hexsha
stringlengths 40
40
| size
int64 3
1.05M
| ext
stringclasses 163
values | lang
stringclasses 53
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
112
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
listlengths 1
10
| max_stars_count
float64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
113
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
listlengths 1
10
| max_issues_count
float64 1
116k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
113
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
listlengths 1
10
| max_forks_count
float64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 3
1.05M
| avg_line_length
float64 1
966k
| max_line_length
int64 1
977k
| alphanum_fraction
float64 0
1
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c39e4642d82f0e20b712cd025a3c01ca6f817a0e | 30,508 | pas | Pascal | Source/Factories/DDuce.Factories.VirtualTrees.pas | beNative/dduce | cedbe2e847cc49fe8bcd5ba12b76327eee43d639 | [
"Apache-2.0"
]
| 52 | 2015-03-17T16:34:08.000Z | 2022-03-16T12:06:09.000Z | Source/Factories/DDuce.Factories.VirtualTrees.pas | beNative/dduce | cedbe2e847cc49fe8bcd5ba12b76327eee43d639 | [
"Apache-2.0"
]
| 2 | 2016-06-04T11:26:16.000Z | 2018-07-11T04:14:16.000Z | Source/Factories/DDuce.Factories.VirtualTrees.pas | beNative/dduce | cedbe2e847cc49fe8bcd5ba12b76327eee43d639 | [
"Apache-2.0"
]
| 10 | 2015-03-25T06:12:24.000Z | 2019-11-13T13:20:27.000Z | {
Copyright (C) 2013-2021 Tim Sinaeve tim.sinaeve@gmail.com
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
}
{$I DDuce.inc}
unit DDuce.Factories.VirtualTrees;
interface
uses
System.Classes, System.UITypes,
Vcl.Controls, Vcl.Forms,
Spring,
VirtualTrees, VirtualTrees.Types, VirtualTrees.Header;
{ TVSTOptions is a settings container which holds the most commonly adjusted
properties of the TVirtualStringTree component.
This is intended to create a consistent look and feel when the
TVirtualStringTree control is used as a tree, grid, list, treegrid, or
treelist control in your applications. }
type
TVSTOptions = class(TPersistent)
strict private
FHeaderOptions : TVTHeaderOptions;
FPaintOptions : TVTPaintOptions;
FAnimationOptions : TVTAnimationOptions;
FAutoOptions : TVTAutoOptions;
FStringOptions : TVTStringOptions;
FSelectionOptions : TVTSelectionOptions;
FMiscOptions : TVTMiscOptions;
FEditOptions : TVTEditOptions;
FColumnOptions : TVTColumnOptions;
FLineStyle : TVTLineStyle; // style of the tree lines
FLineMode : TVTLineMode; // tree lines or bands etc.
FDrawSelectionMode : TVTDrawSelectionMode;
FHintMode : TVTHintMode;
FSelectionTextColor : TColor;
FSelectionRectangleBlendColor : TColor;
FGridLineColor : TColor;
FBorderStyle : TBorderStyle;
public
procedure AssignTo(Dest: TPersistent); override;
procedure Assign(Source: TPersistent); override;
property BorderStyle: TBorderStyle
read FBorderStyle write FBorderStyle default bsSingle;
property HeaderOptions: TVTHeaderOptions
read FHeaderOptions write FHeaderOptions;
property PaintOptions: TVTPaintOptions
read FPaintOptions write FPaintOptions;
property AnimationOptions: TVTAnimationOptions
read FAnimationOptions write FAnimationOptions;
property AutoOptions: TVTAutoOptions
read FAutoOptions write FAutoOptions;
property StringOptions: TVTStringOptions
read FStringOptions write FStringOptions;
property SelectionOptions: TVTSelectionOptions
read FSelectionOptions write FSelectionOptions;
property MiscOptions: TVTMiscOptions
read FMiscOptions write FMiscOptions;
property EditOptions: TVTEditOptions
read FEditOptions write FEditOptions;
property ColumnOptions: TVTColumnOptions // TS: todo default column options
read FColumnOptions write FColumnOptions;
property LineStyle: TVTLineStyle
read FLineStyle write FLineStyle;
property LineMode: TVTLineMode
read FLineMode write FLineMode;
property DrawSelectionMode: TVTDrawSelectionMode
read FDrawSelectionMode write FDrawSelectionMode;
property HintMode: TVTHintMode
read FHintMode write FHintMode;
{ background color for selection. }
property SelectionRectangleBlendColor: TColor
read FSelectionRectangleBlendColor write FSelectionRectangleBlendColor;
{ font color for text in selection. }
property SelectionTextColor: TColor
read FSelectionTextColor write FSelectionTextColor;
property GridLineColor: TColor
read FGridLineColor write FGridLineColor;
end;
type
TVirtualStringTreeFactory = class sealed
private class var
FDefaultTreeOptions : Lazy<TVSTOptions>;
FDefaultGridOptions : Lazy<TVSTOptions>;
FDefaultListOptions : Lazy<TVSTOptions>;
FDefaultTreeGridOptions : Lazy<TVSTOptions>;
FDefaultTreeListOptions : Lazy<TVSTOptions>;
class function GetDefaultGridOptions: TVSTOptions; static;
class function GetDefaultListOptions: TVSTOptions; static;
class function GetDefaultTreeGridOptions: TVSTOptions; static;
class function GetDefaultTreeListOptions: TVSTOptions; static;
class function GetDefaultTreeOptions: TVSTOptions; static;
public
class constructor Create;
class function Create(
AOwner : TComponent;
AParent : TWinControl;
const AName : string = ''
): TVirtualStringTree;
class function CreateTree(
AOwner : TComponent;
AParent : TWinControl;
const AName : string = ''
): TVirtualStringTree;
class function CreateList(
AOwner : TComponent;
AParent : TWinControl;
const AName : string = ''
): TVirtualStringTree;
class function CreateGrid(
AOwner : TComponent;
AParent : TWinControl;
const AName : string = ''
): TVirtualStringTree;
class function CreateTreeGrid(
AOwner : TComponent;
AParent : TWinControl;
const AName : string = ''
): TVirtualStringTree;
class function CreateTreeList(
AOwner : TComponent;
AParent : TWinControl;
const AName : string = ''
): TVirtualStringTree;
class property DefaultTreeOptions: TVSTOptions
read GetDefaultTreeOptions;
class property DefaultGridOptions: TVSTOptions
read GetDefaultGridOptions;
class property DefaultListOptions: TVSTOptions
read GetDefaultListOptions;
class property DefaultTreeGridOptions: TVSTOptions
read GetDefaultTreeGridOptions;
class property DefaultTreeListOptions: TVSTOptions
read GetDefaultTreeListOptions;
end;
implementation
uses
System.SysUtils,
Vcl.Graphics;
type
TCustomVirtualStringTreeAccess = class(TCustomVirtualStringTree) end;
{$REGION 'TVSTOptions'}
procedure TVSTOptions.Assign(Source: TPersistent);
var
LOptions : TVSTOptions;
begin
if Source is TVSTOptions then
begin
LOptions := TVSTOptions(Source);
AnimationOptions := LOptions.AnimationOptions;
AutoOptions := LOptions.AutoOptions;
MiscOptions := LOptions.MiscOptions;
PaintOptions := LOptions.PaintOptions;
SelectionOptions := LOptions.SelectionOptions;
EditOptions := LOptions.EditOptions;
HeaderOptions := LOptions.HeaderOptions;
LineStyle := LOptions.LineStyle;
LineMode := LOptions.LineMode;
DrawSelectionMode := LOptions.DrawSelectionMode;
HintMode := LOptions.HintMode;
BorderStyle := LOptions.BorderStyle;
SelectionTextColor := LOptions.SelectionTextColor;
GridLineColor := LOptions.GridLineColor;
SelectionRectangleBlendColor := LOptions.SelectionRectangleBlendColor;
StringOptions := LOptions.StringOptions;
end
else
inherited Assign(Source);
end;
procedure TVSTOptions.AssignTo(Dest: TPersistent);
var
LTree : TCustomVirtualStringTreeAccess;
LOptions : TVSTOptions;
begin
if Dest is TCustomVirtualStringTree then
begin
LTree := TCustomVirtualStringTreeAccess(Dest);
LTree.TreeOptions.AnimationOptions := AnimationOptions;
LTree.TreeOptions.AutoOptions := AutoOptions;
LTree.TreeOptions.MiscOptions := MiscOptions;
LTree.TreeOptions.PaintOptions := PaintOptions;
LTree.TreeOptions.SelectionOptions := SelectionOptions;
LTree.TreeOptions.EditOptions := EditOptions;
LTree.Header.Options := HeaderOptions;
LTree.LineStyle := LineStyle;
LTree.LineMode := LineMode;
LTree.DrawSelectionMode := DrawSelectionMode;
LTree.HintMode := HintMode;
LTree.BorderStyle := BorderStyle;
LTree.Colors.SelectionTextColor := SelectionTextColor;
LTree.Colors.GridLineColor := GridLineColor;
LTree.Colors.SelectionRectangleBlendColor := SelectionRectangleBlendColor;
TStringTreeOptions(LTree.TreeOptions).StringOptions := StringOptions;
end
else if Dest is TVSTOptions then
begin
LOptions := TVSTOptions(Dest);
LOptions.AnimationOptions := AnimationOptions;
LOptions.AutoOptions := AutoOptions;
LOptions.MiscOptions := MiscOptions;
LOptions.PaintOptions := PaintOptions;
LOptions.SelectionOptions := SelectionOptions;
LOptions.EditOptions := EditOptions;
LOptions.HeaderOptions := HeaderOptions;
LOptions.LineStyle := LineStyle;
LOptions.LineMode := LineMode;
LOptions.DrawSelectionMode := DrawSelectionMode;
LOptions.HintMode := HintMode;
LOptions.BorderStyle := BorderStyle;
LOptions.SelectionTextColor := SelectionTextColor;
LOptions.GridLineColor := GridLineColor;
LOptions.SelectionRectangleBlendColor := SelectionRectangleBlendColor;
LOptions.StringOptions := StringOptions;
end
else
inherited AssignTo(Dest);
end;
{$ENDREGION}
{$REGION 'construction and destruction'}
class constructor TVirtualStringTreeFactory.Create;
begin
{$REGION 'FDefaultTreeOptions'}
FDefaultTreeOptions.Create(
function: TVSTOptions
begin
Result := TVSTOptions.Create;
with Result do
begin
HeaderOptions := [
{hoAutoResize,}
{hoHeightResize,}
{hoHeightDblClickResize,}
{hoRestrictDrag,}
{hoShowHint,}
{hoShowImages,}
{hoShowSortGlyphs,}
{hoVisible}
];
PaintOptions := [
toHideFocusRect,
{toHideSelection,}
toPopupMode,
toShowButtons,
toShowDropmark,
toShowRoot,
toThemeAware,
{toUseExplorerTheme,}
toUseBlendedImages,
toUseBlendedSelection,
toStaticBackground
];
AnimationOptions := [
{toAnimatedToggle,}
{toAdvancedAnimatedToggle}
];
AutoOptions := [
{toAutoDropExpand,}
toAutoScroll,
{toAutoScrollOnExpand,}
toDisableAutoscrollOnEdit,
toAutoSort,
toAutoTristateTracking,
toAutoDeleteMovedNodes,
toAutoChangeScale,
toAutoBidiColumnOrdering
];
StringOptions := [
toAutoAcceptEditChange
];
SelectionOptions := [
{toDisableDrawSelection,}
toExtendedFocus,
{toFullRowSelect,}
{toLevelSelectConstraint,}
{toMiddleClickSelect,}
{toMultiSelect,}
{toRightClickSelect,}
{toSiblingSelectConstraint,}
{toCenterScrollIntoView,}
{toSimpleDrawSelection,}
toAlwaysSelectNode{,}
{toRestoreSelection,}
{toSyncCheckboxesWithSelection}
];
MiscOptions := [
{toAcceptOLEDrop,}
toCheckSupport,
{toEditable,}
{toFullRepaintOnResize,}
{toGridExtensions,}
toInitOnSave,
{toReportMode,}
toToggleOnDblClick,
toWheelPanning,
{toReadOnly,}
toVariableNodeHeight{,}
{toFullRowDrag,}
{toNodeHeightResize,}
{toNodeHeightDblClickResize,}
{toEditOnClick,}
{toEditOnDblClick,}
{toReverseFullExpandHotKey}
];
EditOptions := toDefaultEdit;
ColumnOptions := [
{coAllowClick,}
{coDraggable,}
{coEnabled,}
{coParentBidiMode,}
{coParentColor,}
{coResizable,}
{coShowDropMark,}
{coVisible,}
{coAutoSpring,}
{coFixed,}
{coSmartResize,}
{coAllowFocus,}
{coDisableAnimatedResize,}
{coWrapCaption,}
{coUseCaptionAlignment,}
{coEditable,}
{coStyleColor}
];
LineStyle := lsDotted;
LineMode := lmNormal;
DrawSelectionMode := smBlendedRectangle;
HintMode := hmTooltip;
SelectionRectangleBlendColor := clGray;
SelectionTextColor := clBlack;
GridLineColor := clSilver;
end;
end,
True
);
{$ENDREGION}
{$REGION 'FDefaultGridOptions'}
FDefaultGridOptions.Create(
function: TVSTOptions
begin
Result := TVSTOptions.Create;
with Result do
begin
HeaderOptions := [
hoAutoResize,
hoColumnResize,
hoDblClickResize,
hoDrag,
{hoHotTrack,}
{hoOwnerDraw,}
hoRestrictDrag,
hoShowHint,
hoShowImages,
hoShowSortGlyphs,
hoVisible,
hoAutoSpring,
{hoFullRepaintOnResize,}
hoDisableAnimatedResize{,}
{hoHeightResize,}
{hoHeightDblClickResize,}
{hoHeaderClickAutoSort,}
{hoAutoColumnPopupMenu}
];
PaintOptions := [
toHideFocusRect,
{toHideSelection,}
{toHotTrack,}
toPopupMode,
{toShowBackground,}
toShowButtons,
toShowDropmark,
toShowHorzGridLines,
toShowRoot,
{toShowTreeLines,}
toShowVertGridLines,
toThemeAware,
toUseBlendedImages,
{toGhostedIfUnfocused,}
{toFullVertGridLines,}
{toAlwaysHideSelection,}
toUseBlendedSelection{,}
{toStaticBackground,}
{toChildrenAbove,}
{toFixedIndent,}
{toUseExplorerTheme,}
{toHideTreeLinesIfThemed,}
{toShowFilteredNodes}
];
AnimationOptions := [
{toAnimatedToggle,}
{toAdvancedAnimatedToggle}
];
AutoOptions := [
toAutoDropExpand,
{toAutoExpand,}
toAutoScroll,
toAutoScrollOnExpand,
toAutoSort,
{toAutoSpanColumns,}
toAutoTristateTracking,
{toAutoHideButtons,}
toAutoDeleteMovedNodes,
{toDisableAutoscrollOnFocus,}
toAutoChangeScale,
{toAutoFreeOnCollapse,}
toDisableAutoscrollOnEdit,
toAutoBidiColumnOrdering
];
StringOptions := [
toAutoAcceptEditChange
];
SelectionOptions := [
{toDisableDrawSelection,}
toExtendedFocus,
toFullRowSelect{,}
{toLevelSelectConstraint,}
{toMiddleClickSelect,}
{toMultiSelect,}
{toRightClickSelect,}
{toSiblingSelectConstraint,}
{toCenterScrollIntoView,}
{toSimpleDrawSelection,}
{toAlwaysSelectNode,}
{toRestoreSelection,}
{toSyncCheckboxesWithSelection}
];
MiscOptions := [
{toAcceptOLEDrop,}
toCheckSupport,
{toEditable,}
{toFullRepaintOnResize,}
{toGridExtensions,}
toInitOnSave,
{toReportMode,}
toToggleOnDblClick,
toWheelPanning,
{toReadOnly,}
toVariableNodeHeight{,}
{toFullRowDrag,}
{toNodeHeightResize,}
{toNodeHeightDblClickResize,}
{toEditOnClick,}
{toEditOnDblClick,}
{toReverseFullExpandHotKey}
];
EditOptions := toDefaultEdit;
ColumnOptions := [
{coAllowClick,}
{coDraggable,}
{coEnabled,}
{coParentBidiMode,}
{coParentColor,}
{coResizable,}
{coShowDropMark,}
{coVisible,}
{coAutoSpring,}
{coFixed,}
{coSmartResize,}
{coAllowFocus,}
{coDisableAnimatedResize,}
{coWrapCaption,}
{coUseCaptionAlignment,}
{coEditable,}
{coStyleColor}
];
LineStyle := lsSolid;
LineMode := lmBands;
DrawSelectionMode := smBlendedRectangle;
HintMode := hmTooltip;
SelectionRectangleBlendColor := clGray;
SelectionTextColor := clBlack;
GridLineColor := clSilver;
end;
end,
True
);
{$ENDREGION}
{$REGION 'FDefaultListOptions'}
FDefaultListOptions.Create(
function: TVSTOptions
begin
Result := TVSTOptions.Create;
with Result do
begin
HeaderOptions := [
hoAutoResize, hoAutoSpring, hoColumnResize, hoDblClickResize,
hoDrag, hoRestrictDrag, hoDisableAnimatedResize,
hoShowHint, hoShowImages, hoShowSortGlyphs,
hoVisible
];
PaintOptions := [
toHideFocusRect,
{toHideSelection,}
toHotTrack,
toPopupMode,
{toShowButtons,}
toShowDropmark,
{toShowRoot,}
{toShowHorzGridLines,}
{toShowVertGridLines,}
toThemeAware,
toUseExplorerTheme,
toUseBlendedImages,
toUseBlendedSelection,
toStaticBackground
];
AnimationOptions := [
{toAnimatedToggle,}
{toAdvancedAnimatedToggle}
];
AutoOptions := [
toAutoDropExpand,
toAutoScroll,
toAutoScrollOnExpand,
toDisableAutoscrollOnEdit,
toAutoSort,
toAutoTristateTracking,
toAutoDeleteMovedNodes,
toAutoChangeScale,
toAutoBidiColumnOrdering
];
StringOptions := [toAutoAcceptEditChange];
SelectionOptions := [
{toDisableDrawSelection,}
toExtendedFocus,
toFullRowSelect,
{toLevelSelectConstraint,}
{toMiddleClickSelect,}
{toMultiSelect,}
{toRightClickSelect,}
{toSiblingSelectConstraint,}
{toCenterScrollIntoView,}
{toSimpleDrawSelection,}
toAlwaysSelectNode{,}
{toRestoreSelection,}
{toSyncCheckboxesWithSelection}
];
MiscOptions := [
toCheckSupport,
toInitOnSave,
toToggleOnDblClick,
toWheelPanning,
toVariableNodeHeight
];
EditOptions := toDefaultEdit;
ColumnOptions := [
{coAllowClick,}
{coDraggable,}
{coEnabled,}
{coParentBidiMode,}
{coParentColor,}
{coResizable,}
{coShowDropMark,}
{coVisible,}
{coAutoSpring,}
{coFixed,}
{coSmartResize,}
{coAllowFocus,}
{coDisableAnimatedResize,}
{coWrapCaption,}
{coUseCaptionAlignment,}
{coEditable,}
{coStyleColor}
];
LineStyle := lsSolid;
LineMode := lmNormal;
DrawSelectionMode := smBlendedRectangle;
HintMode := hmTooltip;
SelectionRectangleBlendColor := clGray;
SelectionTextColor := clBlack;
GridLineColor := clSilver;
end;
end,
True
);
{$ENDREGION}
{$REGION 'FDefaultTreeGridOptions'}
FDefaultTreeGridOptions.Create(
function: TVSTOptions
begin
Result := TVSTOptions.Create;
with Result do
begin
HeaderOptions := [
hoAutoResize,
hoAutoSpring,
hoColumnResize,
hoDblClickResize,
hoRestrictDrag,
hoDisableAnimatedResize,
hoShowHint,
hoShowImages,
hoShowSortGlyphs,
hoVisible
];
PaintOptions := [
toHideFocusRect,
{toHideSelection,}
{toHotTrack,}
toPopupMode,
toShowButtons,
toShowDropmark,
toShowRoot,
toShowHorzGridLines,
toShowVertGridLines,
toThemeAware, {toUseExplorerTheme,}
toUseBlendedImages,
toUseBlendedSelection,
toStaticBackground
];
AnimationOptions := [
{toAnimatedToggle,}
{toAdvancedAnimatedToggle}
];
AutoOptions := [
toAutoDropExpand,
toAutoScroll,
toAutoScrollOnExpand,
toDisableAutoscrollOnEdit,
toAutoSort,
toAutoTristateTracking,
toAutoDeleteMovedNodes,
toAutoChangeScale,
toAutoBidiColumnOrdering
];
StringOptions := [toAutoAcceptEditChange];
SelectionOptions := [
{toDisableDrawSelection,}
toExtendedFocus,
toFullRowSelect,
{toLevelSelectConstraint,}
{toMiddleClickSelect,}
{toMultiSelect,}
{toRightClickSelect,}
{toSiblingSelectConstraint,}
{toCenterScrollIntoView,}
{toSimpleDrawSelection,}
toAlwaysSelectNode{,}
{toRestoreSelection,}
{toSyncCheckboxesWithSelection}
];
MiscOptions := [
toCheckSupport,
toInitOnSave,
toToggleOnDblClick,
toWheelPanning,
toVariableNodeHeight
];
EditOptions := toDefaultEdit;
ColumnOptions := [
{coAllowClick,}
{coDraggable,}
{coEnabled,}
{coParentBidiMode,}
{coParentColor,}
{coResizable,}
{coShowDropMark,}
{coVisible,}
{coAutoSpring,}
{coFixed,}
{coSmartResize,}
{coAllowFocus,}
{coDisableAnimatedResize,}
{coWrapCaption,}
{coUseCaptionAlignment,}
{coEditable,}
{coStyleColor}
];
LineStyle := lsSolid;
LineMode := lmNormal;
DrawSelectionMode := smBlendedRectangle;
HintMode := hmTooltip;
SelectionRectangleBlendColor := clGray;
SelectionTextColor := clBlack;
GridLineColor := clSilver;
end;
end,
True
);
{$ENDREGION}
{$REGION 'FDefaultTreeListOptions'}
FDefaultTreeListOptions.Create(
function: TVSTOptions
begin
Result := TVSTOptions.Create;
with Result do
begin
HeaderOptions := [
hoAutoResize,
hoAutoSpring,
hoColumnResize,
hoDblClickResize,
hoRestrictDrag,
hoDisableAnimatedResize,
hoShowHint,
hoShowImages,
hoShowSortGlyphs,
hoVisible
];
PaintOptions := [
toHideFocusRect,
{toHideSelection,}
toHotTrack,
toPopupMode,
toShowButtons,
toShowDropmark,
toShowRoot,
{toShowHorzGridLines,}
toShowVertGridLines,
toThemeAware,
toUseExplorerTheme,
toUseBlendedSelection,
toUseBlendedImages,
toStaticBackground
];
AnimationOptions := [
{toAnimatedToggle,}
{toAdvancedAnimatedToggle}
];
AutoOptions := [
toAutoDropExpand,
toAutoScroll,
toAutoScrollOnExpand,
toDisableAutoscrollOnEdit,
toAutoSort,
toAutoTristateTracking,
toAutoDeleteMovedNodes,
toAutoChangeScale,
toAutoBidiColumnOrdering
];
StringOptions := [toAutoAcceptEditChange];
SelectionOptions := [
{toDisableDrawSelection,}
toExtendedFocus,
toFullRowSelect,
{toLevelSelectConstraint,}
{toMiddleClickSelect,}
{toMultiSelect,}
{toRightClickSelect,}
{toSiblingSelectConstraint,}
{toCenterScrollIntoView,}
{toSimpleDrawSelection,}
toAlwaysSelectNode{,}
{toRestoreSelection,}
{toSyncCheckboxesWithSelection}
];
MiscOptions := [
toCheckSupport,
toInitOnSave,
toToggleOnDblClick,
toWheelPanning,
toVariableNodeHeight
];
EditOptions := toDefaultEdit;
ColumnOptions := [
{coAllowClick,}
{coDraggable,}
{coEnabled,}
{coParentBidiMode,}
{coParentColor,}
{coResizable,}
{coShowDropMark,}
{coVisible,}
{coAutoSpring,}
{coFixed,}
{coSmartResize,}
{coAllowFocus,}
{coDisableAnimatedResize,}
{coWrapCaption,}
{coUseCaptionAlignment,}
{coEditable,}
{coStyleColor}
];
LineStyle := lsSolid;
LineMode := lmNormal;
DrawSelectionMode := smBlendedRectangle;
HintMode := hmTooltip;
SelectionRectangleBlendColor := clGray;
SelectionTextColor := clBlack;
GridLineColor := clSilver;
end;
end,
True
);
{$ENDREGION}
end;
{$ENDREGION}
{$REGION 'property access methods'}
class function TVirtualStringTreeFactory.GetDefaultGridOptions: TVSTOptions;
begin
Result := FDefaultGridOptions;
end;
class function TVirtualStringTreeFactory.GetDefaultListOptions: TVSTOptions;
begin
Result := FDefaultListOptions;
end;
class function TVirtualStringTreeFactory.GetDefaultTreeGridOptions: TVSTOptions;
begin
Result := FDefaultTreeGridOptions;
end;
class function TVirtualStringTreeFactory.GetDefaultTreeListOptions: TVSTOptions;
begin
Result := FDefaultTreeListOptions;
end;
class function TVirtualStringTreeFactory.GetDefaultTreeOptions: TVSTOptions;
begin
Result := FDefaultTreeOptions;
end;
{$ENDREGION}
{$REGION 'public methods'}
{ Creates a TVirtualStringTree instance with stock settings. }
class function TVirtualStringTreeFactory.Create(AOwner: TComponent;
AParent: TWinControl; const AName: string): TVirtualStringTree;
var
VST : TVirtualStringTree;
begin
Guard.CheckNotNull(AOwner, 'AOwner');
Guard.CheckNotNull(AParent, 'AParent');
VST := TVirtualStringTree.Create(AOwner);
VST.AlignWithMargins := True;
VST.Parent := AParent;
VST.Align := alClient;
VST.Header.Height := 18;
VST.ShowHint := True;
Result := VST;
end;
{ Creates a TVirtualStringTree that is tuned to behave and look like a grid
control. }
class function TVirtualStringTreeFactory.CreateGrid(AOwner: TComponent;
AParent: TWinControl; const AName: string): TVirtualStringTree;
var
VST : TVirtualStringTree;
begin
Guard.CheckNotNull(AOwner, 'AOwner');
Guard.CheckNotNull(AParent, 'AParent');
VST := TVirtualStringTree.Create(AOwner);
VST.AlignWithMargins := True;
VST.Parent := AParent;
VST.Align := alClient;
VST.Header.Height := 18;
DefaultGridOptions.AssignTo(VST);
VST.Indent := 2; // show first column as a normal grid column
VST.ShowHint := True;
Result := VST;
end;
{ Creates a TVirtualStringTree that mimics a list control. }
class function TVirtualStringTreeFactory.CreateList(AOwner: TComponent;
AParent: TWinControl; const AName: string): TVirtualStringTree;
var
VST : TVirtualStringTree;
begin
Guard.CheckNotNull(AOwner, 'AOwner');
Guard.CheckNotNull(AParent, 'AParent');
VST := TVirtualStringTree.Create(AOwner);
VST.AlignWithMargins := True;
VST.Parent := AParent;
VST.Align := alClient;
VST.Header.Height := 18;
DefaultListOptions.AssignTo(VST);
VST.Indent := 2; // show first column as a normal grid column
VST.ShowHint := True;
Result := VST;
end;
{ Creates a TVirtualStringTree that will be used as a simple tree control with
no header. }
class function TVirtualStringTreeFactory.CreateTree(AOwner: TComponent;
AParent: TWinControl; const AName: string): TVirtualStringTree;
var
VST : TVirtualStringTree;
begin
Guard.CheckNotNull(AOwner, 'AOwner');
Guard.CheckNotNull(AParent, 'AParent');
VST := TVirtualStringTree.Create(AOwner);
VST.AlignWithMargins := True;
VST.Parent := AParent;
VST.Align := alClient;
VST.ShowHint := True;
DefaultTreeOptions.AssignTo(VST);
Result := VST;
end;
{ Creates a TVirtualStringTree with a header and columns, using the first column
to display the tree structure and tuned to behave and look like a grid
control. }
class function TVirtualStringTreeFactory.CreateTreeGrid(AOwner: TComponent;
AParent: TWinControl; const AName: string): TVirtualStringTree;
var
VST : TVirtualStringTree;
begin
Guard.CheckNotNull(AOwner, 'AOwner');
Guard.CheckNotNull(AParent, 'AParent');
VST := TVirtualStringTree.Create(AOwner);
VST.AlignWithMargins := True;
VST.Parent := AParent;
VST.Align := alClient;
VST.Header.Height := 18;
VST.ShowHint := True;
DefaultTreeGridOptions.AssignTo(VST);
Result := VST;
end;
{ Creates a TVirtualStringTree with a header and columns, using the first column
to display the tree structure and tuned to behave and look like a list
control. }
class function TVirtualStringTreeFactory.CreateTreeList(AOwner: TComponent;
AParent: TWinControl; const AName: string): TVirtualStringTree;
var
VST : TVirtualStringTree;
begin
Guard.CheckNotNull(AOwner, 'AOwner');
Guard.CheckNotNull(AParent, 'AParent');
VST := TVirtualStringTree.Create(AOwner);
VST.AlignWithMargins := True;
VST.Parent := AParent;
VST.Align := alClient;
VST.Header.Height := 18;
VST.ShowHint := True;
DefaultTreeListOptions.AssignTo(VST);
Result := VST;
end;
{$ENDREGION}
end.
| 30.538539 | 81 | 0.607185 |
c3d72f59e05f6729501a0dc112977a0aaee49fdb | 9,716 | pas | Pascal | Source/Core/Object/NovusBO.pas | atkins126/NovuscodeLibrary | fac415cf62a3925590762ed8c060c335f5a0541d | [
"Apache-2.0"
]
| 15 | 2017-02-02T17:43:01.000Z | 2021-03-04T02:12:03.000Z | Source/Core/Object/NovusBO.pas | atkins126/NovuscodeLibrary | fac415cf62a3925590762ed8c060c335f5a0541d | [
"Apache-2.0"
]
| 12 | 2017-04-18T23:51:00.000Z | 2021-01-30T06:36:53.000Z | Source/Core/Object/NovusBO.pas | atkins126/NovuscodeLibrary | fac415cf62a3925590762ed8c060c335f5a0541d | [
"Apache-2.0"
]
| 5 | 2016-11-28T21:38:29.000Z | 2021-02-04T06:22:20.000Z | {$I ..\..\core\NovusCodeLibrary.inc}
unit NovusBO;
interface
Uses NovusObject, Activex, ComObj, Classes, SysUtils,
NovusBOField, NovusBOMap, NovusUtilities, DBXJson, DB, NovusDateUtils,
{$IFDEF DELPHIXE6_UP}
JSON,
{$ENDIF}
NovusStringUtils, NovusDateStringUtils;
Type
TNovusBO = Class(TNovusObject)
private
protected
fsLastExceptionMessage: String;
FoNovusBOMap: TNovusBOMap;
fGUID: tGUID;
foChildList: tList;
foFormObject: tObject;
fsGUIDString: String;
fbIsNewRec: Boolean;
foParentObject: tObject;
function GetoChildList: tList; virtual;
function GetImageIndex: Integer; virtual;
function GetIsNewRec: Boolean; virtual;
procedure SetIsNewRec(Value: Boolean);
function GetGUIDID: String;
procedure SetGUIDID(Value: String);
function GetEOF: Boolean; virtual;
function GetBOF: Boolean; virtual;
public
constructor Create; virtual;
destructor Destroy; override;
procedure InitObjects; virtual;
function GetText: String; virtual;
function GetPrimary_ID: Integer; virtual;
function GetIsMandtoryRecord: Boolean; virtual;
procedure CopyFromJSONObject(aJSONObject: TJSONObject;
aFieldName: string = ''); virtual;
function ToJSONObject: TJSONObject; virtual;
function ToJSON: String;
function ToJSONNoBrackets: String;
procedure PropertiesToFields; virtual;
procedure FieldsToProperties; overload; virtual;
procedure FieldsToProperties(aDataSet: TDataSet); overload; virtual;
procedure SetupFields; virtual;
procedure First; virtual;
procedure Next; virtual;
procedure Open; virtual;
procedure Close; virtual;
procedure New; virtual;
procedure Clear; virtual;
function Retrieve: Boolean; virtual;
function Post: Boolean; virtual;
function Delete: Boolean; virtual;
function NewBO: TNovusBO; virtual;
function CloneBO: TNovusBO; virtual;
procedure CopyFrom(AFromNovusBO: TNovusBO); virtual;
procedure CopyBOFields(AFromNovusBO: TNovusBO);
procedure Sort; virtual;
Property oParentObject: tObject read foParentObject write foParentObject;
property BOF: Boolean read GetBOF;
property EOF: Boolean read GetEOF;
Property IsMandtoryRecord: Boolean read GetIsMandtoryRecord;
Property IsNewRec: Boolean read GetIsNewRec write SetIsNewRec;
Property GUIDString: String read fsGUIDString;
Property oFormObject: tObject read foFormObject write foFormObject;
property Text: String read GetText;
property ImageIndex: Integer read GetImageIndex;
Property oChildList: tList read GetoChildList;
property GUIDID: String read GetGUIDID write SetGUIDID;
property Primary_ID: Integer Read GetPrimary_ID;
property oBOMap: TNovusBOMap read FoNovusBOMap write FoNovusBOMap;
property LastExceptionMessage: String read fsLastExceptionMessage
write fsLastExceptionMessage;
end;
TNovusBOClass = class of TNovusBO;
implementation
// uses NovusStringUtils;
constructor TNovusBO.Create;
begin
FoNovusBOMap := TNovusBOMap.Create;
inherited Create;
CoCreateGuid(fGUID);
fsGUIDString := GUIDToString(fGUID);
fbIsNewRec := False;
foParentObject := NIL;
foChildList := NIL;
SetupFields;
end;
destructor TNovusBO.Destroy;
begin
inherited;
FreeandNIL(FoNovusBOMap);
If Assigned(foChildList) then
FreeandNIL(foChildList);
end;
procedure TNovusBO.SetupFields;
begin
end;
function TNovusBO.GetImageIndex: Integer;
begin
Result := -1;
end;
function TNovusBO.Retrieve: Boolean;
begin
Result := False;
end;
function TNovusBO.Post: Boolean;
begin
Result := False;
fbIsNewRec := False;
end;
function TNovusBO.Delete: Boolean;
begin
Result := False;
fbIsNewRec := False;
end;
procedure TNovusBO.New;
begin
fbIsNewRec := True;
Clear;
end;
procedure TNovusBO.Clear;
begin
end;
function TNovusBO.GetText: String;
begin
Result := '';
end;
function TNovusBO.GetoChildList;
begin
If Not Assigned(foChildList) then
foChildList := tList.Create;
Result := foChildList;
end;
function TNovusBO.GetIsNewRec: Boolean;
begin
Result := fbIsNewRec;
end;
procedure TNovusBO.SetIsNewRec(Value: Boolean);
begin
fbIsNewRec := Value;
end;
procedure TNovusBO.CopyFrom(AFromNovusBO: TNovusBO);
begin
end;
procedure TNovusBO.CopyBOFields(AFromNovusBO: TNovusBO);
Var
I: Integer;
loNovusBOField1: tNovusBOField;
loNovusBOField2: tNovusBOField;
begin
if Not Assigned(AFromNovusBO) then
Exit;
if Assigned(AFromNovusBO.oBOMap) then
begin
For I := 0 to AFromNovusBO.oBOMap.oFieldList.Count - 1 do
begin
loNovusBOField1 := tNovusBOField(AFromNovusBO.oBOMap.oFieldList[I]);
loNovusBOField2 := oBOMap.FieldByName(loNovusBOField1.FieldName);
if Assigned(loNovusBOField2) then
loNovusBOField2.Value := loNovusBOField1.Value;
end;
end;
end;
function TNovusBO.CloneBO: TNovusBO;
begin
Result := NIL;
end;
function TNovusBO.NewBO: TNovusBO;
begin
Result := NIL;
end;
function TNovusBO.GetGUIDID: String;
begin
Result := fsGUIDString;
end;
procedure TNovusBO.SetGUIDID(Value: String);
begin
fsGUIDString := Value;
fGUID := StringToGUID(fsGUIDString);
end;
function TNovusBO.GetIsMandtoryRecord: Boolean;
begin
Result := False;
end;
function TNovusBO.GetPrimary_ID: Integer;
begin
Result := 0;
end;
procedure TNovusBO.First;
begin
end;
procedure TNovusBO.Next;
begin
end;
function TNovusBO.GetEOF: Boolean;
begin
Result := True;
end;
function TNovusBO.GetBOF: Boolean;
begin
Result := False;
end;
procedure TNovusBO.Open;
begin
end;
procedure TNovusBO.Close;
begin
end;
procedure TNovusBO.Sort;
begin
end;
procedure TNovusBO.PropertiesToFields;
begin
end;
procedure TNovusBO.FieldsToProperties;
begin
end;
procedure TNovusBO.FieldsToProperties(aDataSet: TDataSet);
begin
end;
procedure TNovusBO.InitObjects;
begin
end;
procedure TNovusBO.CopyFromJSONObject(aJSONObject: TJSONObject;
aFieldName: string = '');
var
loBOField: tNovusBOField;
I: Integer;
LJPair: TJSONPair;
procedure PassField(var aBOField: tNovusBOField; aLJPair: TJSONPair);
begin
if aBOField is TnovusBODateTimeField then
begin
aBOField.Value := TNovusDateUtils.UnixTimeToDateTime
(TNovusDateStringUtils.JSONDateStr2UnixTime
(TJSONString(aLJPair.JsonValue).Value));
end
else if aBOField is TNovusBOIntegerField then
aBOField.Value := TJSONNumber(aLJPair.JsonValue).AsInt
else if aBOField is TNovusBOStringField then
aBOField.Value := TJSONString(aLJPair.JsonValue).Value
else if aBOField is TNovusBOSmallintField then
begin
if (tNovusStringUtils.IsBoolean(aLJPair.JsonValue.ToString)) or
TNovusBOSmallintField(loBOField).UseAsBoolean then
begin
aBOField.Value :=
Smallint(tNovusStringUtils.StrToBoolean(aLJPair.JsonValue.ToString));
end
else
aBOField.Value := Smallint(TJSONNumber(aLJPair.JsonValue).AsInt);
end;
end;
begin
if Not Assigned(aJSONObject) then
Exit;
for I := 0 to aJSONObject.Size - 1 do
begin
LJPair := aJSONObject.Get(I);
loBOField := oBOMap.FieldByName(TJSONPair(LJPair).JsonString.Value);
if Assigned(loBOField) then
begin
if aFieldName = '' then
begin
PassField(loBOField, LJPair);
end
else if aFieldName = loBOField.FieldName then
begin
PassField(loBOField, LJPair);
break;
end;
end;
end;
end;
function TNovusBO.ToJSONObject: TJSONObject;
var
loJSONObject: TJSONObject;
I: Integer;
LJValue: TJSONValue;
loBOField: tNovusBOField;
begin
loJSONObject := TJSONObject.Create;
for I := 0 to oBOMap.oFieldList.Count - 1 do
begin
loBOField := tNovusBOField(oBOMap.oFieldList.Items[I]);
if loBOField.ToJSON then
begin
if loBOField is TnovusBODateTimeField then
begin
if loBOField.Value <> 0 then
loJSONObject.AddPair(TJSONPair.Create(loBOField.FieldName,
TJSONString.Create(TNovusDateUtils.DateTimeToISO8601
(loBOField.Value))));
end
else if loBOField is TNovusBOStringField then
loJSONObject.AddPair(TJSONPair.Create(loBOField.FieldName,
TJSONString.Create(loBOField.Value)))
else if loBOField is TNovusBOIntegerField then
loJSONObject.AddPair(TJSONPair.Create(loBOField.FieldName,
TJSONNumber.Create(loBOField.Value)))
else if loBOField is TNovusBOFloatField then
loJSONObject.AddPair(TJSONPair.Create(loBOField.FieldName,
TJSONNumber.Create(loBOField.Value)))
else if loBOField is TNovusBOBooleanField then
loJSONObject.AddPair(TJSONPair.Create(loBOField.FieldName,
TJSONString.Create(tNovusStringUtils.BooleanToStr(TNovusBOBooleanField
(loBOField).AsBoolean))))
else if loBOField is TNovusBOSmallintField then
begin
if Not TNovusBOSmallintField(loBOField).UseAsBoolean then
loJSONObject.AddPair(TJSONPair.Create(loBOField.FieldName,
TJSONNumber.Create(loBOField.Value)))
else
loJSONObject.AddPair(TJSONPair.Create(loBOField.FieldName,
TJSONString.Create(tNovusStringUtils.BooleanToStr
(TNovusBOSmallintField(loBOField).AsBoolean))));
end;
end;
end;
Result := loJSONObject;
end;
function TNovusBO.ToJSON: String;
var
loJSONObject: TJSONObject;
begin
loJSONObject := ToJSONObject;
Result := loJSONObject.ToString;
loJSONObject.Free;
end;
function TNovusBO.ToJSONNoBrackets: String;
begin
Result := tNovusStringUtils.StripChar(ToJSON, '{');
Result := tNovusStringUtils.StripChar(Result, '}');
end;
end.
| 22.081818 | 80 | 0.732091 |
47cd97a0037ddf88a688c54774c7659ddbf265b5 | 1,588 | dfm | Pascal | Packages/Order Entry Results Reporting/CPRS/CPRS-Chart/XuDigSig/fPINPrompt.dfm | timmvt/VistA_tt | 05694e3a98c026f682f99ca9eb701bdd1e82af28 | [
"Apache-2.0"
]
| 1 | 2017-04-18T15:55:43.000Z | 2017-04-18T15:55:43.000Z | Packages/Order Entry Results Reporting/CPRS/CPRS-Chart/XuDigSig/fPINPrompt.dfm | timmvt/VistA_tt | 05694e3a98c026f682f99ca9eb701bdd1e82af28 | [
"Apache-2.0"
]
| null | null | null | Packages/Order Entry Results Reporting/CPRS/CPRS-Chart/XuDigSig/fPINPrompt.dfm | timmvt/VistA_tt | 05694e3a98c026f682f99ca9eb701bdd1e82af28 | [
"Apache-2.0"
]
| null | null | null | object frmPINPrompt: TfrmPINPrompt
Left = 192
Top = 114
BorderStyle = bsDialog
Caption = 'CPRS PIV card PIN entry'
ClientHeight = 198
ClientWidth = 249
Color = clBtnFace
DefaultMonitor = dmMainForm
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsStayOnTop
OldCreateOrder = False
Position = poScreenCenter
OnShow = FormShow
DesignSize = (
249
198)
PixelsPerInch = 96
TextHeight = 13
object Panel3: TPanel
Left = 0
Top = 67
Width = 249
Height = 41
Color = clRed
TabOrder = 2
end
object Panel1: TPanel
Left = 0
Top = 87
Width = 249
Height = 114
Anchors = [akTop, akRight, akBottom]
TabOrder = 0
object Label1: TLabel
Left = 8
Top = 8
Width = 126
Height = 13
Caption = 'Please enter your PIV PIN:'
end
object btnOK: TButton
Left = 21
Top = 70
Width = 75
Height = 25
Caption = '&OK'
Default = True
ModalResult = 1
TabOrder = 0
OnClick = btnOKClick
end
object btnCancel: TButton
Left = 134
Top = 70
Width = 75
Height = 25
Caption = '&Cancel'
ModalResult = 2
TabOrder = 1
end
object edtPINValue: TEdit
Left = 21
Top = 27
Width = 188
Height = 21
PasswordChar = '*'
TabOrder = 2
end
end
object Panel2: TPanel
Left = 0
Top = 0
Width = 249
Height = 81
Color = clGray
TabOrder = 1
end
end
| 18.904762 | 44 | 0.578086 |
c334d807b65fab48035268042dc67a85e4e8a510 | 1,334 | pas | Pascal | Packages/Order Entry Results Reporting/CPRS/CPRS-Chart/Cover Sheet/oCoverSheetParam_WidgetClock.pas | rjwinchester/VistA | 6ada05a153ff670adcb62e1c83e55044a2a0f254 | [
"Apache-2.0"
]
| 72 | 2015-02-03T02:30:45.000Z | 2020-01-30T17:20:52.000Z | Packages/Order Entry Results Reporting/CPRS/CPRS-Chart/Cover Sheet/oCoverSheetParam_WidgetClock.pas | rjwinchester/VistA | 6ada05a153ff670adcb62e1c83e55044a2a0f254 | [
"Apache-2.0"
]
| 80 | 2016-04-19T12:04:06.000Z | 2020-01-31T14:35:19.000Z | Packages/Order Entry Results Reporting/CPRS/CPRS-Chart/Cover Sheet/oCoverSheetParam_WidgetClock.pas | rjwinchester/VistA | 6ada05a153ff670adcb62e1c83e55044a2a0f254 | [
"Apache-2.0"
]
| 67 | 2015-01-27T16:47:56.000Z | 2020-02-12T21:23:56.000Z | unit oCoverSheetParam_WidgetClock;
{
================================================================================
*
* Application: CPRS - CoverSheet
* Developer: doma.user@domain.ext
* Site: Salt Lake City ISC
* Date: 2015-12-04
*
* Description: Proof of concept for multiple types of panels.
*
* Notes:
*
================================================================================
}
interface
uses
System.Classes,
System.SysUtils,
Vcl.Controls,
oCoverSheetParam,
iCoverSheetIntf;
type
TCoverSheetParam_WidgetClock = class(TCoverSheetParam, ICoverSheetParam)
protected
function NewCoverSheetControl(aOwner: TComponent): TControl; override;
public
constructor Create(aInitStr: string = '');
end;
implementation
uses
oDelimitedString,
mCoverSheetDisplayPanel_WidgetClock;
{ TCoverSheetParam_WidgetClock }
constructor TCoverSheetParam_WidgetClock.Create(aInitStr: string = '');
begin
inherited Create;
with NewDelimitedString(aInitStr) do
try
setTitle(GetPieceAsString(2, 'Clock'));
finally
Free;
end;
end;
function TCoverSheetParam_WidgetClock.NewCoverSheetControl(aOwner: TComponent): TControl;
begin
Result := TfraCoverSheetDisplayPanel_WidgetClock.Create(aOwner);
end;
end.
| 22.610169 | 89 | 0.624438 |
fcddfaba2de41b1f1eb383eb60e4193715568f9b | 2,440 | pas | Pascal | Demos/Extensions/Math/extmain.pas | bgarrels/php4delphi | 041fed9bb6898faed25076f6ff893bfee93e41cd | [
"PHP-3.0"
]
| 19 | 2015-08-10T15:42:28.000Z | 2021-11-23T02:04:02.000Z | Demos/Extensions/Math/extmain.pas | bgarrels/php4delphi | 041fed9bb6898faed25076f6ff893bfee93e41cd | [
"PHP-3.0"
]
| 2 | 2018-06-22T12:45:58.000Z | 2020-11-30T09:05:57.000Z | Demos/Extensions/Math/extmain.pas | bgarrels/php4delphi | 041fed9bb6898faed25076f6ff893bfee93e41cd | [
"PHP-3.0"
]
| 13 | 2015-05-02T14:39:20.000Z | 2021-11-18T19:50:05.000Z | {*******************************************************}
{ PHP4Delphi }
{ PHP - Delphi interface }
{ Author: }
{ Serhiy Perevoznyk }
{ serge_perevoznyk@hotmail.com }
{ http://users.chello.be/ws36637 }
{*******************************************************}
{ $Id: extmain.pas,v 6.2 02/2006 delphi32 Exp $ }
unit extmain;
interface
uses
Windows,
Messages,
SysUtils,
Classes,
Forms,
zendTypes,
zendAPI,
phpTypes,
phpAPI,
phpFunctions,
PHPModules,
math;
type
TMathExtension = class(TPHPExtension)
procedure SinExecute(Sender: TObject;
Parameters: TFunctionParams; var ReturnValue: Variant;
ThisPtr: Pzval; TSRMLS_DC: Pointer);
procedure CoshExecute(Sender: TObject;
Parameters: TFunctionParams; var ReturnValue: Variant;
ThisPtr: Pzval; TSRMLS_DC: Pointer);
procedure ArcsinExecute(Sender: TObject;
Parameters: TFunctionParams; var ReturnValue: Variant;
ThisPtr: Pzval; TSRMLS_DC: Pointer);
procedure ArccoshExecute(Sender: TObject;
Parameters: TFunctionParams; var ReturnValue: Variant;
ThisPtr: Pzval; TSRMLS_DC: Pointer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MathExtension: TMathExtension;
implementation
{$R *.DFM}
procedure TMathExtension.SinExecute(Sender: TObject;
Parameters: TFunctionParams; var ReturnValue: Variant; ThisPtr: Pzval;
TSRMLS_DC: Pointer);
begin
ReturnValue := Sin(Parameters[0].ZendVariable.AsFloat);
end;
procedure TMathExtension.CoshExecute(Sender: TObject;
Parameters: TFunctionParams; var ReturnValue: Variant; ThisPtr: Pzval;
TSRMLS_DC: Pointer);
begin
ReturnValue := Cosh(Parameters[0].Value);
end;
procedure TMathExtension.ArcsinExecute(Sender: TObject;
Parameters: TFunctionParams; var ReturnValue: Variant; ThisPtr: Pzval;
TSRMLS_DC: Pointer);
begin
ReturnValue := ArcSin(Parameters[0].value);
end;
procedure TMathExtension.ArccoshExecute(Sender: TObject;
Parameters: TFunctionParams; var ReturnValue: Variant; ThisPtr: Pzval;
TSRMLS_DC: Pointer);
begin
ReturnValue := ArcCosh(Parameters[0].ZendVariable.AsFloat);
end;
end. | 28.372093 | 73 | 0.612705 |
fcda1a2043f101e0e3f6612e55743750a2e69078 | 1,614 | pas | Pascal | Source/Database/Database.Order.pas | marcosblastwer/delphi-framework-orm | 786e40152330808f23e1b82fff82a3d94a760653 | [
"MIT"
]
| 1 | 2021-04-23T02:00:39.000Z | 2021-04-23T02:00:39.000Z | Source/Database/Database.Order.pas | marcosblastwer/delphi-framework-database | 88ca787bc9b15bba150496c1e509d96fcc66b7c3 | [
"MIT"
]
| null | null | null | Source/Database/Database.Order.pas | marcosblastwer/delphi-framework-database | 88ca787bc9b15bba150496c1e509d96fcc66b7c3 | [
"MIT"
]
| null | null | null | unit Database.Order;
interface
uses
Base.Objects;
type
TOrderAttr = (
oaNone,
oaAsc,
oaDesc );
IOrder = interface(IFrameworkInterface)
['{60BBB931-8DFA-4115-A3B4-336063379B84}']
function GetAttr: TOrderAttr;
function GetValue: IFrameworkInterface;
function SetAttr(const Value: TOrderAttr): IOrder;
function SetValue(const AValue: IFrameworkInterface): IOrder;
property Attr: TOrderAttr read GetAttr;
property Value: IFrameworkInterface read GetValue;
end;
implementation
type
TOrder = class(TFrameworkObject, IOrder)
private
FAttr: TOrderAttr;
FValue: IFrameworkInterface;
function GetAttr: TOrderAttr;
function GetValue: IFrameworkInterface;
function SetAttr(const Value: TOrderAttr): IOrder;
function SetValue(const AValue: IFrameworkInterface): IOrder;
public
constructor Create;
destructor Destroy; override;
end;
{ TOrder }
constructor TOrder.Create;
begin
inherited;
FAttr := oaNone;
FValue := nil;
end;
destructor TOrder.Destroy;
begin
if Assigned(FValue) then
begin
try
FValue := nil;
except end;
end;
inherited;
end;
function TOrder.GetAttr: TOrderAttr;
begin
Result := FAttr;
end;
function TOrder.GetValue: IFrameworkInterface;
begin
Result := FValue;
end;
function TOrder.SetAttr(const Value: TOrderAttr): IOrder;
begin
FAttr := Value;
Result := Self;
end;
function TOrder.SetValue(const AValue: IFrameworkInterface): IOrder;
begin
FValue := AValue;
Result := Self;
end;
end.
| 19.214286 | 69 | 0.684634 |
c3e90ca77142d7869d26e41d0327d7e19c42d211 | 6,632 | pas | Pascal | RhodusIDE/Image32/Examples/Layers201/arrows.pas | ObjectPascalInterpreter/BookPart_3 | 95150d4d02f7e13e5b1ebb58c249073a384f2a0a | [
"Apache-2.0"
]
| 8 | 2021-11-07T22:45:25.000Z | 2022-03-12T21:38:53.000Z | RhodusIDE/Image32/Examples/Layers201/arrows.pas | ObjectPascalInterpreter/BookPart_3 | 95150d4d02f7e13e5b1ebb58c249073a384f2a0a | [
"Apache-2.0"
]
| 4 | 2021-09-23T02:13:55.000Z | 2021-12-07T06:08:17.000Z | RhodusIDE/Image32/Examples/Layers201/arrows.pas | ObjectPascalInterpreter/BookPart_3 | 95150d4d02f7e13e5b1ebb58c249073a384f2a0a | [
"Apache-2.0"
]
| 4 | 2021-11-24T17:24:56.000Z | 2021-12-21T04:56:58.000Z | unit arrows;
interface
uses
Windows, Messages, SysUtils, Types, Classes, Math,
Img32, Img32.Layers, Main, Img32.Draw, Img32.Extra,
Img32.Vector, Img32.Transform;
type
TMyArrowLayer32 = class(TMyVectorLayer32) //TMyVectorLayer32 - see main.pas
public
procedure Init(const centerPt: TPointD);
procedure UpdateArrow(btnGroup: TGroupLayer32; btnIdx: integer);
end;
var
defaultArrowBtns: TPathsD;
implementation
//------------------------------------------------------------------------------
// TMyArrowLayer32 - demonstrates using custom designer buttons
//------------------------------------------------------------------------------
procedure TMyArrowLayer32.Init(const centerPt: TPointD);
var
rec: TRectD;
begin
rec := Img32.Vector.GetBoundsD(defaultArrowBtns);
Self.Paths := OffsetPath(defaultArrowBtns,
centerPt.X - rec.Left - rec.Width/2,
centerPt.Y -rec.Top - rec.Height/2);
end;
//------------------------------------------------------------------------------
function TurnsLeft2(const pt1, pt2, pt3: TPointD): boolean;
begin
result := CrossProduct(pt1, pt2, pt3) <= 0;
end;
//---------------------------------------------------------------------------
function TurnsRight2(const pt1, pt2, pt3: TPointD): boolean;
begin
result := CrossProduct(pt1, pt2, pt3) >= 0;
end;
//---------------------------------------------------------------------------
function GrtrEqu90(const pt1, pt2, pt3: TPointD): boolean;
begin
result := DotProduct(pt1, pt2, pt3) <= 0;
end;
//---------------------------------------------------------------------------
function AlmostParallel(const pt1, pt2, pt3: TPointD): boolean;
var
a: double;
const
angle5 = angle1 *5;
angle175 = angle180 - angle5;
begin
//precondition: angle <= 180 degrees
a := Abs(GetAngle(pt1, pt2, pt3));
Result := (a < angle5) or (a > angle175);
end;
//---------------------------------------------------------------------------
function AlmostPerpendicular(const pt1, pt2, pt3: TPointD): boolean;
var
a: double;
const
angle5 = angle1 *5;
angle85 = angle90 - angle5;
begin
//precondition: angle <= 90 degrees
a := GetAngle(pt1, pt2, pt3);
Result := a > angle85;
end;
//---------------------------------------------------------------------------
procedure TMyArrowLayer32.UpdateArrow(btnGroup: TGroupLayer32;
btnIdx: integer);
var
i: integer;
center, newPt, pt2, vec: TPointD;
dist: Double;
p: TPathD;
label
bottom; //goto label
begin
//preserve arrow symmetry and avoids 'broken' non-arrow polygons
p := Copy(Paths[0], 0, 7);
center := Img32.Vector.MidPoint(p[3], p[4]);
newPt := btnGroup[btnIdx].MidPoint;
case btnIdx of
0:
begin
newPt := ClosestPointOnLine(newPt, p[0], center);
if TurnsRight(newPt, p[1], p[6]) and
TurnsRight(newPt, p[1], p[2]) then
p[0] := newPt;
end;
1:
begin
dist := Distance(p[2], p[5]) * 0.5;
pt2 := ClosestPointOnLine(newPt, p[0], center);
if GrtrEqu90(newPt, center, p[0]) or
(Distance(newPt, pt2) <= 2) or
AlmostPerpendicular(center, p[0], newPt) then Goto bottom;
p[1] := newPt;
p[6] := ReflectPoint(newPt, pt2);
if TurnsLeft2(newPt, p[2], p[0]) or
TurnsRight(newPt, p[2], p[5]) or
TurnsRight2(newPt, p[2], p[3]) then
begin
vec := GetUnitVector(pt2, p[1]);
p[2] := PointD(pt2.X + vec.X * dist, pt2.Y + vec.Y * dist);
p[5] := PointD(pt2.X + vec.X * -dist, pt2.Y + vec.Y * -dist);
end;
end;
2:
begin
if TurnsRight2(newPt, p[1], p[0]) or
TurnsRight2(p[1], newPt, p[3]) or
TurnsLeft2(newPt, p[3], p[4]) or
TurnsLeft2(p[0], newPt, center) or
AlmostParallel(p[0], newPt, center) then Goto bottom;
p[2] := newPt;
pt2 := ClosestPointOnLine(newPt, p[0], center);
p[5] := ReflectPoint(newPt, pt2);
if TurnsRight2(p[1], newPt, p[6]) then
begin
dist := Distance(p[1], p[6]) * 0.5;
vec := GetUnitNormal(p[0], center); //perpendicular to center line
p[1] := PointD(pt2.X + vec.X * dist, pt2.Y + vec.Y * dist);
p[6] := PointD(pt2.X + vec.X * -dist, pt2.Y + vec.Y * -dist);
end;
end;
3:
begin
if TurnsRight(newPt, p[0], center) or
TurnsRight2(p[1], p[2], newPt) then Goto bottom;
p[3] := newPt;
center := ClosestPointOnLine(newPt, p[0], center);
p[4] := ReflectPoint(newPt, center);
end;
4:
begin
if TurnsLeft(newPt, p[0], center) or
TurnsLeft2(p[6], p[5], newPt) then Goto bottom;
p[4] := newPt;
center := ClosestPointOnLine(newPt, p[0], center);
p[3] := ReflectPoint(newPt, center);
end;
5:
begin
if TurnsLeft2(newPt, p[6], p[0]) or
TurnsLeft2(p[6], newPt, p[4]) or
TurnsRight2(newPt, p[4], p[3]) or
TurnsRight2(p[0], newPt, center) or
AlmostParallel(p[0], newPt, center) then Goto bottom;
p[5] := newPt;
pt2 := ClosestPointOnLine(newPt, p[0], center);
p[2] := ReflectPoint(newPt, pt2);
if TurnsLeft2(p[6], newPt, p[1]) then
begin
dist := Distance(p[6], p[1]) * 0.5;
vec := GetUnitNormal(center, p[0]); //perpendicular to center line
p[6] := PointD(pt2.X + vec.X * dist, pt2.Y + vec.Y * dist);
p[1] := PointD(pt2.X + vec.X * -dist, pt2.Y + vec.Y * -dist);
end;
end;
6:
begin
dist := Distance(p[5], p[2]) * 0.5;
pt2 := ClosestPointOnLine(newPt, p[0], center);
if GrtrEqu90(newPt, center, p[0]) or
(Distance(newPt, pt2) <= 2) or
AlmostPerpendicular(center, p[0], newPt) then Goto bottom;
p[6] := newPt;
p[1] := ReflectPoint(newPt, pt2);
if TurnsRight2(newPt, p[5], p[0]) or
TurnsLeft(newPt, p[5], p[2]) or
TurnsLeft2(newPt, p[5], p[4]) then
begin
vec := GetUnitVector(pt2, p[6]);
p[5] := PointD(pt2.X + vec.X * dist, pt2.Y + vec.Y * dist);
p[2] := PointD(pt2.X + vec.X * -dist, pt2.Y + vec.Y * -dist);
end;
end;
end;
bottom: //label
for i := 0 to btnGroup.ChildCount -1 do
btnGroup[i].PositionCenteredAt(p[i]);
Paths := Img32.Vector.Paths(p);
end;
//---------------------------------------------------------------------------
initialization
SetLength(defaultArrowBtns, 1);
defaultArrowBtns[0] :=
MakePathI([0,100, 100,0, 100,50, 200,50, 200,150, 100,150, 100,200]);
end.
| 31.884615 | 80 | 0.5193 |
c3826566a360ae7064ace78af7ce5a371c4f78be | 996 | dfm | Pascal | JmpTime.dfm | delphi-pascal-archive/ay_emul_2.8 | bb8cb89fe8f52dd7a71e916ac7f408dbd4777bcf | [
"Unlicense"
]
| null | null | null | JmpTime.dfm | delphi-pascal-archive/ay_emul_2.8 | bb8cb89fe8f52dd7a71e916ac7f408dbd4777bcf | [
"Unlicense"
]
| null | null | null | JmpTime.dfm | delphi-pascal-archive/ay_emul_2.8 | bb8cb89fe8f52dd7a71e916ac7f408dbd4777bcf | [
"Unlicense"
]
| null | null | null | object Form8: TForm8
Left = 206
Top = 163
BorderStyle = bsDialog
ClientHeight = 89
ClientWidth = 182
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 88
Top = 12
Width = 3
Height = 13
end
object Label2: TLabel
Left = 11
Top = 35
Width = 3
Height = 13
end
object Button1: TButton
Left = 8
Top = 56
Width = 75
Height = 25
Default = True
ModalResult = 1
TabOrder = 0
end
object Button2: TButton
Left = 96
Top = 56
Width = 75
Height = 25
Cancel = True
ModalResult = 2
TabOrder = 1
end
object Edit1: TEdit
Left = 8
Top = 8
Width = 73
Height = 21
TabOrder = 2
end
end
| 17.785714 | 33 | 0.569277 |
47118c766c26c3d0fe9cb96abfd75bf2290c6ab9 | 35,792 | pas | Pascal | SDK/Delphi/XPLM/XPLMDisplay.pas | AncientEncoder/SkyLine_Client | 94d634864c3f9ec130b094f63c006af00280aa90 | [
"MIT"
]
| 1 | 2022-02-06T15:27:28.000Z | 2022-02-06T15:27:28.000Z | SDK/Delphi/XPLM/XPLMDisplay.pas | jpoirier/saitek-plugin-xplane | cbf4e25da7c7aff5c84a55355770c4d81810f720 | [
"BSD-3-Clause"
]
| null | null | null | SDK/Delphi/XPLM/XPLMDisplay.pas | jpoirier/saitek-plugin-xplane | cbf4e25da7c7aff5c84a55355770c4d81810f720 | [
"BSD-3-Clause"
]
| 1 | 2022-02-06T15:27:27.000Z | 2022-02-06T15:27:27.000Z | {
Copyright 2005 Sandy Barbour and Ben Supnik
All rights reserved. See license.txt for usage.
X-Plane SDK Version: 1.0.2
}
UNIT XPLMDisplay;
INTERFACE
{
XPLM Display APIs - THEORY OF OPERATION
This API provides the basic hooks to draw in X-Plane and create user
interface. All X-Plane drawing is done in OpenGL. The X-Plane plug-in
manager takes care of properly setting up the OpenGL context and matrices.
You do not decide when in your code's execution to draw; X-Plane tells you
when it is ready to have your plugin draw.
X-Plane's drawing strategy is straightforward: every "frame" the screen is
rendered by drawing the 3-d scene (dome, ground, objects, airplanes, etc.)
and then drawing the cockpit on top of it. Alpha blending is used to
overlay the cockpit over the world (and the gauges over the panel, etc.).
There are two ways you can draw: directly and in a window.
Direct drawing involves drawing to the screen before or after X-Plane
finishes a phase of drawing. When you draw directly, you can specify
whether x-plane is to complete this phase or not. This allows you to do
three things: draw before x-plane does (under it), draw after x-plane does
(over it), or draw instead of x-plane.
To draw directly, you register a callback and specify what phase you want
to intercept. The plug-in manager will call you over and over to draw that
phase.
Direct drawing allows you to override scenery, panels, or anything. Note
that you cannot assume that you are the only plug-in drawing at this
phase.
Window drawing provides slightly higher level functionality. With window
drawing you create a window that takes up a portion of the screen. Window
drawing is always two dimensional. Window drawing is front-to-back
controlled; you can specify that you want your window to be brought on
top, and other plug-ins may put their window on top of you. Window drawing
also allows you to sign up for key presses and receive mouse clicks.
There are three ways to get keystrokes:
If you create a window, the window can take keyboard focus. It will then
receive all keystrokes. If no window has focus, X-Plane receives
keystrokes. Use this to implement typing in dialog boxes, etc. Only one
window may have focus at a time; your window will be notified if it loses
focus.
If you need to associate key strokes with commands/functions in your
plug-in, use a hot key. A hoy is a key-specific callback. Hotkeys are
sent based on virtual key strokes, so any key may be distinctly mapped with
any modifiers. Hot keys can be remapped by other plug-ins. As a plug-in,
you don't have to worry about what your hot key ends up mapped to; other
plug-ins may provide a UI for remapping keystrokes. So hotkeys allow a
user to resolve conflicts and customize keystrokes.
If you need low level access to the keystroke stream, install a key
sniffer. Key sniffers can be installed above everything or right in front
of the sim.
}
USES XPLMDefs;
{$A4}
{$IFDEF MSWINDOWS}
{$DEFINE DELPHI}
{$ENDIF}
{___________________________________________________________________________
* DRAWING CALLBACKS
___________________________________________________________________________}
{
Basic drawing callbacks, for low level intercepting of render loop. The
purpose of drawing callbacks is to provide targeted additions or
replacements to x-plane's graphics environment (for example, to add extra
custom objects, or replace drawing of the AI aircraft). Do not assume that
the drawing callbacks will be called in the order implied by the
enumerations. Also do not assume that each drawing phase ends before
another begins; they may be nested.
}
{
XPLMDrawingPhase
This constant indicates which part of drawing we are in. Drawing is done
from the back to the front. We get a callback before or after each item.
Metaphases provide access to the beginning and end of the 3d (scene) and 2d
(cockpit) drawing in a manner that is independent of new phases added via
x-plane implementation.
WARNING: As X-Plane's scenery evolves, some drawing phases may cease to
exist and new ones may be invented. If you need a particularly specific
use of these codes, consult Austin and/or be prepared to revise your code
as X-Plane evolves.
}
TYPE
XPLMDrawingPhase = (
{ This is the earliest point at which you can draw in 3-d. }
xplm_Phase_FirstScene = 0
{ Drawing of land and water. }
,xplm_Phase_Terrain = 5
{ Drawing runways and other airport detail. }
,xplm_Phase_Airports = 10
{ Drawing roads, trails, trains, etc. }
,xplm_Phase_Vectors = 15
{ 3-d objects (houses, smokestacks, etc. }
,xplm_Phase_Objects = 20
{ External views of airplanes, both yours and the AI aircraft. }
,xplm_Phase_Airplanes = 25
{ This is the last point at which you can draw in 3-d. }
,xplm_Phase_LastScene = 30
{ This is the first phase where you can draw in 2-d. }
,xplm_Phase_FirstCockpit = 35
{ The non-moving parts of the aircraft panel. }
,xplm_Phase_Panel = 40
{ The moving parts of the aircraft panel. }
,xplm_Phase_Gauges = 45
{ Floating windows from plugins. }
,xplm_Phase_Window = 50
{ The last change to draw in 2d. }
,xplm_Phase_LastCockpit = 55
{$IFDEF XPLM200}
{ 3-d Drawing for the local map. Use regular OpenGL coordinates to draw in }
{ this phase. }
,xplm_Phase_LocalMap3D = 100
{$ENDIF}
{$IFDEF XPLM200}
{ 2-d Drawing of text over the local map. }
,xplm_Phase_LocalMap2D = 101
{$ENDIF}
{$IFDEF XPLM200}
{ Drawing of the side-profile view in the local map screen. }
,xplm_Phase_LocalMapProfile = 102
{$ENDIF}
);
PXPLMDrawingPhase = ^XPLMDrawingPhase;
{
XPLMDrawCallback_f
This is the prototype for a low level drawing callback. You are passed in
the phase and whether it is before or after. If you are before the phase,
return 1 to let x-plane draw or 0 to suppress x-plane drawing. If you are
after the phase the return value is ignored.
Refcon is a unique value that you specify when registering the callback,
allowing you to slip a pointer to your own data to the callback.
Upon entry the OpenGL context will be correctly set up for you and OpenGL
will be in 'local' coordinates for 3d drawing and panel coordinates for 2d
drawing. The OpenGL state (texturing, etc.) will be unknown.
}
XPLMDrawCallback_f = FUNCTION(
inPhase : XPLMDrawingPhase;
inIsBefore : integer;
inRefcon : pointer) : integer; cdecl;
{
XPLMKeySniffer_f
This is the prototype for a low level key-sniffing function. Window-based
UI _should not use this_! The windowing system provides high-level
mediated keyboard access. By comparison, the key sniffer provides low
level keyboard access.
Key sniffers are provided to allow libraries to provide non-windowed user
interaction. For example, the MUI library uses a key sniffer to do pop-up
text entry.
inKey is the character pressed, inRefCon is a value you supply during
registration. Return 1 to pass the key on to the next sniffer, the window
mgr, x-plane, or whomever is down stream. Return 0 to consume the key.
Warning: this API declares virtual keys as a signed character; however the
VKEY #define macros in XPLMDefs.h define the vkeys using unsigned values
(that is 0x80 instead of -0x80). So you may need to cast the incoming vkey
to an unsigned char to get correct comparisons in C.
}
XPLMKeySniffer_f = FUNCTION(
inChar : char;
inFlags : XPLMKeyFlags;
inVirtualKey : char;
inRefcon : pointer) : integer; cdecl;
{
XPLMRegisterDrawCallback
This routine registers a low level drawing callback. Pass in the phase you
want to be called for and whether you want to be called before or after.
This routine returns 1 if the registration was successful, or 0 if the
phase does not exist in this version of x-plane. You may register a
callback multiple times for the same or different phases as long as the
refcon is unique each time.
}
FUNCTION XPLMRegisterDrawCallback(
inCallback : XPLMDrawCallback_f;
inPhase : XPLMDrawingPhase;
inWantsBefore : integer;
inRefcon : pointer) : integer;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMUnregisterDrawCallback
This routine unregisters a draw callback. You must unregister a callback
for each time you register a callback if you have registered it multiple
times with different refcons. The routine returns 1 if it can find the
callback to unregister, 0 otherwise.
}
FUNCTION XPLMUnregisterDrawCallback(
inCallback : XPLMDrawCallback_f;
inPhase : XPLMDrawingPhase;
inWantsBefore : integer;
inRefcon : pointer) : integer;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMRegisterKeySniffer
This routine registers a key sniffing callback. You specify whether you
want to sniff before the window system, or only sniff keys the window
system does not consume. You should ALMOST ALWAYS sniff non-control keys
after the window system. When the window system consumes a key, it is
because the user has "focused" a window. Consuming the key or taking
action based on the key will produce very weird results. Returns 1 if
successful.
}
FUNCTION XPLMRegisterKeySniffer(
inCallback : XPLMKeySniffer_f;
inBeforeWindows : integer;
inRefcon : pointer) : integer;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMUnregisterKeySniffer
This routine unregisters a key sniffer. You must unregister a key sniffer
for every time you register one with the exact same signature. Returns 1
if successful.
}
FUNCTION XPLMUnregisterKeySniffer(
inCallback : XPLMKeySniffer_f;
inBeforeWindows : integer;
inRefcon : pointer) : integer;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{___________________________________________________________________________
* WINDOW API
___________________________________________________________________________}
{
Window API, for higher level drawing with UI interaction.
Note: all 2-d (and thus all window drawing) is done in 'cockpit pixels'.
Even when the OpenGL window contains more than 1024x768 pixels, the cockpit
drawing is magnified so that only 1024x768 pixels are available.
}
{
XPLMMouseStatus
When the mouse is clicked, your mouse click routine is called repeatedly.
It is first called with the mouse down message. It is then called zero or
more times with the mouse-drag message, and finally it is called once with
the mouse up message. All of these messages will be directed to the same
window.
}
TYPE
XPLMMouseStatus = (
xplm_MouseDown = 1
,xplm_MouseDrag = 2
,xplm_MouseUp = 3
);
PXPLMMouseStatus = ^XPLMMouseStatus;
{$IFDEF XPLM200}
{
XPLMCursorStatus
XPLMCursorStatus describes how you would like X-Plane to manage the cursor.
See XPLMHandleCursor_f for more info.
}
XPLMCursorStatus = (
{ X-Plane manages the cursor normally, plugin does not affect the cusrsor. }
xplm_CursorDefault = 0
{ X-Plane hides the cursor. }
,xplm_CursorHidden = 1
{ X-Plane shows the cursor as the default arrow. }
,xplm_CursorArrow = 2
{ X-Plane shows the cursor but lets you select an OS cursor. }
,xplm_CursorCustom = 3
);
PXPLMCursorStatus = ^XPLMCursorStatus;
{$ENDIF}
{
XPLMWindowID
This is an opaque identifier for a window. You use it to control your
window. When you create a window, you will specify callbacks to handle
drawing and mouse interaction, etc.
}
XPLMWindowID = pointer;
PXPLMWindowID = ^XPLMWindowID;
{
XPLMDrawWindow_f
This function handles drawing. You are passed in your window and its
refcon. Draw the window. You can use XPLM functions to find the current
dimensions of your window, etc. When this callback is called, the OpenGL
context will be set properly for cockpit drawing. NOTE: Because you are
drawing your window over a background, you can make a translucent window
easily by simply not filling in your entire window's bounds.
}
XPLMDrawWindow_f = PROCEDURE(
inWindowID : XPLMWindowID;
inRefcon : pointer); cdecl;
{
XPLMHandleKey_f
This function is called when a key is pressed or keyboard focus is taken
away from your window. If losingFocus is 1, you are losign the keyboard
focus, otherwise a key was pressed and inKey contains its character. You
are also passewd your window and a refcon. Warning: this API declares
virtual keys as a signed character; however the VKEY #define macros in
XPLMDefs.h define the vkeys using unsigned values (that is 0x80 instead of
-0x80). So you may need to cast the incoming vkey to an unsigned char to
get correct comparisons in C.
}
XPLMHandleKey_f = PROCEDURE(
inWindowID : XPLMWindowID;
inKey : char;
inFlags : XPLMKeyFlags;
inVirtualKey : char;
inRefcon : pointer;
losingFocus : integer); cdecl;
{
XPLMHandleMouseClick_f
You receive this call when the mouse button is pressed down or released.
Between then these two calls is a drag. You receive the x and y of the
click, your window, and a refcon. Return 1 to consume the click, or 0 to
pass it through.
WARNING: passing clicks through windows (as of this writing) causes mouse
tracking problems in X-Plane; do not use this feature!
}
XPLMHandleMouseClick_f = FUNCTION(
inWindowID : XPLMWindowID;
x : integer;
y : integer;
inMouse : XPLMMouseStatus;
inRefcon : pointer) : integer; cdecl;
{$IFDEF XPLM200}
{
XPLMHandleCursor_f
The SDK calls your cursor status callback when the mouse is over your
plugin window. Return a cursor status code to indicate how you would like
X-Plane to manage the cursor. If you return xplm_CursorDefault, the SDK
will try lower-Z-order plugin windows, then let the sim manage the cursor.
Note: you should never show or hide the cursor yourself - these APIs are
typically reference-counted and thus cannot safely and predictably be used
by the SDK. Instead return one of xplm_CursorHidden to hide the cursor or
xplm_CursorArrow/xplm_CursorCustom to show the cursor.
If you want to implement a custom cursor by drawing a cursor in OpenGL, use
xplm_CursorHidden to hide the OS cursor and draw the cursor using a 2-d
drawing callback (after xplm_Phase_Window is probably a good choice). If
you want to use a custom OS-based cursor, use xplm_CursorCustom to ask
X-Plane to show the cursor but not affect its image. You can then use an
OS specific call like SetThemeCursor (Mac) or SetCursor/LoadCursor
(Windows).
}
XPLMHandleCursor_f = FUNCTION(
inWindowID : XPLMWindowID;
x : integer;
y : integer;
inRefcon : pointer) : XPLMCursorStatus; cdecl;
{$ENDIF}
{$IFDEF XPLM200}
{
XPLMHandleMouseWheel_f
The SDK calls your mouse wheel callback when one of the mouse wheels is
turned within your window. Return 1 to consume the mouse wheel clicks or
0 to pass them on to a lower window. (You should consume mouse wheel
clicks even if they do nothing if your window appears opaque to the user.)
The number of clicks indicates how far the wheel was turned since the last
callback. The wheel is 0 for the vertical axis or 1 for the horizontal axis
(for OS/mouse combinations that support this).
}
XPLMHandleMouseWheel_f = FUNCTION(
inWindowID : XPLMWindowID;
x : integer;
y : integer;
wheel : integer;
clicks : integer;
inRefcon : pointer) : integer; cdecl;
{$ENDIF}
{$IFDEF XPLM200}
{
XPLMCreateWindow_t
The XPMCreateWindow_t structure defines all of the parameters used to
create a window using XPLMCreateWindowEx. The structure will be expanded
in future SDK APIs to include more features. Always set the structSize
member to the size of your struct in bytes!
}
XPLMCreateWindow_t = RECORD
structSize : integer;
left : integer;
top : integer;
right : integer;
bottom : integer;
visible : integer;
drawWindowFunc : XPLMDrawWindow_f;
handleMouseClickFunc : XPLMHandleMouseClick_f;
handleKeyFunc : XPLMHandleKey_f;
handleCursorFunc : XPLMHandleCursor_f;
handleMouseWheelFunc : XPLMHandleMouseWheel_f;
refcon : pointer;
END;
PXPLMCreateWindow_t = ^XPLMCreateWindow_t;
{$ENDIF}
{
XPLMGetScreenSize
This routine returns the size of the size of the X-Plane OpenGL window in
pixels. Please note that this is not the size of the screen when doing
2-d drawing (the 2-d screen is currently always 1024x768, and graphics are
scaled up by OpenGL when doing 2-d drawing for higher-res monitors). This
number can be used to get a rough idea of the amount of detail the user
will be able to see when drawing in 3-d.
}
PROCEDURE XPLMGetScreenSize(
outWidth : Pinteger; { Can be nil }
outHeight : Pinteger); { Can be nil }
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMGetMouseLocation
This routine returns the current mouse location in cockpit pixels. The
bottom left corner of the display is 0,0. Pass NULL to not receive info
about either parameter.
}
PROCEDURE XPLMGetMouseLocation(
outX : Pinteger; { Can be nil }
outY : Pinteger); { Can be nil }
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMCreateWindow
This routine creates a new window. Pass in the dimensions and offsets to
the window's bottom left corner from the bottom left of the screen. You
can specify whether the window is initially visible or not. Also, you pass
in three callbacks to run the window and a refcon. This function returns a
window ID you can use to refer to the new window.
NOTE: windows do not have "frames"; you are responsible for drawing the
background and frame of the window. Higher level libraries have routines
which make this easy.
}
FUNCTION XPLMCreateWindow(
inLeft : integer;
inTop : integer;
inRight : integer;
inBottom : integer;
inIsVisible : integer;
inDrawCallback : XPLMDrawWindow_f;
inKeyCallback : XPLMHandleKey_f;
inMouseCallback : XPLMHandleMouseClick_f;
inRefcon : pointer) : XPLMWindowID;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{$IFDEF XPLM200}
{
XPLMCreateWindowEx
This routine creates a new window - you pass in an XPLMCreateWindow_t
structure with all of the fields set in. You must set the structSize of
the structure to the size of the actual structure you used. Also, you
must provide funtions for every callback - you may not leave them null!
(If you do not support the cursor or mouse wheel, use functions that return
the default values.) The numeric values of the XPMCreateWindow_t structure
correspond to the parameters of XPLMCreateWindow.
}
FUNCTION XPLMCreateWindowEx(
inParams : PXPLMCreateWindow_t) : XPLMWindowID;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{$ENDIF}
{
XPLMDestroyWindow
This routine destroys a window. The callbacks are not called after this
call. Keyboard focus is removed from the window before destroying it.
}
PROCEDURE XPLMDestroyWindow(
inWindowID : XPLMWindowID);
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMGetWindowGeometry
This routine returns the position and size of a window in cockpit pixels.
Pass NULL to not receive any paramter.
}
PROCEDURE XPLMGetWindowGeometry(
inWindowID : XPLMWindowID;
outLeft : Pinteger; { Can be nil }
outTop : Pinteger; { Can be nil }
outRight : Pinteger; { Can be nil }
outBottom : Pinteger); { Can be nil }
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMSetWindowGeometry
This routine allows you to set the position or height aspects of a window.
}
PROCEDURE XPLMSetWindowGeometry(
inWindowID : XPLMWindowID;
inLeft : integer;
inTop : integer;
inRight : integer;
inBottom : integer);
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMGetWindowIsVisible
This routine returns whether a window is visible.
}
FUNCTION XPLMGetWindowIsVisible(
inWindowID : XPLMWindowID) : integer;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMSetWindowIsVisible
This routine shows or hides a window.
}
PROCEDURE XPLMSetWindowIsVisible(
inWindowID : XPLMWindowID;
inIsVisible : integer);
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMGetWindowRefCon
This routine returns a windows refcon, the unique value you can use for
your own purposes.
}
FUNCTION XPLMGetWindowRefCon(
inWindowID : XPLMWindowID) : pointer;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMSetWindowRefCon
This routine sets a window's reference constant. Use this to pass data to
yourself in the callbacks.
}
PROCEDURE XPLMSetWindowRefCon(
inWindowID : XPLMWindowID;
inRefcon : pointer);
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMTakeKeyboardFocus
This routine gives a specific window keyboard focus. Keystrokes will be
sent to that window. Pass a window ID of 0 to pass keyboard strokes
directly to X-Plane.
}
PROCEDURE XPLMTakeKeyboardFocus(
inWindow : XPLMWindowID);
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMBringWindowToFront
This routine brings the window to the front of the Z-order. Windows are
brought to the front when they are created...beyond that you should make
sure you are front before handling mouse clicks.
}
PROCEDURE XPLMBringWindowToFront(
inWindow : XPLMWindowID);
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMIsWindowInFront
This routine returns true if you pass inthe ID of the frontmost visible
window.
}
FUNCTION XPLMIsWindowInFront(
inWindow : XPLMWindowID) : integer;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{___________________________________________________________________________
* HOT KEYS
___________________________________________________________________________}
{
Hot Keys - keystrokes that can be managed by others.
}
{
XPLMHotKey_f
Your hot key callback simply takes a pointer of your choosing.
}
TYPE
XPLMHotKey_f = PROCEDURE(
inRefcon : pointer); cdecl;
{
XPLMHotKeyID
Hot keys are identified by opaque IDs.
}
XPLMHotKeyID = pointer;
PXPLMHotKeyID = ^XPLMHotKeyID;
{
XPLMRegisterHotKey
This routine registers a hot key. You specify your preferred key stroke
virtual key/flag combination, a description of what your callback does (so
other plug-ins can describe the plug-in to the user for remapping) and a
callback function and opaque pointer to pass in). A new hot key ID is
returned. During execution, the actual key associated with your hot key
may change, but you are insulated from this.
}
FUNCTION XPLMRegisterHotKey(
inVirtualKey : char;
inFlags : XPLMKeyFlags;
inDescription : Pchar;
inCallback : XPLMHotKey_f;
inRefcon : pointer) : XPLMHotKeyID;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMUnregisterHotKey
This API unregisters a hot key. You can only register your own hot keys.
}
PROCEDURE XPLMUnregisterHotKey(
inHotKey : XPLMHotKeyID);
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMCountHotKeys
Returns the number of current hot keys.
}
FUNCTION XPLMCountHotKeys: longint;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMGetNthHotKey
Returns a hot key by index, for iteration on all hot keys.
}
FUNCTION XPLMGetNthHotKey(
inIndex : longint) : XPLMHotKeyID;
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMGetHotKeyInfo
Returns information about the hot key. Return NULL for any parameter you
don't want info about. The description should be at least 512 chars long.
}
PROCEDURE XPLMGetHotKeyInfo(
inHotKey : XPLMHotKeyID;
outVirtualKey : Pchar; { Can be nil }
outFlags : PXPLMKeyFlags; { Can be nil }
outDescription : Pchar; { Can be nil }
outPlugin : PXPLMPluginID); { Can be nil }
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
{
XPLMSetHotKeyCombination
XPLMSetHotKeyCombination remaps a hot keys keystrokes. You may remap
another plugin's keystrokes.
}
PROCEDURE XPLMSetHotKeyCombination(
inHotKey : XPLMHotKeyID;
inVirtualKey : char;
inFlags : XPLMKeyFlags);
{$IFDEF DELPHI}
cdecl; external 'XPLM.DLL';
{$ELSE}
cdecl; external '';
{$ENDIF}
IMPLEMENTATION
END.
| 42.813397 | 102 | 0.518859 |
fcb45610b1380c67b45cb71c6034ec4240b325f9 | 6,740 | pas | Pascal | Source/Z.MD5.pas | PassByYou888/ZNet | 8f5439ec275ee4eb5d68e00c33675e6117379fcf | [
"BSD-3-Clause"
]
| 24 | 2022-01-20T13:59:38.000Z | 2022-03-25T01:11:43.000Z | Source/Z.MD5.pas | lovong/ZNet | ad67382654ea1979c316c2dc9716fd6d8509f028 | [
"BSD-3-Clause"
]
| null | null | null | Source/Z.MD5.pas | lovong/ZNet | ad67382654ea1979c316c2dc9716fd6d8509f028 | [
"BSD-3-Clause"
]
| 5 | 2022-01-20T14:44:24.000Z | 2022-02-13T10:07:38.000Z | { ****************************************************************************** }
{ * Fast md5 imp * }
{ ****************************************************************************** }
unit Z.MD5;
{$I Z.Define.inc}
interface
uses Z.Core, Z.UnicodeMixedLib;
{$IF Defined(MSWINDOWS) and Defined(Delphi)}
procedure MD5_Transform(var Accu; const Buf);
{$ENDIF Defined(MSWINDOWS) and Defined(Delphi)}
function FastMD5(const buffPtr: PByte; bufSiz: nativeUInt): TMD5; overload;
function FastMD5(stream: TCore_Stream; StartPos, EndPos: Int64): TMD5; overload;
implementation
{$IF Defined(MSWINDOWS) and Defined(Delphi)}
uses Z.MemoryStream;
(*
fastMD5 algorithm by Maxim Masiutin
https://github.com/maximmasiutin/MD5_Transform-x64
delphi imp by 600585@qq.com
https://github.com/PassByYou888/FastMD5
*)
{$IF Defined(WIN32)}
(*
; ==============================================================
;
; MD5_386.Asm - 386 optimized helper routine for calculating
; MD Message-Digest values
; written 2/2/94 by
;
; Peter Sawatzki
; Buchenhof 3
; D58091 Hagen, Germany Fed Rep
;
; EMail: Peter@Sawatzki.de
; EMail: 100031.3002@compuserve.com
; WWW: http://www.sawatzki.de
;
;
; original C Source was found in Dr. Dobbs Journal Sep 91
; MD5 algorithm from RSA Data Security, Inc.
*)
{$L Z.MD5_32.obj}
{$ELSEIF Defined(WIN64)}
(*
; MD5_Transform-x64
; MD5 transform routine oprimized for x64 processors
; Copyright 2018 Ritlabs, SRL
; The 64-bit version is written by Maxim Masiutin <max@ritlabs.com>
; The main advantage of this 64-bit version is that
; it loads 64 bytes of hashed message into 8 64-bit registers
; (RBP, R8, R9, R10, R11, R12, R13, R14) at the beginning,
; to avoid excessive memory load operations
; througout the routine.
; To operate with 32-bit values store in higher bits
; of a 64-bit register (bits 32-63) uses "Ror" by 32;
; 8 macro variables (M1-M8) are used to keep record
; or corrent state of whether the register has been
; Ror'ed or not.
; It also has an ability to use Lea instruction instead
; of two sequental Adds (uncomment UseLea=1), but it is
; slower on Skylake processors. Also, Intel in the
; Optimization Reference Maual discourages us of
; Lea as a replacement of two adds, since it is slower
; on the Atom processors.
; MD5_Transform-x64 is released under a dual license,
; and you may choose to use it under either the
; Mozilla Public License 2.0 (MPL 2.1, available from
; https://www.mozilla.org/en-US/MPL/2.0/) or the
; GNU Lesser General Public License Version 3,
; dated 29 June 2007 (LGPL 3, available from
; https://www.gnu.org/licenses/lgpl.html).
; MD5_Transform-x64 is based
; on the following code by Peter Sawatzki.
; The original notice by Peter Sawatzki follows.
*)
{$L Z.MD5_64.obj}
{$ENDIF}
procedure MD5_Transform(var Accu; const Buf); register; external;
function FastMD5(const buffPtr: PByte; bufSiz: nativeUInt): TMD5;
var
Digest: TMD5;
Lo, Hi: Cardinal;
p: PByte;
ChunkIndex: Byte;
ChunkBuff: array [0 .. 63] of Byte;
begin
Lo := 0;
Hi := 0;
PCardinal(@Digest[0])^ := $67452301;
PCardinal(@Digest[4])^ := $EFCDAB89;
PCardinal(@Digest[8])^ := $98BADCFE;
PCardinal(@Digest[12])^ := $10325476;
inc(Lo, bufSiz shl 3);
inc(Hi, bufSiz shr 29);
p := buffPtr;
while bufSiz >= $40 do
begin
MD5_Transform(Digest, p^);
inc(p, $40);
dec(bufSiz, $40);
end;
if bufSiz > 0 then
CopyPtr(p, @ChunkBuff[0], bufSiz);
Result := PMD5(@Digest[0])^;
ChunkBuff[bufSiz] := $80;
ChunkIndex := bufSiz + 1;
if ChunkIndex > $38 then
begin
if ChunkIndex < $40 then
FillPtrByte(@ChunkBuff[ChunkIndex], $40 - ChunkIndex, 0);
MD5_Transform(Result, ChunkBuff);
ChunkIndex := 0
end;
FillPtrByte(@ChunkBuff[ChunkIndex], $38 - ChunkIndex, 0);
PCardinal(@ChunkBuff[$38])^ := Lo;
PCardinal(@ChunkBuff[$3C])^ := Hi;
MD5_Transform(Result, ChunkBuff);
end;
function FastMD5(stream: TCore_Stream; StartPos, EndPos: Int64): TMD5;
const
deltaSize: Cardinal = $40 * $FFFF;
var
Digest: TMD5;
Lo, Hi: Cardinal;
DeltaBuf: Pointer;
bufSiz: Int64;
Rest: Cardinal;
p: PByte;
ChunkIndex: Byte;
ChunkBuff: array [0 .. 63] of Byte;
begin
if StartPos > EndPos then
Swap(StartPos, EndPos);
StartPos := umlClamp(StartPos, 0, stream.Size);
EndPos := umlClamp(EndPos, 0, stream.Size);
if EndPos - StartPos <= 0 then
begin
Result := FastMD5(nil, 0);
exit;
end;
{$IFDEF OptimizationMemoryStreamMD5}
if stream is TCore_MemoryStream then
begin
Result := FastMD5(Pointer(nativeUInt(TCore_MemoryStream(stream).Memory) + StartPos), EndPos - StartPos);
exit;
end;
if stream is TMS64 then
begin
Result := FastMD5(TMS64(stream).PositionAsPtr(StartPos), EndPos - StartPos);
exit;
end;
{$ENDIF}
//
Lo := 0;
Hi := 0;
PCardinal(@Digest[0])^ := $67452301;
PCardinal(@Digest[4])^ := $EFCDAB89;
PCardinal(@Digest[8])^ := $98BADCFE;
PCardinal(@Digest[12])^ := $10325476;
bufSiz := EndPos - StartPos;
Rest := 0;
inc(Lo, bufSiz shl 3);
inc(Hi, bufSiz shr 29);
DeltaBuf := GetMemory(deltaSize);
stream.Position := StartPos;
if bufSiz < $40 then
begin
stream.read(DeltaBuf^, bufSiz);
p := DeltaBuf;
end
else
while bufSiz >= $40 do
begin
if Rest = 0 then
begin
if bufSiz >= deltaSize then
Rest := deltaSize
else
Rest := bufSiz;
stream.ReadBuffer(DeltaBuf^, Rest);
p := DeltaBuf;
end;
MD5_Transform(Digest, p^);
inc(p, $40);
dec(bufSiz, $40);
dec(Rest, $40);
end;
if bufSiz > 0 then
CopyPtr(p, @ChunkBuff[0], bufSiz);
FreeMemory(DeltaBuf);
Result := PMD5(@Digest[0])^;
ChunkBuff[bufSiz] := $80;
ChunkIndex := bufSiz + 1;
if ChunkIndex > $38 then
begin
if ChunkIndex < $40 then
FillPtrByte(@ChunkBuff[ChunkIndex], $40 - ChunkIndex, 0);
MD5_Transform(Result, ChunkBuff);
ChunkIndex := 0
end;
FillPtrByte(@ChunkBuff[ChunkIndex], $38 - ChunkIndex, 0);
PCardinal(@ChunkBuff[$38])^ := Lo;
PCardinal(@ChunkBuff[$3C])^ := Hi;
MD5_Transform(Result, ChunkBuff);
end;
{$ELSE}
function FastMD5(const buffPtr: PByte; bufSiz: nativeUInt): TMD5;
begin
Result := umlMD5(buffPtr, bufSiz);
end;
function FastMD5(stream: TCore_Stream; StartPos, EndPos: Int64): TMD5;
begin
Result := umlStreamMD5(stream, StartPos, EndPos);
end;
{$ENDIF Defined(MSWINDOWS) and Defined(Delphi)}
end.
| 26.124031 | 110 | 0.624332 |
838ed972a38663cb7709f9d3546f8dc242b2e672 | 1,027 | pas | Pascal | unittests/BusinnessObjects.pas | raelb/delphi-orm | 73e0caede84f2753550492deeaad35bf4191be30 | [
"Apache-2.0"
]
| 156 | 2015-05-28T19:14:20.000Z | 2022-03-18T05:34:41.000Z | unittests/BusinnessObjects.pas | raelb/delphi-orm | 73e0caede84f2753550492deeaad35bf4191be30 | [
"Apache-2.0"
]
| 10 | 2015-05-31T09:19:41.000Z | 2021-09-27T14:34:31.000Z | unittests/BusinnessObjects.pas | raelb/delphi-orm | 73e0caede84f2753550492deeaad35bf4191be30 | [
"Apache-2.0"
]
| 70 | 2015-06-20T17:34:17.000Z | 2022-03-03T10:05:31.000Z | unit BusinnessObjects;
interface
type
TViewPeopleSummary = class(TObject)
//fields
Id: Integer;
FirstName: String;
LastName: String;
Age: Integer;
BornDate: TDate;
BornDateTime: TDateTime;
Photo: TStream;
EmailsCount: Integer;
end;
TEmail = class(TObject)
//primary key
Id: Integer;
//fields
Address: String;
IdPerson: Integer;
end;
TPeople = class(TObject)
//primary key
Id: Integer;
//fields
FirstName: String;
LastName: String;
Age: Integer;
BornDate: TDate;
BornDateTime: TDateTime;
Photo: TStream;
end;
TPhone = class(TObject)
//primary key
Id: Integer;
//fields
Number: String;
Model: String;
IdPerson: Integer;
end;
TCar = class(TObject)
//primary key
Id: Integer;
//fields
Brand: String;
Model: String;
IdPerson: Integer;
end;
implementation
initialization
finalization
end.
| 16.046875 | 38 | 0.582278 |
c34696e102d53a029e48dc0f48ffec5eeeac1c88 | 184 | dpr | Pascal | Grafika Komputer/Modul8/ProjectBola.dpr | r2itech/Project-Delphi7 | 293fa9579cd896e3a03b1669ca323b0af5a16717 | [
"Apache-2.0"
]
| null | null | null | Grafika Komputer/Modul8/ProjectBola.dpr | r2itech/Project-Delphi7 | 293fa9579cd896e3a03b1669ca323b0af5a16717 | [
"Apache-2.0"
]
| null | null | null | Grafika Komputer/Modul8/ProjectBola.dpr | r2itech/Project-Delphi7 | 293fa9579cd896e3a03b1669ca323b0af5a16717 | [
"Apache-2.0"
]
| null | null | null | program ProjectBola;
uses
Forms,
unitBola in 'unitBola.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
| 13.142857 | 40 | 0.717391 |
47826974003c8f6fe0281c8084b073b44a604e85 | 508 | dfm | Pascal | examples/Delphi/Compound/Locking/LockManagerAdminClient/dmLockManagerAdmin.dfm | LenakeTech/BoldForDelphi | 3ef25517d5c92ebccc097c6bc2f2af62fc506c71 | [
"MIT"
]
| 121 | 2020-09-22T10:46:20.000Z | 2021-11-17T12:33:35.000Z | examples/Delphi/Compound/Locking/LockManagerAdminClient/dmLockManagerAdmin.dfm | LenakeTech/BoldForDelphi | 3ef25517d5c92ebccc097c6bc2f2af62fc506c71 | [
"MIT"
]
| 8 | 2020-09-23T12:32:23.000Z | 2021-07-28T07:01:26.000Z | examples/Delphi/Compound/Locking/LockManagerAdminClient/dmLockManagerAdmin.dfm | LenakeTech/BoldForDelphi | 3ef25517d5c92ebccc097c6bc2f2af62fc506c71 | [
"MIT"
]
| 42 | 2020-09-22T14:37:20.000Z | 2021-10-04T10:24:12.000Z | object dmMain: TdmMain
OldCreateOrder = False
Left = 180
Top = 136
Height = 480
Width = 696
object BoldComConnectionHandle1: TBoldComConnectionHandle
ServerCLSID = '{11C6E940-CEC6-45BA-873D-27854A82A023}'
ServerName = 'BoldPropagator.EnterprisePropagator.PropagatorConnection'
Left = 136
Top = 64
end
object BoldLockManagerAdminHandleCom1: TBoldLockManagerAdminHandleCom
ConnectionHandle = BoldComConnectionHandle1
Active = False
Left = 320
Top = 64
end
end
| 25.4 | 75 | 0.746063 |
fca0849a9f2c56d2933d645349aa83dcd78f4c0e | 1,800 | pas | Pascal | ac2000/Stat/QOBJTYPER.pas | aspenryd/Car | 1d812ab60825f0900ac161638e0d375894997204 | [
"MIT"
]
| 1 | 2018-07-22T13:13:16.000Z | 2018-07-22T13:13:16.000Z | ac2000/Stat/QOBJTYPER.pas | aspenryd/Car | 1d812ab60825f0900ac161638e0d375894997204 | [
"MIT"
]
| null | null | null | ac2000/Stat/QOBJTYPER.pas | aspenryd/Car | 1d812ab60825f0900ac161638e0d375894997204 | [
"MIT"
]
| 2 | 2018-03-29T13:57:55.000Z | 2018-07-22T13:13:18.000Z | {
==========================================================
=== (c) CopyRight 2003 ; All rights reserved ===
==========================================================
Filename
Stat\QObjTyper.pas
}
{ $HDR$}
{**********************************************************************}
{ Unit archived using Team Coherence }
{ Team Coherence is Copyright 2002 by Quality Software Components }
{ }
{ For further information / comments, visit our WEB site at }
{ http://www.TeamCoherence.com }
{**********************************************************************}
{}
{ $Log: 13031: QOBJTYPER.pas
{
{ Rev 1.0 2003-03-20 13:59:34 peter
}
{
{ Rev 1.0 2003-03-17 14:39:46 Supervisor
{ Nystart
}
{
{ Rev 1.0 2003-03-17 14:35:08 Supervisor
{ Nystart
}
{
{ Rev 1.0 2003-03-17 14:28:08 Supervisor
{ Bytt ut LMD och BFC Combo
}
unit QObjTyper;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
QuickRpt, Qrctrls, ExtCtrls;
type
TFrmQObjTyp = class(TForm)
QuickRep1: TQuickRep;
QRBand1: TQRBand;
QRlabel1: TQRLabel;
QRLabel2: TQRLabel;
QRFd: TQRLabel;
QRTd: TQRLabel;
QRobjtyp: TQRLabel;
QrAntalRet: TQRLabel;
QrTotInt: TQRLabel;
QRUtnGrad: TQRLabel;
QObjD: TQRLabel;
QLAntObj: TQRLabel;
QRUtn: TQRLabel;
QRBand2: TQRBand;
QRShape1: TQRShape;
QRDBText1: TQRDBText;
QRDBText2: TQRDBText;
QRDBText3: TQRDBText;
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmQObjTyp: TFrmQObjTyp;
implementation
uses Statistik, Bearb, Dmod;
{$R *.DFM}
end.
| 22.5 | 75 | 0.505556 |
c3df2813119326d0ea424ccd9d7ba594f03f90d8 | 66 | lpr | Pascal | Data/PassRc/MiniTest4.lpr | joecare99/Public | 9eee060fbdd32bab33cf65044602976ac83f4b83 | [
"MIT"
]
| 11 | 2017-06-17T05:13:45.000Z | 2021-07-11T13:18:48.000Z | Data/PassRc/MiniTest4.lpr | joecare99/Public | 9eee060fbdd32bab33cf65044602976ac83f4b83 | [
"MIT"
]
| 2 | 2019-03-05T12:52:40.000Z | 2021-12-03T12:34:26.000Z | Data/PassRc/MiniTest4.lpr | joecare99/Public | 9eee060fbdd32bab33cf65044602976ac83f4b83 | [
"MIT"
]
| 6 | 2017-09-07T09:10:09.000Z | 2022-02-19T20:19:58.000Z | const c:array(.0..1.) of byte = (1,2); begin write(c(.0.)); end.
| 33 | 65 | 0.545455 |
fcb4787b400f61f62db399c5e5e00219fdb83e56 | 3,775 | dfm | Pascal | Native/Delphi/Apps/64bit/ConvertDelphi6/Demo/IBMastApp DXE2/QryCust.dfm | jpluimers/bo.codeplex | 787ef3b5a8c6ced0a985361243c48a6c76f5d655 | [
"BSD-3-Clause"
]
| 5 | 2017-05-12T08:03:54.000Z | 2022-02-15T08:23:27.000Z | Native/Delphi/Apps/64bit/ConvertDelphi6/Demo/IBMastApp DXE2/QryCust.dfm | jpluimers/bo.codeplex | 787ef3b5a8c6ced0a985361243c48a6c76f5d655 | [
"BSD-3-Clause"
]
| null | null | null | Native/Delphi/Apps/64bit/ConvertDelphi6/Demo/IBMastApp DXE2/QryCust.dfm | jpluimers/bo.codeplex | 787ef3b5a8c6ced0a985361243c48a6c76f5d655 | [
"BSD-3-Clause"
]
| null | null | null | object QueryCustDlg: TQueryCustDlg
Left = 266
Top = 100
ActiveControl = FromEdit
BorderIcons = [biSystemMenu]
BorderStyle = bsDialog
Caption = 'Specify Date Range'
ClientHeight = 96
ClientWidth = 318
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
Position = poScreenCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Bevel1: TBevel
Left = 5
Top = 6
Width = 225
Height = 84
Shape = bsFrame
end
object Label1: TLabel
Left = 12
Top = 34
Width = 23
Height = 13
Caption = '&From'
FocusControl = FromEdit
end
object Label2: TLabel
Left = 12
Top = 63
Width = 13
Height = 13
Caption = '&To'
FocusControl = ToEdit
end
object Msglab: TLabel
Left = 12
Top = 11
Width = 197
Height = 16
AutoSize = False
Caption = 'Customers with LastInvoiceDate ranging:'
WordWrap = True
end
object PopupCalBtnFrom: TSpeedButton
Left = 197
Top = 31
Width = 21
Height = 21
Hint = 'Browse calendar'
Glyph.Data = {
4E010000424D4E01000000000000760000002800000012000000120000000100
040000000000D800000000000000000000001000000010000000000000000000
BF0000BF000000BFBF00BF000000BF00BF00BFBF0000C0C0C000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
3333330000003333333333333333330000003338888888888888330000003304
0404404040483300000033FFFFFFFFFFFF483300000033FFFFFFFFFFFF483300
000033FF000F0007FF483300000033FFF0FF7F70FF483300000033FFF0FFFFF0
FF483300000033FFF0FF0007FF483300000033FF00FF0FFFFF483300000033FF
F0FF0000FF483300000033FFFFFFFFFFFF483300000033FFFFFFFFFFFF483300
000033F7777777777F4833000000330000000000003333000000333333333333
333333000000333333333333333333000000}
Layout = blGlyphRight
ParentShowHint = False
ShowHint = True
OnClick = PopupCalBtnFromClick
end
object PopupCalToBtn: TSpeedButton
Left = 197
Top = 60
Width = 21
Height = 21
Hint = 'Browse calendar'
Glyph.Data = {
4E010000424D4E01000000000000760000002800000012000000120000000100
040000000000D800000000000000000000001000000010000000000000000000
BF0000BF000000BFBF00BF000000BF00BF00BFBF0000C0C0C000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
3333330000003333333333333333330000003338888888888888330000003304
0404404040483300000033FFFFFFFFFFFF483300000033FFFFFFFFFFFF483300
000033FF000F0007FF483300000033FFF0FF7F70FF483300000033FFF0FFFFF0
FF483300000033FFF0FF0007FF483300000033FF00FF0FFFFF483300000033FF
F0FF0000FF483300000033FFFFFFFFFFFF483300000033FFFFFFFFFFFF483300
000033F7777777777F4833000000330000000000003333000000333333333333
333333000000333333333333333333000000}
Layout = blGlyphRight
ParentShowHint = False
ShowHint = True
OnClick = PopupCalToBtnClick
end
object FromEdit: TEdit
Left = 46
Top = 31
Width = 147
Height = 21
TabOrder = 0
end
object ToEdit: TEdit
Left = 46
Top = 60
Width = 147
Height = 21
TabOrder = 1
end
object CancelBtn: TButton
Left = 240
Top = 34
Width = 70
Height = 25
Cancel = True
Caption = '&Cancel'
ModalResult = 2
TabOrder = 2
end
object OkBtn: TButton
Left = 240
Top = 6
Width = 70
Height = 25
Caption = '&OK'
Default = True
ModalResult = 1
TabOrder = 3
OnClick = OkBtnClick
end
end
| 27.962963 | 71 | 0.705166 |
c30f33bd11a7a697000bf0b12c799ca0ab23539a | 5,665 | pas | Pascal | Source/Unassigned/UMLPlugins/BoldAppEventsRestorer.pas | LenakeTech/BoldForDelphi | 3ef25517d5c92ebccc097c6bc2f2af62fc506c71 | [
"MIT"
]
| 121 | 2020-09-22T10:46:20.000Z | 2021-11-17T12:33:35.000Z | Source/Unassigned/UMLPlugins/BoldAppEventsRestorer.pas | LenakeTech/BoldForDelphi | 3ef25517d5c92ebccc097c6bc2f2af62fc506c71 | [
"MIT"
]
| 8 | 2020-09-23T12:32:23.000Z | 2021-07-28T07:01:26.000Z | Source/Unassigned/UMLPlugins/BoldAppEventsRestorer.pas | LenakeTech/BoldForDelphi | 3ef25517d5c92ebccc097c6bc2f2af62fc506c71 | [
"MIT"
]
| 42 | 2020-09-22T14:37:20.000Z | 2021-10-04T10:24:12.000Z | unit BoldAppEventsRestorer;
interface
uses
Graphics,
Classes,
ActnList,
Forms,
BoldUMLPlugins,
BoldUMLModelEditPlugIn;
type
{ forward declaration of classes }
TUMLAppEventsRestorer = class;
{ TUMLNameFixer }
TUMLAppEventsRestorer = class(TUMLPlugInFunction)
private
FOnActionExecute: TActionEvent;
FOnActionUpdate: TActionEvent;
FOnException: TExceptionEvent;
FOnMessage: TMessageEvent;
FOnHelp: THelpEvent;
FOnHint: TNotifyEvent;
FOnIdle: TIdleEvent;
FOnDeactivate: TNotifyEvent;
FOnActivate: TNotifyEvent;
FOnMinimize: TNotifyEvent;
FOnRestore: TNotifyEvent;
FOnShortCut: TShortCutEvent;
FOnShowHint: TShowHintEvent;
function GetComponentByClassName(const TheClassName: string): TComponent;
procedure SaveAppEvents;
procedure RestoreAppEvents;
protected
function GetMenuItemName: String; override;
function GetPlugInType: TPlugInType; override;
function GetImageResourceName: String; override;
function GetImageMaskColor: TColor; override;
public
procedure Execute(Context: IUMLModelPlugInContext); override;
end;
implementation
uses
SysUtils,
contnrs,
AppEvnts;
type
TMultiCasterShadow = class(TComponent)
private
FAppEvents: TComponentList;
end;
TComponentShadow = class(TPersistent)
private
FOwner: TComponent;
FName: TComponentName;
FTag: Longint;
FComponents: TList;
end;
var
_UMLAppEventsRestorer: TUMLAppEventsRestorer = nil;
{ TUMLNameFixer }
// Main method to invoke plug in functionality
procedure TUMLAppEventsRestorer.Execute(context: IUMLModelPlugInContext);
var
MultiCasterShadow: TMultiCasterShadow;
ComponentList: TComponentList;
ComponentShadow: TComponentShadow;
begin
SaveAppEvents;
// Get the MultiCaster and cast it into shape
MultiCasterShadow := TMultiCasterShadow(GetComponentByClassName('TMultiCaster'));
// Store the old list to application events
ComponentList := MultiCasterShadow.FAppEvents;
// Call constructor to rehook application events
MultiCasterShadow.Create(Application);
// Free the list created when Create was invoked.
MultiCasterShadow.FAppEvents.Free;
// Restore old list
MultiCasterShadow.FAppEvents := ComponentList;
// Now fix up the components list of Application
ComponentShadow := TComponentShadow(Application);
// ..by deleting the fake multicaster we just created...
ComponentShadow.FComponents.Delete(ComponentShadow.FComponents.Count - 1);
RestoreAppEvents;
end;
// Mask color for bitmap
function TUMLAppEventsRestorer.GetComponentByClassName(const TheClassName: string): TComponent;
var
i: integer;
begin
Result := nil;
for i := 0 to Application.ComponentCount - 1 do
if AnsiSameText(Application.Components[i].ClassName, TheClassName) then
begin
Result := Application.Components[i];
Break;
end;
end;
function TUMLAppEventsRestorer.GetImageMaskColor: TColor;
begin
Result := clTeal;
end;
// Resource for menu and button icon
function TUMLAppEventsRestorer.GetImageResourceName: String;
begin
result := 'AppEventsRestorer';
end;
// Caption for menu and hint for button
function TUMLAppEventsRestorer.GetMenuItemName: String;
begin
Result := 'AppEventsRestorer';
end;
// Type of tool
function TUMLAppEventsRestorer.GetPlugInType: TPlugInType;
begin
Result := ptTool;
end;
procedure TUMLAppEventsRestorer.RestoreAppEvents;
var
NewAppEvent: TApplicationEvents;
function EnsuredNewAppEvent: TApplicationEvents;
begin
if not Assigned(NewAppEvent) then
NewAppEvent := TApplicationEvents.Create(Application);
Result := NewAppEvent;
end;
begin
NewAppEvent := nil;
// if we changed onIdle then create a new application event
if @Application.OnIdle <> @fOnIdle then
EnsuredNewAppEvent.OnIdle := fOnIdle;
if @Application.OnActionExecute <> @fOnActionExecute then
EnsuredNewAppEvent.OnActionExecute := fOnActionExecute;
if @Application.OnActionUpdate <> @fOnActionUpdate then
EnsuredNewAppEvent.OnActionUpdate := fOnActionUpdate;
if @Application.OnActivate <> @fOnActivate then
EnsuredNewAppEvent.OnActivate := fOnActivate;
if @Application.OnDeactivate <> @fOnDeactivate then
EnsuredNewAppEvent.OnDeactivate := fOnDeactivate;
if @Application.OnException <> @fOnException then
EnsuredNewAppEvent.OnException := fOnException;
if @Application.OnHelp <> @fOnHelp then
EnsuredNewAppEvent.OnHelp := fOnHelp;
if @Application.OnHint <> @fOnHint then
EnsuredNewAppEvent.OnHint := fOnHint;
if @Application.OnMessage <> @fOnMessage then
EnsuredNewAppEvent.OnMessage := fOnMessage;
if @Application.OnMinimize <> @fOnMinimize then
EnsuredNewAppEvent.OnMinimize := fOnMinimize;
if @Application.OnRestore <> @fOnRestore then
EnsuredNewAppEvent.OnRestore := fOnRestore;
if @Application.OnShowHint <> @fOnShowHint then
EnsuredNewAppEvent.OnShowHint := fOnShowHint;
if @Application.OnShortCut <> @fOnShortCut then
EnsuredNewAppEvent.OnShortCut := fOnShortCut;
end;
procedure TUMLAppEventsRestorer.SaveAppEvents;
begin
with Application do
begin
fOnActionExecute := OnActionExecute;
fOnActionUpdate := OnActionUpdate;
fOnActivate := OnActivate;
fOnDeactivate := OnDeactivate;
fOnException := OnException;
fOnHelp := OnHelp;
fOnHint := OnHint;
fOnIdle := OnIdle;
fOnMessage := OnMessage;
fOnMinimize := OnMinimize;
fOnRestore := OnRestore;
fOnShowHint := OnShowHint;
fOnShortCut := OnShortCut;
end;
end;
initialization
_UMLAppEventsRestorer := TUMLAppEventsRestorer.Create(true);
finalization
FreeAndNil(_UMLAppEventsRestorer);
end.
| 27.105263 | 95 | 0.763636 |
fcac68454f916750b43d6e8510ca638970520b70 | 2,561 | dfm | Pascal | View.Main.dfm | leivio/DTello | 58b6ff7aa7bd4812ab4df83d077366447a78db98 | [
"MIT"
]
| 2 | 2020-07-11T13:46:53.000Z | 2021-06-04T02:06:33.000Z | View.Main.dfm | leivio/DTello | 58b6ff7aa7bd4812ab4df83d077366447a78db98 | [
"MIT"
]
| null | null | null | View.Main.dfm | leivio/DTello | 58b6ff7aa7bd4812ab4df83d077366447a78db98 | [
"MIT"
]
| null | null | null | object Form1: TForm1
Left = 0
Top = 0
Caption = 'DTello Control'
ClientHeight = 440
ClientWidth = 800
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object GroupBox1: TGroupBox
Left = 0
Top = 0
Width = 185
Height = 440
Align = alLeft
Caption = ' Control '
TabOrder = 0
object Button1: TButton
Left = 8
Top = 64
Width = 171
Height = 25
Caption = 'Sample Fly'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 8
Top = 27
Width = 171
Height = 25
Caption = 'Connect'
TabOrder = 1
OnClick = Button2Click
end
end
object GroupBox2: TGroupBox
Left = 185
Top = 0
Width = 615
Height = 440
Align = alClient
TabOrder = 1
object GroupBox3: TGroupBox
Left = 2
Top = 120
Width = 611
Height = 318
Align = alClient
TabOrder = 0
end
object GroupBox4: TGroupBox
Left = 2
Top = 15
Width = 611
Height = 105
Align = alTop
TabOrder = 1
object Label1: TLabel
Left = 8
Top = 16
Width = 44
Height = 13
Caption = 'Connect:'
end
object lblConnect: TLabel
Left = 58
Top = 16
Width = 64
Height = 13
Caption = 'Disconnected'
end
object Label2: TLabel
Left = 29
Top = 35
Width = 23
Height = 13
Caption = 'SDK:'
end
object lblSdk: TLabel
Left = 58
Top = 35
Width = 16
Height = 13
Caption = '0.0'
end
object Label3: TLabel
Left = 141
Top = 16
Width = 40
Height = 13
Caption = 'Battery:'
end
object lblBattery: TLabel
Left = 185
Top = 16
Width = 20
Height = 13
Caption = '0 %'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlue
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
end
end
object tmBattery: TTimer
Enabled = False
Interval = 10000
OnTimer = tmBatteryTimer
Left = 491
Top = 23
end
end
| 20.653226 | 39 | 0.497462 |
fc00e42939da23c50990e6ccfd79d22dfb7f93a1 | 50,817 | pas | Pascal | sources/MVCFramework.Serializer.Commons.pas | FinCodeur/delphimvcframework | a45cb1383eaffc9e81a836247643390acbb7b9b0 | [
"Apache-2.0"
]
| 2 | 2021-08-21T10:17:27.000Z | 2021-08-21T10:17:30.000Z | sources/MVCFramework.Serializer.Commons.pas | FinCodeur/delphimvcframework | a45cb1383eaffc9e81a836247643390acbb7b9b0 | [
"Apache-2.0"
]
| null | null | null | sources/MVCFramework.Serializer.Commons.pas | FinCodeur/delphimvcframework | a45cb1383eaffc9e81a836247643390acbb7b9b0 | [
"Apache-2.0"
]
| null | null | null | // ***************************************************************************
//
// Delphi MVC Framework
//
// Copyright (c) 2010-2021 Daniele Teti and the DMVCFramework Team
//
// https://github.com/danieleteti/delphimvcframework
//
// Collaborators on this file: Ezequiel Juliano Müller (ezequieljuliano@gmail.com)
//
// ***************************************************************************
//
// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ***************************************************************************
unit MVCFramework.Serializer.Commons;
{$I dmvcframework.inc}
{$WARN SYMBOL_DEPRECATED OFF}
interface
uses
System.Rtti,
System.Classes,
System.SysUtils,
System.DateUtils,
System.TypInfo,
{$IFDEF SYSTEMNETENCODING}
System.NetEncoding,
{$ELSE}
Soap.EncdDecd,
{$ENDIF}
MVCFramework.Commons,
Data.DB,
System.Generics.Collections,
JsonDataObjects;
type
EMVCSerializationException = class(EMVCException)
end;
EMVCDeserializationException = class(EMVCException)
end;
TMVCSerializationType = (stUnknown, stDefault, stProperties, stFields);
TMVCNameCase = (ncAsIs, ncUpperCase, ncLowerCase, ncCamelCase, ncPascalCase, ncSnakeCase);
TMVCDataType = (dtObject, dtArray);
TMVCDatasetSerializationType = (dstSingleRecord, dstAllRecords);
TMVCEnumSerializationType = (estEnumName, estEnumOrd, estEnumMappedValues);
TMVCIgnoredList = array of string;
TMVCSerializationAction<T: class> = reference to procedure(const AObject: T;
const Links: IMVCLinks);
TMVCSerializationAction = reference to procedure(const AObject: TObject; const Links: IMVCLinks);
TMVCDataSetSerializationAction = reference to procedure(const ADataSet: TDataset;
const Links: IMVCLinks);
TMVCDataSetFieldSerializationAction = reference to procedure(const AField: TField;
const AJsonObject: TJsonObject; var Handled: Boolean);
MVCValueAsTypeAttribute = class(TCustomAttribute)
private
FValueTypeInfo: PTypeInfo;
protected
{ protected declarations }
public
constructor Create(AValueTypeInfo: PTypeInfo);
function ValueTypeInfo: PTypeInfo;
end;
MVCDoNotSerializeAttribute = class(TCustomAttribute)
end;
MVCDoNotDeSerializeAttribute = class(TCustomAttribute)
end;
MVCSerializeAsStringAttribute = class(TCustomAttribute)
private
{ private declarations }
protected
{ protected declarations }
public
{ public declarations }
end;
MVCNameCaseAttribute = class(TCustomAttribute)
private
FKeyCase: TMVCNameCase;
function GetKeyCase: TMVCNameCase;
protected
{ protected declarations }
public
constructor Create(const AKeyCase: TMVCNameCase);
property KeyCase: TMVCNameCase read GetKeyCase;
end;
MapperJSONNaming = MVCNameCaseAttribute deprecated 'Use MVCNameCaseAttribute';
MVCNameAsAttribute = class(TCustomAttribute)
private
fName: string;
fFixed: Boolean;
protected
{ protected declarations }
public
constructor Create(const AName: string; const Fixed: Boolean = False);
property name: string read fName;
property Fixed: Boolean read fFixed;
end;
MapperJSONSer = MVCNameAsAttribute deprecated 'Use MVCNameAsAttribute';
MVCListOfAttribute = class(TCustomAttribute)
private
FValue: TClass;
protected
{ protected declarations }
public
constructor Create(const AValue: TClass);
property Value: TClass read FValue;
end;
MapperListOfAttribute = MVCListOfAttribute deprecated 'Use MVCListOfAttribute';
MVCDataSetFieldAttribute = class(TCustomAttribute)
private
FDataType: TMVCDataType;
protected
{ protected declarations }
public
constructor Create(const ADataType: TMVCDataType);
property DataType: TMVCDataType read FDataType;
end;
MVCSerializeAttribute = class(TCustomAttribute)
private
FSerializationType: TMVCSerializationType;
protected
{ protected declarations }
public
constructor Create(const ASerializationType: TMVCSerializationType);
property SerializationType: TMVCSerializationType read FSerializationType;
end;
MVCColumnAttribute = class(TCustomAttribute)
private
FFieldName: string;
FIsPK: Boolean;
procedure SetFieldName(const Value: string);
procedure SetIsPK(const Value: Boolean);
public
constructor Create(AFieldName: string; AIsPK: Boolean = False);
property FieldName: string read FFieldName write SetFieldName;
property IsPK: Boolean read FIsPK write SetIsPK;
end;
MVCEnumSerializationAttribute = class(TCustomAttribute)
private
FSerializationType: TMVCEnumSerializationType;
FMappedValues: TList<string>;
public
constructor Create(const ASerializationType: TMVCEnumSerializationType;
const AMappedValues: string = '');
destructor Destroy; override;
property SerializationType: TMVCEnumSerializationType read FSerializationType;
property MappedValues: TList<string> read FMappedValues;
end;
MVCOwnedAttribute = class(TCustomAttribute)
private
fClassRef: TClass;
public
constructor Create(const ClassRef: TClass = nil);
property ClassRef: TClass read fClassRef;
end;
TMVCSerializerHelper = record
private
{ private declarations }
public
class function ApplyNameCase(const NameCase: TMVCNameCase; const Value: string): string; static;
class function GetKeyName(const AField: TRttiField; const AType: TRttiType): string;
overload; static;
class function GetKeyName(const AProperty: TRttiProperty; const AType: TRttiType): string;
overload; static;
class function HasAttribute<T: class>(const AMember: TRttiObject): Boolean; overload; static;
class function HasAttribute<T: class>(const AMember: TRttiObject; out AAttribute: T): Boolean;
overload; static;
class function AttributeExists<T: TCustomAttribute>(const AAttributes: TArray<TCustomAttribute>;
out AAttribute: T): Boolean; overload; static;
class function AttributeExists<T: TCustomAttribute>(const AAttributes: TArray<TCustomAttribute>)
: Boolean; overload; static;
class procedure EncodeStream(AInput, AOutput: TStream); static;
class procedure DecodeStream(AInput, AOutput: TStream); static;
class function EncodeString(const AInput: string): string; static;
class function DecodeString(const AInput: string): string; static;
class procedure DeSerializeStringStream(AStream: TStream; const ASerializedString: string;
const AEncoding: string); static;
class procedure DeSerializeBase64StringStream(AStream: TStream;
const ABase64SerializedString: string); static;
class function GetTypeKindAsString(const ATypeKind: TTypeKind): string; static;
class function StringToTypeKind(const AValue: string): TTypeKind; static;
class function CreateObject(const AObjectType: TRttiType): TObject; overload; static;
class function CreateObject(const AQualifiedClassName: string): TObject; overload; static;
class function IsAPropertyToSkip(const aPropName: string): Boolean; static; inline;
end;
TMVCLinksCallback = reference to procedure(const Links: TMVCStringDictionary);
IMVCResponseData = interface
['{DF69BE0E-3212-4535-8B78-38EEF0F5B656}']
function GetMetadata: TMVCStringDictionary;
property MetaData: TMVCStringDictionary read GetMetadata;
function GetData: TObject;
property Data: TObject read GetData;
end;
// Well Known Response Objects
[MVCNameCase(ncLowerCase)]
TMVCResponseBase = class abstract(TInterfacedObject, IMVCResponseData)
protected
function GetMetadata: TMVCStringDictionary; virtual; abstract;
function GetData: TObject; virtual; abstract;
end;
[MVCNameCase(ncLowerCase)]
TMVCTask = class
private
fID: string;
fHREF: string;
public
property HREF: string read fHREF write fHREF;
property ID: string read fID write fID;
constructor Create(const HREF, ID: string);
end;
[MVCNameCase(ncLowerCase)]
TMVCAcceptedResponse = class(TMVCResponseBase)
private
fTask: TMVCTask;
public
property Task: TMVCTask read fTask;
// constructor Create(const aTask: TMVCTask); overload;
constructor Create(const HREF, ID: string);
destructor Destroy; override;
end;
[MVCNameCase(ncLowerCase)]
TMVCResponseData = class(TMVCResponseBase, IMVCResponseData)
private
fData: TObject;
fMetaData: TMVCStringDictionary;
fOwns: Boolean;
fDataSetSerializationType: TMVCDatasetSerializationType;
protected
function GetMetadata: TMVCStringDictionary; override;
function GetData: TObject; override;
public
constructor Create(const AObject: TObject; const AOwns: Boolean = False;
const ADataSetSerializationType: TMVCDatasetSerializationType = TMVCDatasetSerializationType.
dstAllRecords); virtual;
destructor Destroy; override;
function SerializationType: TMVCDatasetSerializationType;
[MVCNameAs('items')]
property Items: TObject read GetData;
[MVCNameAs('meta')]
property MetaData: TMVCStringDictionary read GetMetadata;
end deprecated 'Use "ObjectDict"';
TDataObjectHolder = TMVCResponseData deprecated 'Use "ObjectDict"';
THTTPStatusCode = 100 .. 599;
TMVCObjectListResponse = class(TMVCResponseData)
public
constructor Create(const AObject: TObject; Owns: Boolean = True); reintroduce;
end;
TMVCObjectResponse = class(TMVCResponseData)
public
constructor Create(const AObject: TObject; Owns: Boolean = True); reintroduce;
end;
IMVCObjectDictionary = interface
['{B54F02EE-4B3B-4E55-9E6B-FB6CFE746028}']
function Add(const Name: string; const Value: TObject;
const SerializationAction: TMVCSerializationAction = nil): IMVCObjectDictionary; overload;
function Add(const Name: string; const Value: TDataset;
const SerializationAction: TMVCDataSetSerializationAction = nil;
const DataSetSerializationType: TMVCDatasetSerializationType = dstAllRecords;
const NameCase: TMVCNameCase = TMVCNameCase.ncLowerCase): IMVCObjectDictionary; overload;
function TryGetValue(const Name: string; out Value: TObject): Boolean; overload;
function Count: Integer;
function ContainsKey(const Key: string): Boolean;
function Keys: TArray<string>;
end;
TMVCObjectDictionary = class(TInterfacedObject, IMVCObjectDictionary)
public
{
TMVCSerializationAction = reference to procedure(const AObject: TObject; const Links: IMVCLinks);
TMVCDataSetSerializationAction = reference to procedure(const ADataSet: TDataset; const Links: IMVCLinks);
}
type
TMVCObjectDictionaryValueItem = class
private
fOwns: Boolean;
fData: TObject;
fSerializationAction: TMVCSerializationAction;
fDataSetSerializationAction: TMVCDataSetSerializationAction;
fDataSetFieldNameCase: TMVCNameCase;
fDataSetSerializationType: TMVCDatasetSerializationType;
public
constructor Create(const Owns: Boolean; const Data: TObject;
const SerializationAction: TMVCSerializationAction); overload;
constructor Create(const Owns: Boolean; const Data: TDataset;
const SerializationAction: TMVCDataSetSerializationAction;
const DataSetSerializationType: TMVCDatasetSerializationType;
const NameCase: TMVCNameCase); overload;
destructor Destroy; override;
property Data: TObject read fData;
property SerializationAction: TMVCSerializationAction read fSerializationAction;
property DataSetSerializationAction: TMVCDataSetSerializationAction
read fDataSetSerializationAction;
property DataSetFieldNameCase: TMVCNameCase read fDataSetFieldNameCase;
property DataSetSerializationType: TMVCDatasetSerializationType
read fDataSetSerializationType;
end;
strict private
function GetItem(const Key: string): TMVCObjectDictionaryValueItem;
private
fOwnsValueItemData: Boolean;
protected
fDict: TObjectDictionary<string, TMVCObjectDictionaryValueItem>;
public
constructor Create(const OwnsValues: Boolean = True); overload; virtual;
constructor Create(const aKey: string; const Value: TObject; const OwnsValues: Boolean = True);
overload; virtual;
destructor Destroy; override;
procedure Clear;
function Add(const Name: string; const Value: TObject;
const SerializationAction: TMVCSerializationAction = nil): IMVCObjectDictionary; overload;
function Add(const Name: string; const Value: TDataset;
const SerializationAction: TMVCDataSetSerializationAction = nil;
const DataSetSerializationType: TMVCDatasetSerializationType = dstAllRecords;
const NameCase: TMVCNameCase = TMVCNameCase.ncLowerCase): IMVCObjectDictionary; overload;
function TryGetValue(const Name: string; out Value: TObject): Boolean; overload;
function Count: Integer;
function ContainsKey(const Key: string): Boolean;
function Keys: TArray<string>;
property Items[const Key: string]: TMVCObjectDictionaryValueItem read GetItem; default;
end;
var
/// <summary>
/// Use this variable when you want to convert your local time as UTC or when you receive an UTC ISOTimeStamp and
/// do not want to apply the time zone when converting.
/// The default value of gLocalTimeStampAsUTC = False.
/// </summary>
/// <example>
/// * For gLocalTimeStampAsUTC = False and timezone: - 03:00
/// ISOTimeStamp: 2021-01-11T14:22:17.763Z = DateTime: 2021-01-11 11:22:17.763
/// DateTime: 2021-01-11 14:22:17.763 = ISOTimeStamp: 2021-01-11T14:22:17.763-03:00
///
/// * For gLocalTimeStampAsUTC = True and timezone: - 03:00
/// ISOTimeStamp: 2021-01-11T14:22:17.763Z = DateTime: 2021-01-11 14:22:17
/// DateTime: 2021-01-11 14:22:17.763 = ISOTimeStamp: 2021-01-11T14:22:17.763Z
/// </example>
gLocalTimeStampAsUTC: Boolean;
function DateTimeToISOTimeStamp(const ADateTime: TDateTime): string;
function DateToISODate(const ADate: TDateTime): string;
function TimeToISOTime(const ATime: TTime): string;
procedure MapDataSetFieldToRTTIField(const AField: TField; const aRTTIField: TRttiField;
const AObject: TObject);
function MapDataSetFieldToNullableRTTIField(const AValue: TValue; const AField: TField;
const aRTTIField: TRttiField; const AObject: TObject): Boolean;
function MapDataSetFieldToNullableRTTIProperty(const AValue: TValue; const AField: TField;
const aRTTIProp: TRttiProperty; const AObject: TObject): Boolean;
/// <summary>
/// Supports ISO8601 in the following formats:
/// yyyy-mm-ddThh:nn:ss
/// yyyy-mm-ddThh:nn:ss.000Z
/// </summary>
function ISOTimeStampToDateTime(const ADateTime: string): TDateTime;
function ISODateToDate(const ADate: string): TDate;
function ISOTimeToTime(const ATime: string): TTime;
const
JSONNameLowerCase = ncLowerCase deprecated 'Use MVCNameCaseAttribute(ncLowerCase)';
JSONNameUpperCase = ncUpperCase deprecated 'Use MVCNameCaseAttribute(ncUpperCase)';
function StrDict: TMVCStringDictionary; overload;
function StrDict(const aKeys: array of string; const aValues: array of string)
: TMVCStringDictionary; overload;
function ObjectDict(const OwnsValues: Boolean = True): IMVCObjectDictionary;
function GetPaginationMeta(const CurrPageNumber: UInt32; const CurrPageSize: UInt32;
const DefaultPageSize: UInt32; const URITemplate: string): TMVCStringDictionary;
procedure RaiseSerializationError(const Msg: string);
implementation
uses
Data.FmtBcd,
MVCFramework.Nullables,
System.Generics.Defaults;
procedure RaiseSerializationError(const Msg: string);
begin
raise EMVCSerializationException.Create(Msg);
end;
function StrDict: TMVCStringDictionary; overload;
begin
Result := TMVCStringDictionary.Create;
end;
function GetPaginationMeta(const CurrPageNumber: UInt32; const CurrPageSize: UInt32;
const DefaultPageSize: UInt32; const URITemplate: string): TMVCStringDictionary;
var
lMetaKeys: array of string;
lMetaValues: array of string;
begin
Insert('curr_page', lMetaKeys, 0);
Insert(CurrPageNumber.ToString(), lMetaValues, 0);
if CurrPageNumber > 1 then
begin
Insert('prev_page_uri', lMetaKeys, 0);
Insert(Format(URITemplate, [(CurrPageNumber - 1)]), lMetaValues, 0);
end;
if CurrPageSize = DefaultPageSize then
begin
Insert('next_page_uri', lMetaKeys, 0);
Insert(Format(URITemplate, [(CurrPageNumber + 1)]), lMetaValues, 0);
end;
Result := StrDict(lMetaKeys, lMetaValues);
end;
function ObjectDict(const OwnsValues: Boolean): IMVCObjectDictionary;
begin
Result := TMVCObjectDictionary.Create(OwnsValues);
end;
function StrDict(const aKeys: array of string; const aValues: array of string)
: TMVCStringDictionary; overload;
var
I: Integer;
begin
if Length(aKeys) <> Length(aValues) then
begin
raise EMVCException.CreateFmt('Dict error. Got %d keys but %d values',
[Length(aKeys), Length(aValues)]);
end;
Result := StrDict();
for I := low(aKeys) to high(aKeys) do
begin
Result.Add(aKeys[I], aValues[I]);
end;
end;
function DateTimeToISOTimeStamp(const ADateTime: TDateTime): string;
begin
Result := DateToISO8601(ADateTime, gLocalTimeStampAsUTC);
end;
function DateToISODate(const ADate: TDateTime): string;
begin
Result := FormatDateTime('YYYY-MM-DD', ADate);
end;
function TimeToISOTime(const ATime: TTime): string;
var
fs: TFormatSettings;
begin
fs.TimeSeparator := ':';
Result := FormatDateTime('hh:nn:ss', ATime, fs);
end;
function ISOTimeStampToDateTime(const ADateTime: string): TDateTime;
var
lDateTime: string;
lIsUTC: Boolean;
begin
lDateTime := ADateTime;
if lDateTime.Length < 19 then
raise Exception.CreateFmt
('Invalid parameter "%s". Hint: DateTime parameters must be formatted in ISO8601 (e.g. 2010-10-12T10:12:23)',
[ADateTime]);
if lDateTime.Chars[10] = ' ' then
begin
lDateTime := lDateTime.Substring(0, 10) + 'T' + lDateTime.Substring(11);
end;
lIsUTC := lDateTime.Length > 19;
Result := ISO8601ToDate(lDateTime, True);
if lIsUTC and (not gLocalTimeStampAsUTC) then
begin
Result := TTimeZone.Local.ToLocalTime(Result);
end;
end;
function ISODateToDate(const ADate: string): TDate;
begin
Result := EncodeDate(StrToInt(Copy(ADate, 1, 4)), StrToInt(Copy(ADate, 6, 2)),
StrToInt(Copy(ADate, 9, 2)));
end;
function ISOTimeToTime(const ATime: string): TTime;
begin
Result := EncodeTime(StrToInt(Copy(ATime, 1, 2)), StrToInt(Copy(ATime, 4, 2)),
StrToInt(Copy(ATime, 7, 2)), 0);
end;
{ TMVCSerializerHelper }
class procedure TMVCSerializerHelper.DeSerializeBase64StringStream(AStream: TStream;
const ABase64SerializedString: string);
var
SS: TStringStream;
begin
AStream.Size := 0;
SS := TStringStream.Create(ABase64SerializedString, TEncoding.ASCII);
try
SS.Position := 0;
DecodeStream(SS, AStream);
finally
SS.Free;
end;
end;
class procedure TMVCSerializerHelper.DeSerializeStringStream(AStream: TStream;
const ASerializedString: string; const AEncoding: string);
var
Encoding: TEncoding;
SS: TStringStream;
begin
AStream.Position := 0;
Encoding := TEncoding.GetEncoding(AEncoding);
SS := TStringStream.Create(ASerializedString, Encoding);
try
SS.Position := 0;
AStream.CopyFrom(SS, SS.Size);
finally
SS.Free;
end;
end;
class function TMVCSerializerHelper.GetKeyName(const AField: TRttiField;
const AType: TRttiType): string;
var
Attrs: TArray<TCustomAttribute>;
Attr: TCustomAttribute;
begin
{
Dear future me...
Yes, this method is called a lot of times, but after some tests
seems that the performance loss is very low, so if you don't have any
new evidence don't try to improve it...
}
Result := AField.Name;
Attrs := AField.GetAttributes;
for Attr in Attrs do
begin
if Attr is MVCNameAsAttribute then
begin
Exit(MVCNameAsAttribute(Attr).Name);
end;
end;
Attrs := AType.GetAttributes;
for Attr in Attrs do
begin
if Attr is MVCNameCaseAttribute then
begin
Exit(TMVCSerializerHelper.ApplyNameCase(MVCNameCaseAttribute(Attr).KeyCase, AField.Name));
end;
end;
end;
class function TMVCSerializerHelper.AttributeExists<T>(const AAttributes: TArray<TCustomAttribute>;
out AAttribute: T): Boolean;
var
Att: TCustomAttribute;
begin
AAttribute := nil;
for Att in AAttributes do
if Att is T then
begin
AAttribute := T(Att);
Break;
end;
Result := (AAttribute <> nil);
end;
class function TMVCSerializerHelper.ApplyNameCase(const NameCase: TMVCNameCase;
const Value: string): string;
begin
case NameCase of
ncUpperCase:
begin
Result := UpperCase(Value);
end;
ncLowerCase:
begin
Result := LowerCase(Value);
end;
ncCamelCase:
begin
Result := CamelCase(Value);
end;
ncPascalCase:
begin
Result := CamelCase(Value, True);
end;
ncSnakeCase:
begin
Result := SnakeCase(Value);
end;
ncAsIs:
begin
Result := Value;
end
else
raise Exception.Create('Invalid NameCase');
end;
end;
class function TMVCSerializerHelper.AttributeExists<T>(const AAttributes
: TArray<TCustomAttribute>): Boolean;
var
Att: TCustomAttribute;
begin
Result := False;
for Att in AAttributes do
if Att is T then
Exit(True);
end;
class function TMVCSerializerHelper.CreateObject(const AObjectType: TRttiType): TObject;
var
MetaClass: TClass;
Method: TRttiMethod;
begin
MetaClass := nil;
Method := nil;
for Method in AObjectType.GetMethods do
if Method.HasExtendedInfo and Method.IsConstructor then
if Length(Method.GetParameters) = 0 then
begin
MetaClass := AObjectType.AsInstance.MetaclassType;
Break;
end;
if Assigned(MetaClass) then
Result := Method.Invoke(MetaClass, []).AsObject
else
raise EMVCException.CreateFmt('Cannot find a propert constructor for %s',
[AObjectType.ToString]);
end;
class function TMVCSerializerHelper.CreateObject(const AQualifiedClassName: string): TObject;
var
Context: TRttiContext;
ObjectType: TRttiType;
begin
{$IF not Defined(TokyoOrBetter)}
Result := nil;
{$ENDIF}
Context := TRttiContext.Create;
try
ObjectType := Context.FindType(AQualifiedClassName);
if Assigned(ObjectType) then
Result := CreateObject(ObjectType)
else
raise Exception.CreateFmt
('Cannot find RTTI for %s. Hint: Is the specified classtype linked in the module?',
[AQualifiedClassName]);
finally
Context.Free;
end;
end;
class procedure TMVCSerializerHelper.DecodeStream(AInput, AOutput: TStream);
begin
{$IFDEF SYSTEMNETENCODING}
TNetEncoding.Base64.Decode(AInput, AOutput);
{$ELSE}
Soap.EncdDecd.DecodeStream(AInput, AOutput);
{$ENDIF}
end;
class function TMVCSerializerHelper.DecodeString(const AInput: string): string;
begin
{$IFDEF SYSTEMNETENCODING}
Result := TNetEncoding.Base64.Decode(AInput);
{$ELSE}
Result := Soap.EncdDecd.DecodeString(AInput);
{$ENDIF}
end;
class procedure TMVCSerializerHelper.EncodeStream(AInput, AOutput: TStream);
begin
{$IFDEF SYSTEMNETENCODING}
TNetEncoding.Base64.Encode(AInput, AOutput);
{$ELSE}
Soap.EncdDecd.EncodeStream(AInput, AOutput);
{$ENDIF}
end;
class function TMVCSerializerHelper.EncodeString(const AInput: string): string;
begin
{$IFDEF SYSTEMNETENCODING}
Result := TNetEncoding.Base64.Encode(AInput);
{$ELSE}
Result := Soap.EncdDecd.EncodeString(AInput);
{$ENDIF}
end;
class function TMVCSerializerHelper.GetKeyName(const AProperty: TRttiProperty;
const AType: TRttiType): string;
var
Attrs: TArray<TCustomAttribute>;
Attr: TCustomAttribute;
begin
{ TODO -oDanieleT -cGeneral : in un rendering di una lista, quante volte viene chiamata questa funzione? }
{ Tante volte, ma eliminando tutta la logica si guadagnerebbe al massiom il 6% nel caso tipico, forse non vale la pena di aggiungere una cache apposita }
Result := AProperty.Name;
Attrs := AProperty.GetAttributes;
for Attr in Attrs do
begin
if Attr is MVCNameAsAttribute then
begin
Result := MVCNameAsAttribute(Attr).Name;
if MVCNameAsAttribute(Attr).Fixed then { if FIXED the attribute NameAs remains untouched }
begin
Exit
end
else
begin
Break;
end;
end;
end;
Attrs := AType.GetAttributes;
for Attr in Attrs do
begin
if Attr is MVCNameCaseAttribute then
begin
Exit(TMVCSerializerHelper.ApplyNameCase(MVCNameCaseAttribute(Attr).KeyCase, Result));
end;
end;
end;
class function TMVCSerializerHelper.GetTypeKindAsString(const ATypeKind: TTypeKind): string;
begin
Result := GetEnumName(TypeInfo(TTypeKind), Ord(ATypeKind));
Result := Result.Remove(0, 2).ToLower;
end;
class function TMVCSerializerHelper.HasAttribute<T>(const AMember: TRttiObject): Boolean;
var
Attrs: TArray<TCustomAttribute>;
Attr: TCustomAttribute;
begin
Result := False;
Attrs := AMember.GetAttributes;
if Length(Attrs) = 0 then
Exit(False);
for Attr in Attrs do
if Attr is T then
Exit(True);
end;
class function TMVCSerializerHelper.HasAttribute<T>(const AMember: TRttiObject;
out AAttribute: T): Boolean;
var
Attrs: TArray<TCustomAttribute>;
Attr: TCustomAttribute;
begin
AAttribute := nil;
Result := False;
Attrs := AMember.GetAttributes;
for Attr in Attrs do
if Attr is T then
begin
AAttribute := T(Attr);
Exit(True);
end;
end;
class function TMVCSerializerHelper.IsAPropertyToSkip(const aPropName: string): Boolean;
begin
Result := (aPropName = 'RefCount') or (aPropName = 'Disposed');
end;
class function TMVCSerializerHelper.StringToTypeKind(const AValue: string): TTypeKind;
begin
Result := TTypeKind(GetEnumValue(TypeInfo(TTypeKind), 'tk' + AValue));
end;
{ MVCValueAsTypeAttribute }
constructor MVCValueAsTypeAttribute.Create(AValueTypeInfo: PTypeInfo);
begin
inherited Create;
FValueTypeInfo := AValueTypeInfo;
end;
function MVCValueAsTypeAttribute.ValueTypeInfo: PTypeInfo;
begin
Result := FValueTypeInfo;
end;
{ MVCNameCaseAttribute }
constructor MVCNameCaseAttribute.Create(const AKeyCase: TMVCNameCase);
begin
inherited Create;
FKeyCase := AKeyCase;
end;
function MVCNameCaseAttribute.GetKeyCase: TMVCNameCase;
begin
Result := FKeyCase;
end;
{ MVCNameAsAttribute }
constructor MVCNameAsAttribute.Create(const AName: string; const Fixed: Boolean = False);
begin
inherited Create;
fName := AName;
fFixed := Fixed;
end;
{ MVCListOfAttribute }
constructor MVCListOfAttribute.Create(const AValue: TClass);
begin
inherited Create;
FValue := AValue;
end;
{ MVCDataSetFieldAttribute }
constructor MVCDataSetFieldAttribute.Create(const ADataType: TMVCDataType);
begin
inherited Create;
FDataType := ADataType;
end;
{ MVCSerializeAttribute }
constructor MVCSerializeAttribute.Create(const ASerializationType: TMVCSerializationType);
begin
inherited Create;
FSerializationType := ASerializationType;
end;
{ MVCColumnAttribute }
constructor MVCColumnAttribute.Create(AFieldName: string; AIsPK: Boolean);
begin
inherited Create;
FFieldName := AFieldName;
FIsPK := AIsPK;
end;
procedure MVCColumnAttribute.SetFieldName(const Value: string);
begin
FFieldName := Value;
end;
procedure MVCColumnAttribute.SetIsPK(const Value: Boolean);
begin
FIsPK := Value;
end;
{ MVCEnumSerializationTypeAttribute }
constructor MVCEnumSerializationAttribute.Create(const ASerializationType
: TMVCEnumSerializationType; const AMappedValues: string);
begin
FMappedValues := TList<string>.Create(TDelegatedComparer<string>.Create(
function(const Left, Right: string): Integer
begin
Result := CompareText(Left, Right);
end));
FSerializationType := ASerializationType;
if (FSerializationType = estEnumMappedValues) then
begin
if AMappedValues.Trim.IsEmpty then
raise EMVCException.Create('Mapped values are required for estEnumMappedValues type.');
FMappedValues.AddRange(AMappedValues.Split([',', ';', ' ']));
end;
end;
destructor MVCEnumSerializationAttribute.Destroy;
begin
FMappedValues.Free;
inherited;
end;
{ TMVCTask }
constructor TMVCTask.Create(const HREF, ID: string);
begin
inherited Create;
fHREF := HREF;
fID := ID;
end;
{ TMVCAcceptedResponse }
// constructor TMVCAcceptedResponse.Create(const aTask: TMVCTask);
// begin
// inherited Create;
// fTask := aTask;
// end;
constructor TMVCAcceptedResponse.Create(const HREF, ID: string);
begin
inherited Create;
fTask := TMVCTask.Create(HREF, ID);
end;
destructor TMVCAcceptedResponse.Destroy;
begin
fTask.Free;
inherited;
end;
{ TObjectResponseBase }
constructor TMVCResponseData.Create(const AObject: TObject; const AOwns: Boolean;
const ADataSetSerializationType: TMVCDatasetSerializationType);
begin
inherited Create;
fData := AObject;
fMetaData := TMVCStringDictionary.Create;
fOwns := AOwns;
fDataSetSerializationType := ADataSetSerializationType;
end;
destructor TMVCResponseData.Destroy;
begin
fMetaData.Free;
if fOwns then
begin
fData.Free;
end;
inherited;
end;
function TMVCResponseData.GetData: TObject;
begin
Result := fData;
end;
function TMVCResponseData.GetMetadata: TMVCStringDictionary;
begin
Result := fMetaData;
end;
function TMVCResponseData.SerializationType: TMVCDatasetSerializationType;
begin
Result := fDataSetSerializationType;
end;
{ TMVCObjectListResponse }
constructor TMVCObjectListResponse.Create(const AObject: TObject; Owns: Boolean);
begin
inherited Create(AObject, Owns, dstAllRecords);
end;
{ TMVCObjectResponse }
constructor TMVCObjectResponse.Create(const AObject: TObject; Owns: Boolean = True);
begin
inherited Create(AObject, Owns, dstSingleRecord);
end;
procedure MapDataSetFieldToRTTIField(const AField: TField; const aRTTIField: TRttiField;
const AObject: TObject);
var
lInternalStream: TStream;
lSStream: TStringStream;
lValue: TValue;
lStrValue: string;
{$IF not Defined(TokyoOrBetter)}
lFieldValue: string;
{$ENDIF}
begin
lValue := aRTTIField.GetValue(AObject);
if lValue.Kind = tkRecord then
begin
if MapDataSetFieldToNullableRTTIField(lValue, AField, aRTTIField, AObject) then
begin
Exit;
end;
end;
// if we reached this point, the field is not a nullable type...
case AField.DataType of
ftString, ftWideString:
begin
// mysql tinytext is identified as string, but raises an Invalid Class Cast
// so we need to do some more checks...
case aRTTIField.FieldType.TypeKind of
tkString, tkUString:
begin
aRTTIField.SetValue(AObject, AField.AsString);
end;
tkClass: { mysql - maps a tiny field, identified as string, into a TStream }
begin
lInternalStream := aRTTIField.GetValue(AObject).AsObject as TStream;
if lInternalStream = nil then
begin
raise EMVCException.CreateFmt
('Property target for %s field is nil. [HINT] Initialize the stream before load data',
[AField.FieldName]);
end;
lInternalStream.Size := 0;
lStrValue := AField.AsString;
if not lStrValue.IsEmpty then
begin
lInternalStream.Write(lStrValue, Length(lStrValue));
lInternalStream.Position := 0;
end;
end
else
begin
raise EMVCException.CreateFmt('Unsupported FieldType (%d) for field %s',
[Ord(AField.DataType), AField.FieldName]);
end;
end;
// aRTTIField.SetValue(AObject, AField.AsString);
end;
ftLargeint, ftAutoInc:
begin
aRTTIField.SetValue(AObject, AField.AsLargeInt);
end;
ftInteger, ftSmallint, ftShortint, ftByte:
begin
aRTTIField.SetValue(AObject, AField.AsInteger);
end;
ftLongWord, ftWord:
begin
aRTTIField.SetValue(AObject, AField.AsLongWord);
end;
ftCurrency:
begin
aRTTIField.SetValue(AObject, AField.AsCurrency);
end;
ftFMTBcd:
begin
aRTTIField.SetValue(AObject, BCDtoCurrency(AField.AsBCD));
end;
ftDate:
begin
aRTTIField.SetValue(AObject, Trunc(AField.AsDateTime));
end;
ftDateTime:
begin
aRTTIField.SetValue(AObject, AField.AsDateTime);
end;
ftTime:
begin
aRTTIField.SetValue(AObject, Frac(AField.AsDateTime));
end;
ftTimeStamp:
begin
aRTTIField.SetValue(AObject, AField.AsDateTime);
end;
ftBoolean:
begin
aRTTIField.SetValue(AObject, AField.AsBoolean);
end;
ftMemo, ftWideMemo:
begin
case aRTTIField.FieldType.TypeKind of
tkString, tkUString:
begin
{TODO -oDanieleT -cGeneral : Optimize this code... too complex}
if AField.DataType = ftMemo then
aRTTIField.SetValue(AObject, TMemoField(AField).AsWideString)
else if AField.DataType = ftWideMemo then
aRTTIField.SetValue(AObject, TWideMemoField(AField).AsWideString)
else
begin
lSStream := TStringStream.Create('', TEncoding.Unicode);
try
TBlobField(AField).SaveToStream(lSStream);
aRTTIField.SetValue(AObject, lSStream.DataString);
finally
lSStream.Free;
end;
end;
end;
tkFloat: { sqlite - date types stored as text }
begin
if TypeInfo(TDate) = aRTTIField.FieldType.Handle then
begin
aRTTIField.SetValue(AObject, ISODateToDate(AField.AsString));
end
else if TypeInfo(TDateTime) = aRTTIField.FieldType.Handle then
begin
aRTTIField.SetValue(AObject, ISOTimeStampToDateTime(AField.AsString));
end
else if TypeInfo(TTime) = aRTTIField.FieldType.Handle then
begin
aRTTIField.SetValue(AObject, ISOTimeToTime(AField.AsString));
end
else
begin
raise EMVCDeserializationException.Create('Cannot deserialize field ' +
AField.FieldName);
end;
end
else
begin
// In case you want to map a binary blob into a Delphi Stream
lInternalStream := aRTTIField.GetValue(AObject).AsObject as TStream;
if lInternalStream = nil then
begin
raise EMVCException.CreateFmt('Property target for %s field is nil',
[AField.FieldName]);
end;
lInternalStream.Position := 0;
TBlobField(AField).SaveToStream(lInternalStream);
lInternalStream.Position := 0;
end;
end;
end;
ftBCD:
begin
aRTTIField.SetValue(AObject, BCDtoCurrency(AField.AsBCD));
end;
ftFloat, ftSingle:
begin
aRTTIField.SetValue(AObject, AField.AsFloat);
end;
ftBlob:
begin
lInternalStream := aRTTIField.GetValue(AObject).AsObject as TStream;
if AField.IsNull then
begin
lInternalStream.Free;
aRTTIField.SetValue(AObject, nil);
Exit;
end;
if lInternalStream = nil then
begin
lInternalStream := TMemoryStream.Create;
aRTTIField.SetValue(AObject, lInternalStream);
// raise EMVCActiveRecord.CreateFmt('Property target for %s field is nil', [aFieldName]);
end;
lInternalStream.Position := 0;
TBlobField(AField).SaveToStream(lInternalStream);
lInternalStream.Position := 0;
end;
ftGuid:
begin
{$IF Defined(TokyoOrBetter)}
aRTTIField.SetValue(AObject, TValue.From<TGUID>(AField.AsGuid));
{$ELSE}
lFieldValue := AField.AsString;
if lFieldValue.IsEmpty then
begin
lFieldValue := '{00000000-0000-0000-0000-000000000000}';
end;
aRTTIField.SetValue(AObject, TValue.From<TGUID>(StringToGUID(lFieldValue)));
{$ENDIF}
end;
ftDBaseOle: // xml
begin
lSStream := TStringStream.Create('', TEncoding.Unicode);
try
TBlobField(AField).SaveToStream(lSStream);
aRTTIField.SetValue(AObject, lSStream.DataString);
finally
lSStream.Free;
end;
end
else
raise EMVCException.CreateFmt('Unsupported FieldType (%d) for field %s',
[Ord(AField.DataType), AField.FieldName]);
end;
end;
function MapDataSetFieldToNullableRTTIField(const AValue: TValue; const AField: TField;
const aRTTIField: TRttiField; const AObject: TObject): Boolean;
var
lStr: string;
begin
Assert(AValue.Kind = tkRecord);
Result := False;
if AValue.IsType(TypeInfo(NullableString)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableString>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableString>(AField.AsString));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableInt32)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableInt32>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableInt32>(AField.AsLargeInt));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableUInt32)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableUInt32>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableUInt32>(AField.AsLargeInt));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableInt64)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableInt64>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableInt64>(AField.AsLargeInt));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableUInt64)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableUInt64>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableUInt64>(AField.AsLargeInt));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableInt16)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableInt16>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableInt16>(AField.AsLargeInt));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableUInt16)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableUInt16>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableUInt16>(AField.AsInteger));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableTDate)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableTDate>().Clear;
end
else
begin
if not (AField.DataType in [ftWideMemo]) then
begin
aRTTIField.SetValue(AObject, TValue.From<NullableTDate>(AField.AsDateTime));
end
else
begin
{SQLite case...}
lStr := AField.AsWideString;
aRTTIField.SetValue(AObject, TValue.From<NullableTDate>(ISODateToDate(lStr)));
end;
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableTDateTime)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableTDateTime>().Clear;
end
else
begin
if not (AField.DataType in [ftWideMemo]) then
begin
aRTTIField.SetValue(AObject, TValue.From<NullableTDateTime>(AField.AsDateTime));
end
else
begin
{SQLite case...}
lStr := AField.AsWideString;
aRTTIField.SetValue(AObject, TValue.From<NullableTDateTime>(ISOTimeStampToDateTime(lStr)));
end;
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableTTime)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableTTime>().Clear;
end
else
begin
if not (AField.DataType in [ftWideMemo]) then
begin
aRTTIField.SetValue(AObject, TValue.From<NullableTTime>(AField.AsDateTime));
end
else
begin
{SQLite case...}
lStr := AField.AsWideString;
aRTTIField.SetValue(AObject, TValue.From<NullableTTime>(ISOTimeToTime(lStr)));
end;
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableBoolean)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableBoolean>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableBoolean>(AField.AsBoolean));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableDouble)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableDouble>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableDouble>(AField.AsFloat));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableSingle)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableSingle>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableSingle>(AField.AsSingle));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableExtended)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableExtended>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableExtended>(AField.AsExtended));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableCurrency)) then
begin
if AField.IsNull then
begin
aRTTIField.GetValue(AObject).AsType<NullableCurrency>().Clear;
end
else
begin
aRTTIField.SetValue(AObject, TValue.From<NullableCurrency>(AField.AsCurrency));
end;
Result := True;
end
end;
function MapDataSetFieldToNullableRTTIProperty(const AValue: TValue; const AField: TField;
const aRTTIProp: TRttiProperty; const AObject: TObject): Boolean;
begin
Assert(AValue.Kind = tkRecord);
Result := False;
if AValue.IsType(TypeInfo(NullableString)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableString>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableString>(AField.AsString));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableInt32)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableInt32>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableInt32>(AField.AsLargeInt));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableUInt32)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableUInt32>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableUInt32>(AField.AsLargeInt));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableInt64)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableInt64>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableInt64>(AField.AsLargeInt));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableUInt64)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableUInt64>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableUInt64>(AField.AsLargeInt));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableInt16)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableInt16>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableInt16>(AField.AsLargeInt));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableUInt16)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableUInt16>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableUInt16>(AField.AsInteger));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableTDate)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableTDate>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableTDate>(AField.AsDateTime));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableTDateTime)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableTDateTime>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableTDateTime>(AField.AsDateTime));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableTTime)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableTTime>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableTTime>(AField.AsDateTime));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableBoolean)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableBoolean>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableBoolean>(AField.AsBoolean));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableDouble)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableDouble>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableDouble>(AField.AsFloat));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableSingle)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableSingle>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableSingle>(AField.AsSingle));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableExtended)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableExtended>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableExtended>(AField.AsExtended));
end;
Result := True;
end
else if AValue.IsType(TypeInfo(NullableCurrency)) then
begin
if AField.IsNull then
begin
aRTTIProp.GetValue(AObject).AsType<NullableCurrency>().Clear;
end
else
begin
aRTTIProp.SetValue(AObject, TValue.From<NullableCurrency>(AField.AsCurrency));
end;
Result := True;
end
end;
{ TMVCObjectDictionary }
function TMVCObjectDictionary.Add(const Name: string; const Value: TObject;
const SerializationAction: TMVCSerializationAction): IMVCObjectDictionary;
begin
fDict.Add(name, TMVCObjectDictionaryValueItem.Create(fOwnsValueItemData, Value,
SerializationAction));
Result := Self;
end;
function TMVCObjectDictionary.Add(const Name: string; const Value: TDataset;
const SerializationAction: TMVCDataSetSerializationAction;
const DataSetSerializationType: TMVCDatasetSerializationType; const NameCase: TMVCNameCase)
: IMVCObjectDictionary;
begin
fDict.Add(name, TMVCObjectDictionaryValueItem.Create(fOwnsValueItemData, Value,
SerializationAction, DataSetSerializationType, NameCase));
Result := Self;
end;
procedure TMVCObjectDictionary.Clear;
begin
fDict.Clear;
end;
function TMVCObjectDictionary.ContainsKey(const Key: string): Boolean;
begin
Result := fDict.ContainsKey(Key);
end;
function TMVCObjectDictionary.Count: Integer;
begin
Result := fDict.Count;
end;
constructor TMVCObjectDictionary.Create(const aKey: string; const Value: TObject;
const OwnsValues: Boolean);
begin
Create(OwnsValues);
Add(aKey, Value);
end;
constructor TMVCObjectDictionary.Create(const OwnsValues: Boolean);
begin
inherited Create;
fOwnsValueItemData := OwnsValues;
fDict := TObjectDictionary<string, TMVCObjectDictionaryValueItem>.Create([doOwnsValues]);
end;
destructor TMVCObjectDictionary.Destroy;
begin
fDict.Free;
inherited;
end;
function TMVCObjectDictionary.GetItem(const Key: string): TMVCObjectDictionaryValueItem;
begin
Result := fDict.Items[Key];
end;
function TMVCObjectDictionary.Keys: TArray<string>;
begin
Result := fDict.Keys.ToArray;
end;
function TMVCObjectDictionary.TryGetValue(const Name: string; out Value: TObject): Boolean;
var
lItem: TMVCObjectDictionaryValueItem;
begin
Result := fDict.TryGetValue(name, lItem);
if Result then
Value := lItem.Data;
end;
{ TMVCObjectDictionary.TMVCObjectDictionaryValueItem }
constructor TMVCObjectDictionary.TMVCObjectDictionaryValueItem.Create(const Owns: Boolean;
const Data: TObject; const SerializationAction: TMVCSerializationAction);
begin
inherited Create;
fOwns := Owns;
fData := Data;
fSerializationAction := SerializationAction;
fDataSetFieldNameCase := ncAsIs; { not used }
end;
constructor TMVCObjectDictionary.TMVCObjectDictionaryValueItem.Create(const Owns: Boolean;
const Data: TDataset; const SerializationAction: TMVCDataSetSerializationAction;
const DataSetSerializationType: TMVCDatasetSerializationType; const NameCase: TMVCNameCase);
begin
Create(Owns, Data, nil);
fDataSetFieldNameCase := NameCase;
fDataSetSerializationType := DataSetSerializationType;
fDataSetSerializationAction := SerializationAction;
end;
destructor TMVCObjectDictionary.TMVCObjectDictionaryValueItem.Destroy;
begin
if fOwns then
fData.Free;
inherited;
end;
{ MVCOwnedAttribute }
constructor MVCOwnedAttribute.Create(const ClassRef: TClass);
begin
inherited Create;
fClassRef := ClassRef;
end;
initialization
gLocalTimeStampAsUTC := False;
end.
| 28.939066 | 155 | 0.714544 |
c3c02132c917af712d02db09447d43504a2e1c53 | 5,832 | dfm | Pascal | Kide/Source/KIDE.DataPanelControllerDesignerFrameUnit.dfm | gz818/kitto3 | e76eea45028d732730a66c2d6238d13cd2e65392 | [
"Apache-2.0"
]
| 1 | 2021-11-18T05:41:19.000Z | 2021-11-18T05:41:19.000Z | Kide/Source/KIDE.DataPanelControllerDesignerFrameUnit.dfm | gz818/kitto3 | e76eea45028d732730a66c2d6238d13cd2e65392 | [
"Apache-2.0"
]
| null | null | null | Kide/Source/KIDE.DataPanelControllerDesignerFrameUnit.dfm | gz818/kitto3 | e76eea45028d732730a66c2d6238d13cd2e65392 | [
"Apache-2.0"
]
| null | null | null | inherited DataPanelControllerDesignerFrame: TDataPanelControllerDesignerFrame
Height = 429
HelpKeyword = 'DataPanelLeaf'
ExplicitHeight = 429
inherited ClientPanel: TPanel
Height = 429
ExplicitHeight = 429
inherited DesignPanel: TPanel
Height = 429
ExplicitHeight = 429
inherited ControllerGroupBox: TGroupBox
Top = 43
Height = 386
TabOrder = 1
ExplicitTop = 40
ExplicitHeight = 389
inherited ControllerPageControl: TPageControl
Height = 312
ExplicitHeight = 315
inherited SubControllersTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 443
ExplicitHeight = 287
inherited SubControllersPageControl: TPageControl
Height = 183
ExplicitHeight = 186
inherited CenterControllerTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 435
ExplicitHeight = 158
end
inherited NorthControllerTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 435
ExplicitHeight = 158
end
inherited EastControllerTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 435
ExplicitHeight = 158
end
inherited SouthControllerTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 435
ExplicitHeight = 158
end
inherited WestControllerTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 435
ExplicitHeight = 158
end
end
end
inherited SubViewsTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 443
ExplicitHeight = 287
inherited SubViewsPageControl: TPageControl
Height = 183
ExplicitHeight = 186
inherited CenterViewTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 435
ExplicitHeight = 158
end
inherited NorthViewTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 435
ExplicitHeight = 158
end
inherited EastViewTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 435
ExplicitHeight = 158
end
inherited SouthViewTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 435
ExplicitHeight = 158
end
inherited WestViewTabSheet: TTabSheet
ExplicitLeft = 4
ExplicitTop = 24
ExplicitWidth = 435
ExplicitHeight = 158
end
end
inherited ViewsGroupBox: TGroupBox
ExplicitTop = 0
end
end
end
end
object DataPanelGroupBox: TGroupBox
Left = 0
Top = 0
Width = 455
Height = 43
Align = alTop
Caption = 'TopToolbar'
TabOrder = 0
object TopToolBar: TToolBar
Left = 2
Top = 15
Width = 451
Height = 26
AutoSize = True
ButtonHeight = 26
ButtonWidth = 26
Images = MainDataModule.ToolbarImages
TabOrder = 0
object AddToolButton: TToolButton
Left = 0
Top = 0
Hint = 'Allow/Prevent Adding (Default Allow)'
ImageIndex = 0
ParentShowHint = False
ShowHint = True
Style = tbsCheck
end
object DupToolButton: TToolButton
Left = 26
Top = 0
Hint = 'Allow/Prevent Duplicating (Default Prevent)'
ImageIndex = 1
ParentShowHint = False
ShowHint = True
Style = tbsCheck
end
object EditToolButton: TToolButton
Left = 52
Top = 0
Hint = 'Allow/Prevent Editing (Default Allow)'
ImageIndex = 2
ParentShowHint = False
ShowHint = True
Style = tbsCheck
end
object DeleteToolButton: TToolButton
Left = 78
Top = 0
Hint = 'Allow/Prevent Deleting (Default Allow)'
ImageIndex = 3
ParentShowHint = False
ShowHint = True
Style = tbsCheck
end
object ViewToolButton: TToolButton
Left = 104
Top = 0
Hint = 'Allow/Prevent Viewing (Default Prevent)'
ImageIndex = 4
ParentShowHint = False
ShowHint = True
Style = tbsCheck
end
object RefreshToolButton: TToolButton
Left = 130
Top = 0
Hint = 'Allow/Prevent Refreshing (Default Allow)'
ImageIndex = 5
ParentShowHint = False
ShowHint = True
Style = tbsCheck
end
end
end
end
end
end
| 32.043956 | 78 | 0.486111 |
c3d83225a660ddabd01206e214791ce2469758e7 | 46,732 | pas | Pascal | src/PCElements/IndMach012.pas | PMeira/dss_capi | 8b80035730c9d470d057f6643db0a4d4623d70f4 | [
"BSD-3-Clause"
]
| 4 | 2017-12-18T15:23:43.000Z | 2019-02-05T18:22:53.000Z | src/PCElements/IndMach012.pas | PMeira/dss_capi | 8b80035730c9d470d057f6643db0a4d4623d70f4 | [
"BSD-3-Clause"
]
| 28 | 2018-02-12T20:13:26.000Z | 2019-02-11T17:27:51.000Z | src/PCElements/IndMach012.pas | PMeira/dss_capi | 8b80035730c9d470d057f6643db0a4d4623d70f4 | [
"BSD-3-Clause"
]
| 1 | 2018-07-30T22:57:42.000Z | 2018-07-30T22:57:42.000Z | unit IndMach012;
// Symmetrical component Induction Machine model
// ************ DRAFT Version 2 ******************************
{
----------------------------------------------------------
Copyright (c) 2008-2017, Electric Power Research Institute, Inc.
All rights reserved.
----------------------------------------------------------
}
// Change Log
//
// November 10, 2016
//
// Created by
// Andres Ovalle
// Celso Rocha
//
interface
uses
Classes,
DSSClass,
PCClass,
PCElement,
ucmatrix,
UComplex, DSSUcomplex,
ArrayDef,
LoadShape,
GrowthShape,
Spectrum,
Dynamics,
Generator;
type
{$SCOPEDENUMS ON}
TIndMach012Prop = (
INVALID = 0,
phases = 1,
bus1 = 2,
kv = 3,
kW = 4,
pf = 5,
conn = 6,
kVA = 7,
H = 8,
D = 9,
puRs = 10,
puXs = 11,
puRr = 12,
puXr = 13,
puXm = 14,
Slip = 15,
MaxSlip = 16,
SlipOption = 17,
Yearly = 18,
Daily = 19,
Duty = 20,
Debugtrace = 21
);
{$SCOPEDENUMS OFF}
TIndMach012 = class(TPCClass)
PROTECTED
cBuffer: TCBuffer24; // Temp buffer for complex math calcs; allows up to 24-phase models.
procedure DefineProperties; override; // Define the property names and help strings
PUBLIC
constructor Create(dssContext: TDSSContext);
destructor Destroy; OVERRIDE;
function EndEdit(ptr: Pointer; const NumChanges: integer): Boolean; override;
Function NewObject(const ObjName: String; Activate: Boolean = True): Pointer; OVERRIDE; // This function is called by the DSS New command
end;
TSymCompArray = array[0..2] of Complex;
TIndMach012Obj = class(TPCElement)
PRIVATE
{Private variables of this class}
Connection: Integer; {0 = line-neutral; 1=Delta}
Yeq: Complex; // Y at nominal voltage
puRs, puXs, puRr, puXr, puXm,
S1, // Pos seq slip
S2,
MaxSlip, // limit for slip to prevent solution blowing up
dSdP, // for power flow
{Dynamics variables}
Xopen,
Xp,
T0p // Rotor time constant
: Double;
InDynamics: Boolean;
Zs, Zm, Zr,
Is1, Ir1, V1, // Keep the last computed voltages and currents
Is2, Ir2, V2: Complex;
{Complex variables for dynamics}
E1, E1n, dE1dt, dE1dtn,
E2, E2n, dE2dt, dE2dtn,
Zsp: Complex;
FirstIteration: Boolean;
FixedSlip: LongBool;
RandomMult: Double;
IndMach012SwitchOpen: Boolean;
// Debugging
TraceFile: TFileStream;
DebugTrace: LongBool;
MachineData: TGeneratorVars; // Use generator variable structure
MachineON: Boolean;
ShapeFactor: Complex;
ShapeIsActual: Boolean;
VBase: Double;
kWBase: Double;
procedure set_Localslip(const Value: Double);
procedure Get_PFlowModelCurrent(const V: Complex; const S: Double; var Istator, Irotor: Complex);
procedure Get_DynamicModelCurrent;
function GetRotorLosses: Double;
function GetStatorLosses: Double;
function Compute_dSdP: Double;
procedure Randomize(Opt: Integer);
procedure InitModel(V012, I012: TSymCompArray);
procedure CalcYPrimMatrix(Ymatrix: TcMatrix);
procedure CalcIndMach012ModelContribution;
procedure DoIndMach012Model;
procedure CalcModel(V, I: pComplexArray);
procedure CalcDailyMult(Hr: Double);
procedure CalcYearlyMult(Hr: Double);
procedure CalcDutyMult(Hr: Double);
procedure InitTraceFile;
procedure WriteTraceRecord;
procedure SetPowerkW(const PkW: Double);
PROTECTED
procedure GetTerminalCurrents(Curr: pComplexArray); OVERRIDE;
procedure DoDynamicMode;
procedure DoHarmonicMode;
PUBLIC
DailyDispShapeObj: TLoadShapeObj; // Daily Generator Shape for this load
DutyShapeObj: TLoadShapeObj; // Shape for this generator
YearlyShapeObj: TLoadShapeObj; // Shape for this Generator
constructor Create(ParClass: TDSSClass; const IndMach012ObjName: String);
destructor Destroy; OVERRIDE;
procedure PropertySideEffects(Idx: Integer; previousIntVal: Integer = 0); override;
procedure MakeLike(OtherPtr: Pointer); override;
procedure Set_ConductorClosed(Index: Integer; Value: Boolean); OVERRIDE;
procedure RecalcElementData; OVERRIDE; // Generally called after Edit is complete to recompute variables
procedure CalcYPrim; OVERRIDE; // Calculate Primitive Y matrix
procedure Integrate;
procedure CalcDynamic(var V012, I012: TSymCompArray);
procedure CalcPFlow(var V012, I012: TSymCompArray);
procedure SetNominalPower;
function InjCurrents: Integer; OVERRIDE;
function NumVariables: Integer; OVERRIDE;
procedure GetAllVariables(States: pDoubleArray); OVERRIDE;
function Get_Variable(i: Integer): Double; OVERRIDE;
procedure Set_Variable(i: Integer; Value: Double); OVERRIDE;
function VariableName(i: Integer): String; OVERRIDE;
// Support for Dynamics Mode
procedure InitStateVars; OVERRIDE;
procedure IntegrateStates; OVERRIDE;
// Support for Harmonics Mode
procedure InitHarmonics; OVERRIDE;
procedure MakePosSequence(); OVERRIDE; // Make a positive Sequence Model, if possible
end;
implementation
uses
BufStream,
DSSClassDefs,
DSSGlobals,
Circuit,
Command,
Sysutils,
Math,
MathUtil,
Utilities,
DSSHelper,
DSSObjectHelper,
TypInfo;
type
TObj = TIndMach012Obj;
TProp = TIndMach012Prop;
const
NumPropsThisClass = Ord(High(TProp));
NumIndMach012Variables = 22;
var
PropInfo: Pointer = NIL;
SlipOptionEnum : TDSSEnum;
constructor TIndMach012.Create(dssContext: TDSSContext);
begin
if PropInfo = NIL then
begin
PropInfo := TypeInfo(TProp);
SlipOptionEnum := TDSSEnum.Create('IndMach012: Slip Option', True, 1, 1,
['VariableSlip', 'FixedSlip'], [0, Integer(True)]);
SlipOptionEnum.DefaultValue := 0;
end;
inherited Create(dssContext, INDMACH012_ELEMENT, 'IndMach012');
end;
destructor TIndMach012.Destroy;
begin
inherited Destroy;
end;
function PowerFactorProperty(obj: TObj): Double;
begin
Result := PowerFactor(obj.Power[1]);
end;
procedure SetLocalSlip(Obj: TObj; Value: Double);
begin
obj.set_Localslip(Value);
end;
procedure TIndMach012.DefineProperties;
var
obj: TObj = NIL; // NIL (0) on purpose
begin
Numproperties := NumPropsThisClass;
CountPropertiesAndAllocate();
PopulatePropertyNames(0, NumPropsThisClass, PropInfo);
// integer
PropertyType[ord(TProp.phases)] := TPropertyType.IntegerProperty;
PropertyOffset[ord(TProp.phases)] := ptruint(@obj.FNPhases);
PropertyFlags[ord(TProp.phases)] := [TPropertyFlag.NonNegative, TPropertyFlag.NonZero];
// special function properties
PropertyFlags[ord(TProp.pf)] := [TPropertyFlag.SilentReadOnly, TPropertyFlag.ReadByFunction];
PropertyReadFunction[ord(TProp.pf)] := @PowerFactorProperty;
// enum properties
PropertyType[ord(TProp.conn)] := TPropertyType.MappedStringEnumProperty;
PropertyOffset[ord(TProp.conn)] := ptruint(@obj.Connection);
PropertyOffset2[ord(TProp.conn)] := PtrInt(DSS.ConnectionEnum);
PropertyType[ord(TProp.SlipOption)] := TPropertyType.MappedStringEnumProperty;
PropertyOffset[ord(TProp.SlipOption)] := ptruint(@obj.Fixedslip); // LongBool as Integer
PropertyOffset2[ord(TProp.SlipOption)] := PtrInt(SlipOptionEnum);
// bus properties
PropertyType[ord(TProp.bus1)] := TPropertyType.BusProperty;
PropertyOffset[ord(TProp.bus1)] := 1;
// boolean properties
PropertyType[ord(TProp.Debugtrace)] := TPropertyType.BooleanProperty;
PropertyOffset[ord(TProp.Debugtrace)] := ptruint(@obj.DebugTrace);
// object properties
PropertyType[ord(TProp.yearly)] := TPropertyType.DSSObjectReferenceProperty;
PropertyType[ord(TProp.daily)] := TPropertyType.DSSObjectReferenceProperty;
PropertyType[ord(TProp.duty)] := TPropertyType.DSSObjectReferenceProperty;
PropertyOffset[ord(TProp.yearly)] := ptruint(@obj.YearlyShapeObj);
PropertyOffset[ord(TProp.daily)] := ptruint(@obj.DailyDispShapeObj);
PropertyOffset[ord(TProp.duty)] := ptruint(@obj.DutyShapeObj);
PropertyOffset2[ord(TProp.yearly)] := ptruint(DSS.LoadShapeClass);
PropertyOffset2[ord(TProp.daily)] := ptruint(DSS.LoadShapeClass);
PropertyOffset2[ord(TProp.duty)] := ptruint(DSS.LoadShapeClass);
// double properties (default type)
PropertyOffset[ord(TProp.kW)] := ptruint(@obj.kWBase);
PropertyOffset[ord(TProp.puRs)] := ptruint(@obj.puRs);
PropertyOffset[ord(TProp.puXs)] := ptruint(@obj.puXs);
PropertyOffset[ord(TProp.puRr)] := ptruint(@obj.puRr);
PropertyOffset[ord(TProp.puXr)] := ptruint(@obj.puXr);
PropertyOffset[ord(TProp.puXm)] := ptruint(@obj.puXm);
PropertyOffset[ord(TProp.MaxSlip)] := ptruint(@obj.MaxSlip);
PropertyOffset[ord(TProp.H)] := ptruint(@obj.MachineData.Hmass);
PropertyOffset[ord(TProp.D)] := ptruint(@obj.MachineData.D);
PropertyOffset[ord(TProp.kVA)] := ptruint(@obj.MachineData.kVArating);
PropertyOffset[ord(TProp.kV)] := ptruint(@obj.MachineData.kVGeneratorBase);
// advanced double
PropertyOffset[ord(TProp.slip)] := ptruint(@obj.S1);
PropertyWriteFunction[ord(TProp.slip)] := @SetLocalSlip;
PropertyFlags[ord(TProp.slip)] := [TPropertyFlag.WriteByFunction];
ActiveProperty := NumPropsThisClass;
inherited DefineProperties;
end;
function TIndMach012.NewObject(const ObjName: String; Activate: Boolean): Pointer;
var
Obj: TObj;
begin
Obj := TObj.Create(Self, ObjName);
if Activate then
ActiveCircuit.ActiveCktElement := Obj;
Obj.ClassIndex := AddObjectToList(Obj, Activate);
Result := Obj;
end;
procedure SetNcondsForConnection(Obj: TObj);
begin
with Obj do
case Connection of
0:
NConds := Fnphases; // Neutral is not connected for induction machine
1:
case Fnphases of // Delta connection
1, 2:
NConds := Fnphases + 1; // L-L and Open-delta
else
NConds := Fnphases; // no neutral for this connection
end;
end;
end;
procedure TIndMach012Obj.PropertySideEffects(Idx: Integer; previousIntVal: Integer);
begin
case Idx of
ord(TProp.phases):
SetNCondsForConnection(self); // Force Reallocation of terminal info
ord(TProp.kV):
with MachineData do
case FNphases of
2, 3:
VBase := kVGeneratorBase * InvSQRT3x1000;
else
VBase := kVGeneratorBase * 1000.0;
end;
ord(TProp.slip):
MachineData.Speed := MachineData.w0 * (-S1); // make motor speed agree
18:
if Assigned(YearlyShapeObj) then
with YearlyShapeObj do
if UseActual then
SetPowerkW(MaxP);
19:
if Assigned(DailyDispShapeObj) then
with DailyDispShapeObj do
if UseActual then
SetPowerkW(MaxP);
20:
if Assigned(DutyShapeObj) then
with DutyShapeObj do
if UseActual then
SetPowerkW(MaxP);
end;
inherited PropertySideEffects(Idx, previousIntVal);
end;
function TIndMach012.EndEdit(ptr: Pointer; const NumChanges: integer): Boolean;
begin
with TObj(ptr) do
begin
RecalcElementData;
YPrimInvalid := TRUE;
Exclude(Flags, Flg.EditionActive);
end;
Result := True;
end;
procedure TIndMach012Obj.MakeLike(OtherPtr: Pointer);
var
Other: TObj;
begin
inherited MakeLike(OtherPtr);
Other := TObj(OtherPtr);
if (Fnphases <> Other.Fnphases) then
begin
FNphases := Other.Fnphases;
NConds := Fnphases; // Forces reallocation of terminal stuff
Yorder := Fnconds * Fnterms;
YPrimInvalid := TRUE;
end;
MachineData := Other.MachineData; // record, copy everything at once
VBase := Other.VBase;
kWBase := Other.kWBase;
puRs := Other.puRs;
puRr := Other.puRr;
puXr := Other.puXr;
puXm := Other.puXm;
puXs := Other.puXs;
MaxSlip := Other.MaxSlip;
end;
constructor TIndMach012Obj.Create(ParClass: TDSSClass; const IndMach012ObjName: String);
begin
inherited create(ParClass);
Name := AnsiLowerCase(IndMach012ObjName);
DSSObjType := ParClass.DSSClassType; // Same as Parent Class
TraceFile := nil;
FNphases := 3;
Fnconds := 3;
Yorder := 0;
Nterms := 1;
kWBase := 1000.0;
YearlyShapeObj := NIL; // if YearlyShapeobj = nil then the load alway stays nominal * global multipliers
DailyDispShapeObj := NIL; // if DaillyShapeobj = nil then the load alway stays nominal * global multipliers
DutyShapeObj := NIL; // if DutyShapeobj = nil then the load alway stays nominal * global multipliers
Debugtrace := FALSE;
Yorder := Fnterms * Fnconds;
ShapeIsActual := FALSE;
IndMach012SwitchOpen := FALSE;
Connection := 1; // Delta Default
MachineData.kVGeneratorBase := 12.47;
MachineData.kVArating := kWBase * 1.2;
with MachineData do
begin
Hmass := 1.0; // W-sec/VA rating
Theta := 0.0;
w0 := TwoPi * Basefrequency;
Speed := 0.0; // relative speed
dSpeed := 0.0;
D := 1.0;
XRdp := 20.0; // not used for indmach
// newly added
Conn := connection;
NumPhases := Fnphases;
NumConductors := Fnconds;
end;
{Typical machine impedance data}
puRs := 0.0053;
puXs := 0.106;
puRr := 0.007;
puXr := 0.12;
puXm := 4.0;
// Set slip local and make generator model agree
MaxSlip := 0.1; // 10% slip limit - set this before setting slip
set_LocalSlip(0.007); // About 1 pu power
PropertySideEffects(ord(TProp.slip));
FixedSlip := FALSE; // Allow Slip to float to match specified power
InDynamics := FALSE;
RecalcElementData;
end;
destructor TIndMach012Obj.Destroy;
// Free everything here that needs to be freed
// If you allocated anything, dispose of it here
begin
FreeAndNil(TraceFile);
inherited Destroy; // This will take care of most common circuit element arrays, etc.
end;
procedure TIndMach012Obj.RecalcElementData;
var
Rs, Xs,
Rr, Xr,
Xm, ZBase: Double;
begin
with MachineData do
begin
ZBase := Sqr(kVGeneratorBase) / kVArating * 1000.0;
Conn := connection;
NumPhases := Fnphases;
NumConductors := Fnconds;
end;
Rs := puRs * ZBase;
Xs := puXs * ZBase;
Rr := puRr * ZBase;
Xr := puXr * ZBase;
Xm := puXm * ZBase;
Zs := Cmplx(Rs, Xs);
Zm := Cmplx(0.0, Xm);
Zr := Cmplx(Rr, Xr);
Xopen := Xs + Xm;
Xp := Xs + (Xr * Xm) / (Xr + Xm);
Zsp := Cmplx(Rs, Xp);
//Yeq := Cinv(Zsp); // for Yprim for dynamics
//Yeq := Cmplx(1.0/ZBase, -0.5/Zbase); // vars are half the watts
Yeq := Cmplx(0.0, -1.0 / ZBase); // vars only for power flow
T0p := (Xr + Xm) / (MachineData.w0 * Rr);
dSdP := Compute_dSdP;
Is1 := CZERO;
V1 := CZERO;
Is2 := CZERO;
V2 := CZERO;
FirstIteration := TRUE;
Reallocmem(InjCurrent, SizeOf(InjCurrent^[1]) * Yorder);
SetNominalPower;
if DebugTrace then
InitTraceFile
else
FreeAndNil(TraceFile);
end;
procedure TIndMach012Obj.SetPowerkW(const PkW: Double);
begin
kWBase := PkW;
end;
procedure TIndMach012Obj.Integrate;
var
h2: Double;
begin
with ActiveCircuit.Solution.Dynavars do
begin
if IterationFlag = 0 then
begin // on predictor step
E1n := E1; // update old values
dE1dtn := dE1dt;
E2n := E2;
dE2dtn := dE2dt;
end;
// Derivative of E
// dEdt = -jw0SE' - (E' - j(X-X')I')/T0'
dE1dt := cmplx(0.0, -MachineData.w0 * S1) * E1 - (E1 - cmplx(0.0, Xopen - Xp) * Is1) / T0p;
dE2dt := cmplx(0.0, -MachineData.w0 * S2) * E2 - (E2 - cmplx(0.0, Xopen - Xp) * Is2) / T0p;
// Trapezoidal Integration
h2 := h * 0.5;
E1 := E1n + (dE1dt + dE1dtn) * h2;
E2 := E2n + (dE2dt + dE2dtn) * h2;
end;
end;
procedure TIndMach012Obj.CalcDynamic(var V012, I012: TSymCompArray);
begin
{In dynamics mode, slip is allowed to vary}
InDynamics := TRUE;
V1 := V012[1]; // Save for variable calcs
V2 := V012[2];
{Gets slip from shaft speed}
with MachineData do
set_LocalSlip((-Speed) / w0);
Get_DynamicModelCurrent;
// Get_ModelCurrent(V2, S2, Is2, Ir2);
I012[1] := Is1; // Save for variable calcs
I012[2] := Is2;
I012[0] := cmplx(0.0, 0.0);
end;
procedure TIndMach012Obj.CalcPFlow(var V012, I012: TSymCompArray);
var
P_Error: Double;
begin
V1 := V012[1]; // Save for variable calcs
V2 := V012[2];
InDynamics := FALSE;
if FirstIteration then
begin
Get_PFlowModelCurrent(V1, S1, Is1, Ir1); // initialize Is1
FirstIteration := FALSE;
end;
{If Fixed slip option set, then use the value set by the user}
if not FixedSlip then
begin
P_Error := MachineData.PnominalperPhase - (V1 * cong(Is1)).re;
set_LocalSlip(S1 + dSdP * P_Error); // make new guess at slip
end;
Get_PFlowModelCurrent(V1, S1, Is1, Ir1);
Get_PFlowModelCurrent(V2, S2, Is2, Ir2);
I012[1] := Is1; // Save for variable calcs
I012[2] := Is2;
I012[0] := cmplx(0.0, 0.0);
end;
procedure TIndMach012Obj.Randomize(Opt: Integer);
// typical proc for handling randomization in DSS fashion
begin
case Opt of
0:
RandomMult := 1.0;
// GAUSSIAN: RandomMult := Gauss(YearlyShapeObj.Mean, YearlyShapeObj.StdDev);
UNIFORM:
RandomMult := Random; // number between 0 and 1.0
// LOGNORMAL: RandomMult := QuasiLognormal(YearlyShapeObj.Mean);
end;
end;
procedure TIndMach012Obj.InitModel(V012, I012: TSymCompArray);
// Init for Dynamics mode
begin
// Compute Voltage behind transient reactance and set derivatives to zero
// *** already done *** E1 := V012[1] - I012[1] * Zsp;
dE1dt := czero;
E1n := E1;
dE1dtn := dE1dt;
E2 := V012[2] - I012[2] * Zsp;
dE2dt := czero;
E2n := E2;
dE2dtn := dE2dt;
end;
procedure TIndMach012Obj.InitStateVars;
var
i: Integer;
V012,
I012: TSymCompArray;
Vabc: array[1..3] of Complex;
begin
YPrimInvalid := TRUE; // Force rebuild of YPrims
with MachineData do
begin
{Compute nominal Positive sequence voltage behind transient reactance}
if MachineON then
with ActiveCircuit.Solution do
begin
Yeq := Cinv(Zsp);
ComputeIterminal;
case Fnphases of
1:
begin
E1 := NodeV^[NodeRef^[1]] - NodeV^[NodeRef^[2]] - ITerminal^[1] * Zsp;
end;
3:
begin
// Calculate E1 based on Pos Seq only
Phase2SymComp(ITerminal, pComplexArray(@I012)); // terminal currents
// Voltage behind Zsp (transient reactance), volts
for i := 1 to FNphases do
Vabc[i] := NodeV^[NodeRef^[i]]; // Wye Voltage
Phase2SymComp(pComplexArray(@Vabc), pComplexArray(@V012));
E1 := V012[1] - I012[1] * Zsp; // Pos sequence
end;
else
DoSimpleMsg('Dynamics mode is implemented only for 1- or 3-phase Motors. %s has %d phases.', [FullName, Fnphases], 5672);
DSS.SolutionAbort := TRUE;
end;
InitModel(V012, I012); // E2, etc
// Shaft variables
Theta := Cang(E1);
dTheta := 0.0;
w0 := Twopi * ActiveCircuit.Solution.Frequency;
// recalc Mmass and D in case the frequency has changed
with MachineData do
begin
Mmass := 2.0 * Hmass * kVArating * 1000.0 / (w0); // M = W-sec
D := Dpu * kVArating * 1000.0 / (w0);
end;
Pshaft := Power[1].re; // Initialize Pshaft to present power consumption of motor
Speed := -S1 * w0; // relative to synch speed
dSpeed := 0.0;
if DebugTrace then // Put in a separator record
begin
FSWriteln(TraceFile);
FSWriteln(TraceFile, '*************** Entering Dynamics Mode ***********************');
FSWriteln(TraceFile);
FSFlush(Tracefile);
end;
end
else
begin
Theta := 0.0;
dTheta := 0.0;
w0 := 0;
Speed := 0.0;
dSpeed := 0.0;
end;
end;
end;
procedure TIndMach012Obj.CalcYPrimMatrix(Ymatrix: TcMatrix);
// A typical helper function for PC elements to assist in the computation of Yprim
var
Y, Yij, Yadder: Complex;
i, j: Integer;
FreqMultiplier: Double;
begin
FYprimFreq := ActiveCircuit.Solution.Frequency;
FreqMultiplier := FYprimFreq / BaseFrequency; // ratio to adjust reactances for present solution frequency
with ActiveCircuit.solution do
if IsDynamicModel or IsHarmonicModel then
// for Dynamics and Harmonics modes use constant equivalent Y
begin
if MachineON then
Y := Yeq // L-N value computed in initialization routines
else
Y := Cmplx(EPSILON, 0.0);
if Connection = 1 then
Y := Y / 3.0; // Convert to delta impedance
Y.im := Y.im / FreqMultiplier; // adjust for frequency
Yij := -Y;
for i := 1 to Fnphases do
begin
case Connection of
0:
begin
Ymatrix.SetElement(i, i, Y); // sets the element
// Ymatrix.AddElement(Fnconds, Fnconds, Y); // sums the element
// Ymatrix.SetElemsym(i, Fnconds, Yij);
end;
1:
begin {Delta connection}
Yadder := Y * 1.000001; // to prevent floating delta
Ymatrix.SetElement(i, i, Y + Yadder); // add a little bit to diagonal
Ymatrix.AddElement(i, i, Y); // put it in again
for j := 1 to i - 1 do
Ymatrix.SetElemsym(i, j, Yij);
end;
end;
end;
end
else
begin
// Typical code for a regular power flow model
// Borrowed from Generator object
{Yeq is typically expected as the equivalent line-neutral admittance}
Y := Yeq; // Yeq is L-N quantity
// ****** Need to modify the base admittance for real harmonics calcs
Y.im := Y.im / FreqMultiplier;
case Connection of
0:
with YMatrix do
begin // WYE
for i := 1 to Fnphases do
begin
SetElement(i, i, Y);
{
AddElement(Fnconds, Fnconds, Y);
SetElemsym(i, Fnconds, Yij);
}
end;
end;
1:
with YMatrix do
begin // Delta or L-L
Y := Y / 3.0; // Convert to delta impedance
Yij := -Y;
for i := 1 to Fnphases do
begin
j := i + 1;
if j > Fnconds then
j := 1; // wrap around for closed connections
AddElement(i, i, Y);
AddElement(j, j, Y);
AddElemSym(i, j, Yij);
end;
end;
end;
end; {ELSE IF Solution.mode}
end;
{--- Notes Andres: Added according to IndMach012.dll model }
function TIndMach012Obj.Compute_dSdP: Double;
begin
// dSdP based on rated slip and rated voltage
V1 := Cmplx(MachineData.kvGeneratorBase * 1000.0 / 1.732, 0.0);
if S1 <> 0.0 then
Get_PFlowModelCurrent(V1, S1, Is1, Ir1);
Result := S1 / (V1 * cong(Is1)).Re;
end;
procedure TIndMach012Obj.CalcYPrim;
// Required routine to calculate the primitive Y matrix for this element
// This example uses a helper function (CalcYPrimMatrix) to keep the code
// here clean
var
i: Integer;
begin
{
There are three Yprim matrices that could be computed:
YPrim_Series: Used for zero-load solutions to initialize the first guess
YPrim_Shunt: Equivalent Y in shunt with power system
For PC elements, this is typically the main YPrim
YPrim: Generally the sum of the other two; the total YPrim
}
// Typical PC Elements build only shunt Yprim
// Also, build a dummy Yprim Series so that CalcVoltagebases does not fail
// First clear present value; redefine if necessary
// Note: Complex matrix (TcMatrix -- see uCmatrix.pas) is used for this
if (Yprim = NIL) OR (Yprim.order <> Yorder) OR (Yprim_Shunt = NIL) OR (Yprim_Series = NIL) {YPrimInvalid} then
begin
if YPrim_Shunt <> NIL then
YPrim_Shunt.Free;
YPrim_Shunt := TcMatrix.CreateMatrix(Yorder);
if YPrim_Series <> NIL then
Yprim_Series.Free;
YPrim_Series := TcMatrix.CreateMatrix(Yorder);
if YPrim <> NIL then
YPrim.Free;
YPrim := TcMatrix.CreateMatrix(Yorder);
end
else
begin
YPrim_Shunt.Clear;
YPrim_Series.Clear;
YPrim.Clear;
end;
// call helper routine to compute YPrim_Shunt
CalcYPrimMatrix(YPrim_Shunt);
// Set YPrim_Series based on a small fraction of the diagonals of YPrim_shunt
// so that CalcVoltages doesn't fail
// This is just one of a number of possible strategies but seems to work most of the time
for i := 1 to Yorder do
Yprim_Series.SetElement(i, i, Yprim_Shunt.Getelement(i, i) * 1.0e-10);
// copy YPrim_shunt into YPrim; That's all that is needed for most PC Elements
YPrim.CopyFrom(YPrim_Shunt);
// Account for Open Conductors -- done in base class
inherited CalcYPrim;
end;
// - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - -
procedure TIndMach012Obj.DoIndMach012Model;
{Compute total terminal Current }
var
i: Integer;
begin
CalcYPrimContribution(InjCurrent); // Init InjCurrent Array
CalcModel(Vterminal, Iterminal);
IterminalUpdated := TRUE;
for i := 1 to FNphases do
InjCurrent^[i] -= Iterminal^[i];
if (DebugTrace) then
WriteTraceRecord;
end;
procedure TIndMach012Obj.CalcModel(V, I: pComplexArray); // given voltages returns currents
var
V012, I012: TSymCompArray;
begin
// Convert abc voltages to 012
Phase2SymComp(V, pComplexArray(@V012));
// compute I012
case ActiveCircuit.Solution.DynaVars.SolutionMode of
TSolveMode.DYNAMICMODE:
begin
CalcDynamic(V012, I012);
end;
else {All other modes are power flow modes}
begin
CalcPflow(V012, I012);
end;
end;
SymComp2Phase(I, pComplexArray(@I012)); // convert back to I abc
end;
procedure TIndMach012Obj.DoDynamicMode;
{ This is an example taken from Generator illustrating how a PC element might
handle Dynamics mode with a Thevenin equivalent
Also illustrates the computation of symmetrical component values
}
{Compute Total Current and add into InjTemp}
var
i: Integer;
begin
// Start off by getting the current in the admittance branch of the model
CalcYPrimContribution(InjCurrent); // Init InjCurrent Array
{Inj = -Itotal (in) - Yprim*Vtemp}
CalcModel(Vterminal, Iterminal);
IterminalUpdated := TRUE;
for i := 1 to FNphases do
InjCurrent^[i] -= ITerminal^[i];
end;
procedure TIndMach012Obj.DoHarmonicMode;
{
Example taken from Generator illustrating how a PC element might handle
current calcs for Harmonics mode
Note: Generator objects assume a Thevenin model (voltage behind and impedance)
while Load objects assume the Spectrum applies to a Norton model injection current
}
{Compute Injection Current Only when in harmonics mode}
{Assumes spectrum is a voltage source behind subtransient reactance and YPrim has been built}
{Vd is the fundamental frequency voltage behind Xd" for phase 1}
var
i: Integer;
E: Complex;
GenHarmonic: Double;
pBuffer: PCBuffer24;
begin
pBuffer := @TIndMach012(ParentClass).cBuffer;
// Set the VTerminal array
ComputeVterminal;
with ActiveCircuit.Solution do
begin
GenHarmonic := Frequency / BaseFrequency; // harmonic based on the fundamental for this object
// get the spectrum multiplier and multiply by the V thev (or Norton current for load objects)
// ??? E := SpectrumObj.GetMult(GenHarmonic) * VThevHarm; // Get base harmonic magnitude
// ??? RotatePhasorRad(E, GenHarmonic, ThetaHarm); // Time shift by fundamental frequency phase shift
// Put the values in a temp complex buffer
for i := 1 to Fnphases do
begin
pBuffer[i] := E;
if i < Fnphases then
RotatePhasorDeg(E, GenHarmonic, -120.0); // Assume 3-phase IndMach012
end;
end;
{Handle Wye Connection}
if Connection = 0 then
pBuffer[Fnconds] := Vterminal^[Fnconds]; // assume no neutral injection voltage
// In this case the injection currents are simply Yprim(frequency) times the voltage buffer
// Refer to Load.Pas for load-type objects
{Inj currents = Yprim (E) }
YPrim.MVMult(InjCurrent, pComplexArray(pBuffer));
end;
procedure TIndMach012Obj.CalcIndMach012ModelContribution;
// Main dispatcher for computing PC Element currnts
// Calculates IndMach012 current and adds it properly into the injcurrent array
// routines may also compute ITerminal (ITerminalUpdated flag)
begin
IterminalUpdated := FALSE;
with ActiveCircuit, ActiveCircuit.Solution do
begin
if IsDynamicModel then
DoDynamicMode
else
if IsHarmonicModel and (Frequency <> Fundamental) then
DoHarmonicMode
else
DoIndMach012Model;
end; {WITH}
{When this is done, ITerminal is up to date}
end;
procedure TIndMach012Obj.GetTerminalCurrents(Curr: pComplexArray);
// This function controls the calculation of the total terminal currents
// Note that it only does something if the solution count has changed.
// Otherwise, Iterminal array already contains the currents
begin
with ActiveCircuit.Solution do
begin
if IterminalSolutionCount <> ActiveCircuit.Solution.SolutionCount then
begin // recalc the contribution
// You will likely want some logic like this
if not IndMach012SwitchOpen then
CalcIndMach012ModelContribution; // Adds totals in Iterminal as a side effect
end;
inherited GetTerminalCurrents(Curr); // add in inherited contribution
end;
end;
function TIndMach012Obj.InjCurrents: Integer;
// Required function for managing computing of InjCurrents
begin
with ActiveCircuit.Solution do
begin
// Generators and Loads use logic like this:
if LoadsNeedUpdating then
SetNominalPower; // Set the nominal kW, etc for the type of solution being done
// call the main function for doing calculation
// Difference between currents in YPrim and total terminal current
if IndMach012SwitchOpen then
// If the element is open, just zero the array and return
ZeroInjCurrent
else
// otherwise, go to a routine that manages the calculation
CalcIndMach012ModelContribution;
// If (DebugTrace) Then WriteTraceRecord;
// Add into System Injection Current Array
Result := inherited InjCurrents;
end;
end;
procedure TIndMach012Obj.SetNominalPower;
// Set shaft power
var
Factor: Double;
MachineOn_Saved: Boolean;
begin
MachineOn_Saved := MachineON;
ShapeFactor := CDOUBLEONE;
// Check to make sure the generation is ON
with ActiveCircuit, ActiveCircuit.Solution do
begin
if not (IsDynamicModel or IsHarmonicModel) then // Leave machine in whatever state it was prior to entering Dynamic mode
begin
MachineON := TRUE; // Init to on then check if it should be off
end;
if not MachineON then
begin
// If Machine is OFF enter as tiny resistive load (.0001 pu) so we don't get divide by zero in matrix
MachineData.Pnominalperphase := -0.1 * kWBase / Fnphases;
// Pnominalperphase := 0.0;
MachineData.Qnominalperphase := 0.0; // This really doesn't matter
end
else
begin // Generator is on, compute it's nominal watts and vars
with Solution do
case Mode of
TSolveMode.SNAPSHOT:
Factor := 1.0;
TSolveMode.DAILYMODE:
begin
Factor := 1.0;
CalcDailyMult(DynaVars.dblHour) // Daily dispatch curve
end;
TSolveMode.YEARLYMODE:
begin
Factor := 1.0;
CalcYearlyMult(DynaVars.dblHour);
end;
TSolveMode.DUTYCYCLE:
begin
Factor := 1.0;
CalcDutyMult(DynaVars.dblHour);
end;
TSolveMode.GENERALTIME, // General sequential time simulation
TSolveMode.DYNAMICMODE:
begin
Factor := 1.0;
// This mode allows use of one class of load shape
case ActiveCircuit.ActiveLoadShapeClass of
USEDAILY:
CalcDailyMult(DynaVars.dblHour);
USEYEARLY:
CalcYearlyMult(DynaVars.dblHour);
USEDUTY:
CalcDutyMult(DynaVars.dblHour);
else
ShapeFactor := CDOUBLEONE // default to 1 + j1 if not known
end;
end;
TSolveMode.MONTECARLO1,
TSolveMode.MONTEFAULT,
TSolveMode.FAULTSTUDY:
Factor := 1.0;
TSolveMode.MONTECARLO2,
TSolveMode.MONTECARLO3,
TSolveMode.LOADDURATION1,
TSolveMode.LOADDURATION2:
begin
Factor := 1.0;
CalcDailyMult(DynaVars.dblHour);
end;
TSolveMode.PEAKDAY:
begin
Factor := 1.0;
CalcDailyMult(DynaVars.dblHour);
end;
TSolveMode.AUTOADDFLAG:
Factor := 1.0;
else
Factor := 1.0
end;
if not (IsDynamicModel or IsHarmonicModel) then //******
begin
if ShapeIsActual then
MachineData.Pnominalperphase := 1000.0 * ShapeFactor.re / Fnphases
else
MachineData.Pnominalperphase := 1000.0 * kWBase * Factor * ShapeFactor.re / Fnphases;
// cannot dispatch vars in induction machine
// you get what you get
end;
end; {ELSE GenON}
end; {With ActiveCircuit}
// If machine state changes, force re-calc of Y matrix
if MachineON <> MachineOn_Saved then
YPrimInvalid := TRUE;
end;
procedure TIndMach012Obj.CalcDailyMult(Hr: Double);
begin
if (DailyDispShapeObj <> NIL) then
begin
ShapeFactor := DailyDispShapeObj.GetMultAtHour(Hr);
ShapeIsActual := DailyDispShapeObj.UseActual;
end
else
ShapeFactor := CDOUBLEONE; // Default to no daily variation
end;
procedure TIndMach012Obj.CalcDutyMult(Hr: Double);
begin
if DutyShapeObj <> NIL then
begin
ShapeFactor := DutyShapeObj.GetMultAtHour(Hr);
ShapeIsActual := DutyShapeObj.UseActual;
end
else
CalcDailyMult(Hr); // Default to Daily Mult if no duty curve specified
end;
procedure TIndMach012Obj.CalcYearlyMult(Hr: Double);
begin
{Yearly curve is assumed to be hourly only}
if YearlyShapeObj <> NIL then
begin
ShapeFactor := YearlyShapeObj.GetMultAtHour(Hr);
ShapeIsActual := YearlyShapeObj.UseActual;
end
else
ShapeFactor := CDOUBLEONE; // Defaults to no variation
end;
procedure TIndMach012Obj.InitHarmonics;
{Procedure to initialize for Harmonics solution}
begin
YPrimInvalid := TRUE; // Force rebuild of YPrims
end;
procedure TIndMach012Obj.IntegrateStates;
{
This is a virtual function. You do not need to write this routine
if you are not integrating state variables in dynamics mode.
}
// Integrate state variables for Dynamics analysis
// Example from Generator
// Illustrates use of debug tracing
// Present technique is a predictor-corrector trapezoidal rule
var
TracePower: Complex;
begin
// Compute Derivatives and then integrate
ComputeIterminal;
with ActiveCircuit.Solution, MachineData do
begin
with DynaVars do
if (IterationFlag = 0) then
begin {First iteration of new time step}
ThetaHistory := Theta + 0.5 * h * dTheta;
SpeedHistory := Speed + 0.5 * h * dSpeed;
end;
// Compute shaft dynamics
TracePower := TerminalPowerIn(Vterminal, Iterminal, FnPhases); // in watts
dSpeed := (TracePower.re - Pshaft - abs(D * Speed)) / Mmass;
dTheta := Speed;
// Trapezoidal method
with DynaVars do
begin
Speed := SpeedHistory + 0.5 * h * dSpeed;
Theta := ThetaHistory + 0.5 * h * dTheta;
end;
if DebugTrace then
WriteTraceRecord;
Integrate;
end;
end;
procedure TIndMach012Obj.Get_DynamicModelCurrent;
begin
Is1 := (V1 - E1) / Zsp; // I = (V-E')/Z'
Is2 := (V2 - E2) / Zsp; // I = (V-E')/Z'
// rotor current Ir1= Is1-Vm/jXm
Ir1 := Is1 - (V1 - Is1 * Zsp) / Zm;
Ir2 := Is2 - (V2 - Is2 * Zsp) / Zm;
end;
procedure TIndMach012Obj.Get_PFlowModelCurrent(const V: Complex; const S: Double; var Istator, Irotor: Complex);
var
RL: Double;
ZRotor, Numerator, Zmotor: Complex;
begin
if s <> 0.0 then
RL := Zr.re * (1.0 - s) / s
else
RL := Zr.re * 1.0e6;
ZRotor := RL + Zr;
Numerator := Zm * Zrotor;
Zmotor := Zs + Numerator / (ZRotor + Zm);
Istator := V / Zmotor;
Irotor := Istator - (V - (Zs * Istator)) / Zm;
end;
function TIndMach012Obj.NumVariables: Integer;
{
Return the number of state variables
This is a virtual function. You do not need to write this routine
if you are not defining state variables.
Note: it is not necessary to define any state variables
}
begin
Result := NumIndMach012Variables;
end;
function TIndMach012Obj.VariableName(i: Integer): String;
{
Returns the i-th state variable in a string
This is a virtual function. You do not need to write this routine
if you are not defining state variables.
}
begin
if i < 1 then
Exit; // This means Someone goofed
case i of
1:
Result := 'Frequency';
2:
Result := 'Theta (deg)';
3:
Result := 'E1';
4:
Result := 'Pshaft';
5:
Result := 'dSpeed (deg/sec)';
6:
Result := 'dTheta (deg)';
7:
Result := 'Slip';
8:
Result := 'puRs';
9:
Result := 'puXs';
10:
Result := 'puRr';
11:
Result := 'puXr';
12:
Result := 'puXm';
13:
Result := 'Maxslip';
14:
Result := 'Is1';
15:
Result := 'Is2';
16:
Result := 'Ir1';
17:
Result := 'Ir2';
18:
Result := 'Stator Losses';
19:
Result := 'Rotor Losses';
20:
Result := 'Shaft Power (hp)';
21:
Result := 'Power Factor';
22:
Result := 'Efficiency (%)';
end;
end;
function TIndMach012Obj.Get_Variable(i: Integer): Double;
begin
Result := -9999.99; // Error Value
with MachineData do
case i of
1:
Result := (w0 + Speed) / TwoPi; // Frequency, Hz
2:
Result := (Theta) * RadiansToDegrees; // Report in Deg
3:
Result := Cabs(E1) / vbase; // Report in pu
4:
Result := Pshaft;
5:
Result := dSpeed * RadiansToDegrees; // Report in Deg 57.29577951
6:
Result := dTheta;
7:
Result := S1;
8:
Result := puRs;
9:
Result := puXs;
10:
Result := puRr;
11:
Result := puXr;
12:
Result := puXm;
13:
Result := MaxSlip;
14:
Result := Cabs(Is1);
15:
Result := Cabs(Is2);
16:
Result := Cabs(Ir1);
17:
Result := Cabs(Ir2);
18:
Result := GetStatorLosses;
19:
Result := GetRotorLosses;
20:
begin // Shaft Power (hp)
Result := 3.0 / 746.0 * (Sqr(Cabs(Ir1)) * (1.0 - S1) / S1 + Sqr(Cabs(Ir2)) * (1.0 - S2) / S2) * Zr.re;
end;
21:
Result := PowerFactor(Power[1]);
22:
Result := (1.0 - (GetStatorLosses + GetRotorLosses) / power[1].re) * 100.0; // Efficiency
end;
end;
procedure TIndMach012Obj.Set_Variable(i: Integer; Value: Double); // TODO: remove -- this is completely redundant with the properties but doesn't call RecalcElementData
begin
case i of
7:
begin
set_LocalSlip(Value);
PropertySideEffects(ord(TProp.slip));
end;
8:
puRs := Value;
9:
puXs := Value;
10:
puRr := Value;
11:
puXr := Value;
12:
puXm := Value;
end;
// Do Nothing for other variables: they are read only
end;
procedure TIndMach012Obj.GetAllVariables(States: pDoubleArray);
{
Return all state variables in double array (allocated by calling function)
This is a virtual function. You do not need to write this routine
if you are not defining state variables.
}
var
i: Integer;
begin
for i := 1 to NumIndMach012Variables do
States^[i] := Variable[i];
end;
function TIndMach012Obj.GetRotorLosses: Double;
begin
Result := 3.0 * (Sqr(Ir1.re) + Sqr(Ir1.im) + Sqr(Ir2.re) + Sqr(Ir2.im)) * Zr.re;
end;
function TIndMach012Obj.GetStatorLosses: Double;
begin
Result := 3.0 * (Sqr(Is1.re) + Sqr(Is1.im) + Sqr(Is2.re) + Sqr(Is2.im)) * Zs.re;
end;
procedure TIndMach012Obj.MakePosSequence();
begin
end;
procedure TIndMach012Obj.Set_ConductorClosed(Index: Integer; Value: Boolean);
// Routine for handling Open/Close procedures
begin
inherited;
if Value then
IndMach012SwitchOpen := FALSE
else
IndMach012SwitchOpen := TRUE;
end;
procedure TIndMach012Obj.set_Localslip(const Value: Double);
begin
S1 := Value;
if not InDynamics then
if Abs(S1) > MaxSlip then
begin
// Put limits on the slip unless dynamics
if S1 < 0 then
S1 := -MaxSlip
else
S1 := MaxSlip;
end;
S2 := 2.0 - S1;
end;
procedure TIndMach012Obj.InitTraceFile;
begin
FreeAndNil(TraceFile);
TraceFile := TBufferedFileStream.Create(DSS.OutputDirectory + Format('%s_IndMach012_Trace.csv', [Name]), fmCreate);
FSWrite(TraceFile, 'Time, Iteration, S1, |IS1|, |IS2|, |E1|, |dE1dt|, |E2|, |dE2dt|, |V1|, |V2|, Pshaft, Pin, Speed, dSpeed');
FSWriteln(TraceFile);
FSFlush(TraceFile);
end;
procedure TIndMach012Obj.WriteTraceRecord;
begin
with ActiveCircuit.Solution do
FSWrite(TraceFile, Format('%-.6g, %d, %-.6g, ', [Dynavars.dblHour * 3600.0, Iteration, S1]));
FSWrite(TraceFile, Format('%-.6g, %-.6g, ', [Cabs(Is1), Cabs(Is2)]));
FSWrite(TraceFile, Format('%-.6g, %-.6g, %-.6g, %-.6g, ', [Cabs(E1), Cabs(dE1dt), Cabs(E2), Cabs(dE2dt)]));
FSWrite(TraceFile, Format('%-.6g, %-.6g, ', [Cabs(V1), Cabs(V2)]));
FSWrite(TraceFile, Format('%-.6g, %-.6g, ', [MachineData.Pshaft, power[1].re]));
FSWrite(TraceFile, Format('%-.6g, %-.6g, ', [MachineData.speed, MachineData.dSpeed]));
FSWriteln(TraceFile);
FSFlush(TraceFile);
end;
finalization SlipOptionEnum.Free;
end.
| 30.764977 | 168 | 0.582727 |
fc9ae1ab3c89fecdc23d7a164bba32d84757e259 | 7,998 | pas | Pascal | Scripts/Delphiscript Scripts/PCB/Values Checker/PCBAPI functions.pas | spoilsport/Yazgac-Libraries | 276edeca757c524f7b6c04495d07bd41f6a2f691 | [
"MIT"
]
| null | null | null | Scripts/Delphiscript Scripts/PCB/Values Checker/PCBAPI functions.pas | spoilsport/Yazgac-Libraries | 276edeca757c524f7b6c04495d07bd41f6a2f691 | [
"MIT"
]
| null | null | null | Scripts/Delphiscript Scripts/PCB/Values Checker/PCBAPI functions.pas | spoilsport/Yazgac-Libraries | 276edeca757c524f7b6c04495d07bd41f6a2f691 | [
"MIT"
]
| null | null | null | {..............................................................................}
{ Summary This unit is used by the ValuesCheckerUnit unit. }
{ Copyright (c) 2004 by Altium Limited }
{..............................................................................}
{..............................................................................}
Procedure CheckArcRadii(ABoard : IPCB_Board; AList : TStringList);
Var
Arc : IPCB_Arc;
Iterator : IPCB_BoardIterator;
Begin
Iterator := ABoard.BoardIterator_Create;
Iterator.AddFilter_ObjectSet(MkSet(eArcObject));
Iterator.AddFilter_LayerSet(AllLayers);
Iterator.AddFilter_Method(eProcessAll);
// Search for pads with zero diameter
Arc := Iterator.FirstPCBObject;
While (Arc <> Nil) Do
Begin
If Arc.Radius = 0 Then
AList.Add(' An arc with zero radius found at ' +
IntToStr(CoordToMils(Arc.XCenter)) + 'mils' + ', ' +
IntToStr(CoordToMils(Arc.YCenter)) + 'mils');
Arc := Iterator.NextPCBObject;
End;
ABoard.BoardIterator_Destroy(Iterator);
End;
{..............................................................................}
{..............................................................................}
Procedure CheckPadDiameters(ABoard : IPCB_Board; AValue : Integer; AList : TStringList);
Var
Pad : IPCB_Pad;
Iterator : IPCB_BoardIterator;
Begin
Iterator := ABoard.BoardIterator_Create;
Iterator.AddFilter_ObjectSet(MkSet(ePadObject));
Iterator.AddFilter_LayerSet(AllLayers);
Iterator.AddFilter_Method(eProcessAll);
// Search for pads with specified holesize diameter
Pad := Iterator.FirstPCBObject;
While (Pad <> Nil) Do
Begin
// Assumption, only check TopX and TopY of Pad for 0 value
If Pad.HoleSize = AValue Then
AList.Add(' A pad with ' + IntToStr(AValue) + 'mils diameter found at ' +
IntToStr(CoordToMils(Pad.X)) + 'mils' + ', ' +
IntToStr(CoordToMils(Pad.Y)) + 'mils');
Pad := Iterator.NextPCBObject;
End;
ABoard.BoardIterator_Destroy(Iterator);
End;
{..............................................................................}
{..............................................................................}
Procedure CheckViaDiameters(ABoard : IPCB_Board; AValue : Integer; AList : TStringList);
Var
Via : IPCB_Via;
Iterator : IPCB_BoardIterator;
Begin
Iterator := ABoard.BoardIterator_Create;
Iterator.AddFilter_ObjectSet(MkSet(eViaObject));
Iterator.AddFilter_LayerSet(AllLayers);
Iterator.AddFilter_Method(eProcessAll);
// Search for vias with specified holesize diameter
Via := Iterator.FirstPCBObject;
While (Via <> Nil) Do
Begin
If Via.HoleSize = AValue Then
AList.Add(' A via with ' + IntToStr(AValue) + 'mils diameter found at ' +
IntToStr(CoordToMils(Via.X)) + 'mils' + ', ' +
IntToStr(CoordToMils(Via.Y)) + 'mils');
Via := Iterator.NextPCBObject;
End;
ABoard.BoardIterator_Destroy(Iterator);
End;
{..............................................................................}
{..............................................................................}
Procedure CheckNegativeValues(ABoard : IPCB_Board; AList : TStringList);
Var
Track : IPCB_Track;
Pad : IPCB_Pad;
Via : IPCB_Via;
Arc : IPCB_Arc;
Iterator : IPCB_BoardIterator;
Begin
// Search for tracks with negative locations
Iterator := ABoard.BoardIterator_Create;
Iterator.AddFilter_ObjectSet(MkSet(eTrackObject));
Iterator.AddFilter_LayerSet(AllLayers);
Iterator.AddFilter_Method(eProcessAll);
Track := Iterator.FirstPCBObject;
While (Track <> Nil) Do
Begin
If (Track.x1 < 0) or
(Track.y1 < 0) or
(Track.x2 < 0) or
(Track.y2 < 0) Then
AList.Add(' A track found with negative boundaries at ' +
IntToStr(CoordToMils(Track.X1)) + 'mils' + ', ' +
IntToStr(CoordToMils(Track.Y1)) + 'mils' + ', ' +
IntToStr(CoordToMils(Track.X2)) + 'mils' + ', ' +
IntToStr(CoordToMils(Track.Y2)) + 'mils');
Track := Iterator.NextPCBObject;
End;
ABoard.BoardIterator_Destroy(Iterator);
// Search for pads with negative locations
Iterator := ABoard.BoardIterator_Create;
Iterator.AddFilter_ObjectSet(MkSet(ePadObject));
Iterator.AddFilter_LayerSet(AllLayers);
Iterator.AddFilter_Method(eProcessAll);
Pad := Iterator.FirstPCBObject;
While (Pad <> Nil) Do
Begin
If (Pad.x < 0) or
(Pad.y < 0) Then
AList.Add(' A pad found with negative boundaries at ' +
IntToStr(CoordToMils(Pad.X)) + 'mils' + ', ' +
IntToStr(CoordToMils(Pad.Y)) + 'mils');
Pad := Iterator.NextPCBObject;
End;
ABoard.BoardIterator_Destroy(Iterator);
// Search for vias with negative locations
Iterator := ABoard.BoardIterator_Create;
Iterator.AddFilter_ObjectSet(MkSet(eViaObject));
Iterator.AddFilter_LayerSet(AllLayers);
Iterator.AddFilter_Method(eProcessAll);
Via := Iterator.FirstPCBObject;
While (Via <> Nil) Do
Begin
If (Via.x < 0) or
(Via.y < 0) Then
AList.Add(' A via found with negative boundaries at ' +
IntToStr(CoordToMils(Via.X)) + 'mils' + ', ' +
IntToStr(CoordToMils(Via.Y)) + 'mils' + ', ');
Via := Iterator.NextPCBObject;
End;
ABoard.BoardIterator_Destroy(Iterator);
// Search for arcs with negative locations
Iterator := ABoard.BoardIterator_Create;
Iterator.AddFilter_ObjectSet(MkSet(eArcObject));
Iterator.AddFilter_LayerSet(AllLayers);
Iterator.AddFilter_Method(eProcessAll);
Arc := Iterator.FirstPCBObject;
While (Arc <> Nil) Do
Begin
If (Arc.XCenter < 0) or
(Arc.YCenter < 0) Then
AList.Add(' An arc found with negative boundaries at ' +
IntToStr(CoordToMils(Arc.XCenter)) + 'mils' + ', ' +
IntToStr(CoordToMils(Arc.YCenter)) + 'mils' + ', ');
Arc := Iterator.NextPCBObject;
End;
ABoard.BoardIterator_Destroy(Iterator);
End;
{..............................................................................}
{..............................................................................}
Procedure OutputErrorReport(ABoard : IPCB_Board; AList : TStringList);
Var
S : TDynamicString;
ReportDocument : IServerDocument;
Begin
If AList.Count > 0 Then
Begin
AList.Insert(0,'Object Bad Property Values for this PCB,');
AList.Insert(1, ExtractFileName(ABoard.FileName));
AList.Insert(2,'________________________________________');
AList.Insert(3,'');
// Generate a text file with bad values of PCB objects found
// using PCB board file name but with _BadValues added and
// file extension changed to RPT.
S := ChangeFileExt(ABoard.FileName,'.RPT');
AList.SaveToFile(S);
// Open the text file in DXP.
ReportDocument := Client.OpenDocument('Text', S);
If ReportDocument <> Nil Then
Client.ShowDocument(ReportDocument);
End;
End;
{..............................................................................}
{..............................................................................}
| 39.594059 | 89 | 0.515754 |
c3ca3fef662c805c974a2b615973d52cea02c236 | 1,763 | pas | Pascal | JAToyTank.pas | alb42/Jade-Engine | 7507e9c0fe543b2c049699720b3f61e62612adfc | [
"CC0-1.0"
]
| 1 | 2021-02-28T13:29:23.000Z | 2021-02-28T13:29:23.000Z | JAToyTank.pas | alb42/Jade-Engine | 7507e9c0fe543b2c049699720b3f61e62612adfc | [
"CC0-1.0"
]
| null | null | null | JAToyTank.pas | alb42/Jade-Engine | 7507e9c0fe543b2c049699720b3f61e62612adfc | [
"CC0-1.0"
]
| null | null | null | unit JAToyTank;
{$mode objfpc}{$H+}
{$i JA.inc}
interface
uses
JATypes, JAPolygon, JAPolygonTools, JASketch, JASketchTools,
JANode, JAScene, JAToy;
type
TJAToyTank = record
BodyNode : PJANode;
TurretNode : PJANode;
BarrelNode : PJANode;
BarrelTipNode : PJANode;
Scene : PJAScene;
Parent : PJANode;
end;
PJAToyTank = ^TJAToyTank;
function JAToyTankCreate(AScene : PJAScene; AParentNode : PJANode) : PJAToyTank;
function JAToyTankDestroy(AToyTank : PJAToyTank) : boolean;
implementation
function JAToyTankCreate(AScene : PJAScene; AParentNode : PJANode) : PJAToyTank;
var
Polygon : PJAPolygon;
begin
Result := JAMemGet(SizeOf(TJAToyTank));
with Result^ do
begin
Scene := AScene; {store local reference}
Parent := AParentNode;
BodyNode := JANodeNodeCreate(AParentNode, JANode_Sketch);
Polygon := JASketchPolygonCreate(PJANodeDataSketch(BodyNode^.Data)^.Sketch);
JAPolygonMakeRect(Polygon, JRect(-30,-55,30,55));
Polygon^.Style.PenIndex := 5;
//JAPolygonMakeSpaceShip(Polygon, 50);
TurretNode := JANodeNodeCreate(BodyNode, JANode_Sketch);
Polygon := JASketchPolygonCreate(PJANodeDataSketch(TurretNode^.Data)^.Sketch);
JAPolygonMakeCircle(Polygon,vec2(0,0),30,9);
Polygon^.Style.PenIndex := 5;
BarrelNode := JANodeNodeCreate(TurretNode, JANode_Sketch);
Polygon := JASketchPolygonCreate(PJANodeDataSketch(BarrelNode^.Data)^.Sketch);
JAPolygonMakeRect(Polygon, JRect(-2,0,2,70));
Polygon^.Style.PenIndex := 5;
end;
end;
function JAToyTankDestroy(AToyTank : PJAToyTank) : boolean;
begin
JAMemFree(AToyTank,SizeOf(TJAToyTank));
end;
end.
| 27.984127 | 85 | 0.679524 |
4782a531ce2927d8416989989e53f68942060393 | 3,202 | pas | Pascal | me/kod/expandpanels/developement test project/unit1_onepanel.pas | dalfy15/VizSzz | 7787f5fd45f02983266710227c02d45860ce6a3f | [
"MIT"
]
| null | null | null | me/kod/expandpanels/developement test project/unit1_onepanel.pas | dalfy15/VizSzz | 7787f5fd45f02983266710227c02d45860ce6a3f | [
"MIT"
]
| null | null | null | me/kod/expandpanels/developement test project/unit1_onepanel.pas | dalfy15/VizSzz | 7787f5fd45f02983266710227c02d45860ce6a3f | [
"MIT"
]
| null | null | null | unit unit1_onepanel;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics,
ExtCtrls, StdCtrls, Buttons, Spin, ExpandPanels, StrUtils;
type
{ TForm1 }
TForm1 = class(TForm)
cbRounded: TCheckBox;
cbFlat: TCheckBox;
cbBorders: TComboBox;
Edit1: TEdit;
Edit2: TEdit;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
p1: TMyRollOut;
RGlyph: TRadioGroup;
RCapt: TRadioGroup;
RColl: TRadioGroup;
RButt: TRadioGroup;
RGlyphKind: TRadioGroup;
RStyle: TComboBox;
SpeedButton1: TSpeedButton;
edTabWidth: TSpinEdit;
edButtonSize: TSpinEdit;
procedure cbFlatClick(Sender: TObject);
procedure cbRoundedClick(Sender: TObject);
procedure cbBordersChange(Sender: TObject);
procedure edButtonSizeChange(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure edTabWidthChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure RGlyphClick(Sender: TObject);
procedure RCaptClick(Sender: TObject);
procedure RButtClick(Sender: TObject);
procedure RCollClick(Sender: TObject);
procedure RGlyphKindClick(Sender: TObject);
procedure RStyleChange(Sender: TObject);
procedure RDirectionClick(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.Edit1Change(Sender: TObject);
begin
p1.Button.Caption := Edit1.Text;
end;
procedure TForm1.cbRoundedClick(Sender: TObject);
begin
p1.BevelRounded:=cbRounded.Checked;
end;
procedure TForm1.cbBordersChange(Sender: TObject);
begin
p1.BevelOuter:=TBevelcut(cbBorders.ItemIndex);
end;
procedure TForm1.edButtonSizeChange(Sender: TObject);
begin
p1.ButtonSize:=edButtonSize.Value;
end;
procedure TForm1.cbFlatClick(Sender: TObject);
begin
p1.Button.Flat:=cbFlat.Checked;
end;
procedure TForm1.edTabWidthChange(Sender: TObject);
begin
p1.Button.TabWidth:=edTabWidth.Value;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
edButtonSize.Value:=p1.ButtonSize;
edTabWidth.Value:=p1.Button.TabWidth;
end;
procedure TForm1.RGlyphClick(Sender: TObject);
begin
p1.Button.GlyphLayout:=TGlyphLayout(RGlyph.ItemIndex);
end;
procedure TForm1.RCaptClick(Sender: TObject);
begin
p1.Button.TextLayout:=TTextLayout(RCapt.ItemIndex);
end;
procedure TForm1.RButtClick(Sender: TObject);
begin
p1.ButtonPosition := TAnchorKind(RButt.ItemIndex);
end;
procedure TForm1.RCollClick(Sender: TObject);
begin
p1.CollapseKind := TAnchorKind(RColl.ItemIndex);
end;
procedure TForm1.RGlyphKindClick(Sender: TObject);
begin
p1.Button.GlyphKind:=TGlyphKind(RGlyphKind.ItemIndex);
end;
procedure TForm1.RStyleChange(Sender: TObject);
begin
p1.Button.Style:=TBoundButtonStyle(RStyle.ItemIndex);
end;
procedure TForm1.RDirectionClick(Sender: TObject);
begin
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
p1.Button.Caption := DupeString(Edit1.Caption, 10);
end;
initialization
{$I unit1_onepanel.lrs}
end.
| 22.082759 | 69 | 0.748907 |
c39bd34722135f05335c8eee7f1b27d95ba5a85c | 8,932 | pas | Pascal | Source/DUnitX.TestResult.pas | nandod/DUnitX | adcc1b13b6e5e226ad45eba27b6e70a3bf6ba902 | [
"Apache-2.0"
]
| 282 | 2015-01-16T04:59:48.000Z | 2022-03-31T01:33:36.000Z | Source/DUnitX.TestResult.pas | nandod/DUnitX | adcc1b13b6e5e226ad45eba27b6e70a3bf6ba902 | [
"Apache-2.0"
]
| 179 | 2015-01-05T23:43:12.000Z | 2022-02-22T22:38:42.000Z | Source/DUnitX.TestResult.pas | nandod/DUnitX | adcc1b13b6e5e226ad45eba27b6e70a3bf6ba902 | [
"Apache-2.0"
]
| 178 | 2015-01-06T11:25:14.000Z | 2022-03-30T00:31:10.000Z | {***************************************************************************}
{ }
{ DUnitX }
{ }
{ Copyright (C) 2015 Vincent Parrett & Contributors }
{ }
{ vincent@finalbuilder.com }
{ http://www.finalbuilder.com }
{ }
{ }
{***************************************************************************}
{ }
{ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 }
{ }
{ Unless required by applicable law or agreed to in writing, software }
{ distributed under the License is distributed on an "AS IS" BASIS, }
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{ See the License for the specific language governing permissions and }
{ limitations under the License. }
{ }
{***************************************************************************}
unit DUnitX.TestResult;
interface
{$I DUnitX.inc}
uses
{$IFDEF USE_NS}
System.SysUtils,
System.Timespan,
{$ELSE}
SysUtils,
Timespan,
{$ENDIF}
DUnitX.TestFramework,
DUnitX.WeakReference,
DUnitX.InternalInterfaces,
DUnitX.ComparableFormat,
DUnitX.Exceptions;
type
TDUnitXTestResult = class(TInterfacedObject, ITestResult)
private
//Keeping message as the user passed message. Not used for internal functionality like exception messages.
FMessage : string;
FLogMessages: TLogMessageArray;
FResultType : TTestResultType;
FTest : IWeakReference<ITestInfo>;
FStackTrace : string;
protected
function GetMessage: string;
function GetLogMessages: TLogMessageArray;
function GetResult: Boolean;
function GetResultType: TTestResultType;
function GetTest: ITestInfo;
function GetStartTime : TDateTime;
function GetFinishTime : TDateTime;
function GetDuration : TTimeSpan;
function GetStackTrace : string;
public
constructor Create(const ATestInfo : ITestInfo; const AType : TTestResultType; const AMessage: string; const ALogMessages : TLogMessageArray); overload;
constructor Create(const ATestInfo : ITestInfo; const AType : TTestResultType; const AMessage: string = ''); overload;
destructor Destroy;override;
end;
TDUnitXTestError = class(TDUnitXTestResult, ITestError)
private
FExceptionClass : ExceptClass;
FExceptionMessage : string;
FExceptionAddress : Pointer;
FIsComparable: boolean;
FExpected: string;
FActual: string;
FFormat: TDUnitXComparableFormatClass;
protected
function GetExceptionClass : ExceptClass;
function GetExceptionLocationInfo : string;
function GetExceptionAddressInfo : string;
function GetExceptionMessage : string;
function GetExceptionAddress : Pointer;
function GetIsComparable: boolean;
function GetExpected: string;
function GetActual: string;
function GetFormat: TDUnitXComparableFormatClass;
public
constructor Create(const ATestInfo : ITestInfo; const AType: TTestResultType; const AThrownException: Exception; const Addrs: Pointer; const AMessage: string; const AMessageExList : TLogMessageArray); reintroduce;
end;
implementation
uses
DUnitX.IoC;
constructor TDUnitXTestResult.Create(const ATestInfo : ITestInfo; const AType : TTestResultType; const AMessage: string; const ALogMessages : TLogMessageArray);
begin
FTest := TWeakReference<ITestInfo>.Create(ATestInfo);
FResultType := AType;
FMessage := AMessage;
FLogMessages := ALogMessages;
end;
function TDUnitXTestResult.GetMessage: string;
begin
result := FMessage;
end;
function TDUnitXTestResult.GetLogMessages: TLogMessageArray;
begin
result := FLogMessages;
end;
function TDUnitXTestResult.GetResult: Boolean;
begin
result := GetResultType = TTestResultType.Pass;
end;
function TDUnitXTestResult.GetResultType: TTestResultType;
begin
result := FResultType;
end;
function TDUnitXTestResult.GetTest: ITestInfo;
begin
if FTest.IsAlive then
result := FTest.Data
else
result := nil;
end;
constructor TDUnitXTestResult.Create(const ATestInfo: ITestInfo; const AType: TTestResultType; const AMessage: string);
var
LogMessages: TLogMessageArray;
begin
SetLength(LogMessages, 0);
Create(ATestInfo, AType, AMessage, LogMessages);
end;
destructor TDUnitXTestResult.Destroy;
begin
FTest := nil; //trying to track down memory leak.
inherited;
end;
function TDUnitXTestResult.GetDuration: TTimeSpan;
begin
if FTest.IsAlive then
Result := FTest.Data.GetTestDuration
else
Result := TTimeSpan.Zero;
end;
function TDUnitXTestResult.GetFinishTime: TDateTime;
begin
if FTest.IsAlive then
Result := FTest.Data.GetTestEndTime
else
Result := 0;
end;
function TDUnitXTestResult.GetStackTrace: string;
begin
result := FStackTrace;
end;
function TDUnitXTestResult.GetStartTime: TDateTime;
begin
if FTest.IsAlive then
Result := FTest.Data.GetTestStartTime
else
Result := 0;
end;
{ TDUnitXTestError }
constructor TDUnitXTestError.Create(const ATestInfo : ITestInfo; const AType: TTestResultType; const AThrownException: Exception; const Addrs: Pointer; const AMessage: string; const AMessageExList : TLogMessageArray);
{$IFDEF DELPHI_XE_UP}
var
stackTraceProvider : IStacktraceProvider;
{$ENDIF}
var
StrCompareEx: ETestFailureStrCompare;
begin
inherited Create(ATestInfo, AType, AMessage, AMessageExList);
FExceptionClass := ExceptClass(AThrownException.ClassType);
FExceptionMessage := FMessage;
if FMessage <> AThrownException.Message then
FExceptionMessage := FExceptionMessage + AThrownException.Message;
FExceptionAddress := Addrs;
if FExceptionClass = ETestFailureStrCompare then
begin
StrCompareEx := AThrownException as ETestFailureStrCompare;
FIsComparable := True;
FExpected := StrCompareEx.Expected;
FActual := StrCompareEx.Actual;
FFormat := StrCompareEx.Format;
end
else FIsComparable := False;
{$IFDEF DELPHI_XE_UP}
stackTraceProvider := TDUnitXIoC.DefaultContainer.Resolve<IStacktraceProvider>();
if stackTraceProvider <> nil then
FStackTrace := stackTraceProvider.GetStackTrace(AThrownException,Addrs);
{$ENDIF}
end;
function TDUnitXTestError.GetActual: string;
begin
Result := FActual;
end;
function TDUnitXTestError.GetExceptionAddress: Pointer;
begin
Result := FExceptionAddress;
end;
function TDUnitXTestError.GetExceptionAddressInfo: string;
{$IFDEF DELPHI_XE_UP}
var
stackTraceProvider : IStacktraceProvider;
{$ENDIF}
begin
{$IFDEF DELPHI_XE_UP}
stackTraceProvider := TDUnitXIoc.DefaultContainer.Resolve<IStacktraceProvider>();
if stackTraceProvider <> nil then
Result := stackTraceProvider.PointerToAddressInfo(FExceptionAddress)
else
{$ENDIF}
Result := '';
end;
function TDUnitXTestError.GetExceptionClass: ExceptClass;
begin
result := FExceptionClass;
end;
function TDUnitXTestError.GetExceptionLocationInfo: string;
{$IFDEF DELPHI_XE_UP}
var
stackTraceProvider : IStacktraceProvider;
{$ENDIF}
begin
{$IFDEF DELPHI_XE_UP}
stackTraceProvider := TDUnitXIoc.DefaultContainer.Resolve<IStacktraceProvider>();
if stackTraceProvider <> nil then
Result := stackTraceProvider.PointerToLocationInfo(FExceptionAddress)
else
{$ENDIF}
Result := '';
end;
function TDUnitXTestError.GetExceptionMessage: string;
begin
Result := FExceptionMessage;
end;
function TDUnitXTestError.GetExpected: string;
begin
Result := FExpected;
end;
function TDUnitXTestError.GetFormat: TDUnitXComparableFormatClass;
begin
Result := FFormat;
end;
function TDUnitXTestError.GetIsComparable: boolean;
begin
Result := FIsComparable;
end;
end.
| 31.673759 | 219 | 0.63614 |
fc15c141ecb18d25fd10646546f09eb3ea33188e | 2,275 | dfm | Pascal | samples/SafeLoggerTester/ufrmMain.dfm | Stoby/diocp-v5 | 7d10768e5deadba5fee3b330f3ea05e9913012a1 | [
"BSD-2-Clause"
]
| 229 | 2015-02-25T14:32:37.000Z | 2022-03-29T13:54:06.000Z | samples/SafeLoggerTester/ufrmMain.dfm | Stoby/diocp-v5 | 7d10768e5deadba5fee3b330f3ea05e9913012a1 | [
"BSD-2-Clause"
]
| 3 | 2016-12-30T15:08:57.000Z | 2019-08-15T02:06:11.000Z | samples/SafeLoggerTester/ufrmMain.dfm | Stoby/diocp-v5 | 7d10768e5deadba5fee3b330f3ea05e9913012a1 | [
"BSD-2-Clause"
]
| 127 | 2015-02-23T16:29:52.000Z | 2022-02-23T01:10:31.000Z | object frmMain: TfrmMain
Left = 0
Top = 0
Caption = 'frmMain'
ClientHeight = 379
ClientWidth = 636
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object PageControl1: TPageControl
Left = 0
Top = 0
Width = 636
Height = 177
ActivePage = TabSheet1
Align = alTop
TabOrder = 0
object TabSheet1: TTabSheet
Caption = #21387#21147#27979#35797
object Label1: TLabel
Left = 24
Top = 5
Width = 264
Height = 13
Caption = #32447#31243#25968'/'#36816#34892#27425#25968'('#27599#20010#32447#31243')/'#20241#24687#38388#38548'('#36127#25968#19981#20241#24687')'
end
object btnStart: TButton
Left = 310
Top = 22
Width = 75
Height = 25
Caption = 'btnStart'
TabOrder = 0
OnClick = btnStartClick
end
object edtThreadNum: TEdit
Left = 24
Top = 24
Width = 57
Height = 21
TabOrder = 1
Text = '10'
end
object btnThreadInfo: TButton
Left = 24
Top = 122
Width = 75
Height = 25
Caption = #32447#31243#20449#24687
TabOrder = 2
OnClick = btnThreadInfoClick
end
object rgAppender: TRadioGroup
Left = 8
Top = 64
Width = 377
Height = 46
Caption = 'rgAppender'
Columns = 3
ItemIndex = 0
Items.Strings = (
#31354'Appender'
'SingleFileLogger')
TabOrder = 3
end
object edtPerNum: TEdit
Left = 87
Top = 24
Width = 66
Height = 21
TabOrder = 4
Text = '100000'
end
object edtSleep: TEdit
Left = 160
Top = 24
Width = 81
Height = 21
TabOrder = 5
Text = '-1'
end
end
object TabSheet2: TTabSheet
Caption = 'TabSheet2'
ImageIndex = 1
end
end
object mmoInfo: TMemo
Left = 0
Top = 177
Width = 636
Height = 202
Align = alClient
Lines.Strings = (
'mmoInfo')
TabOrder = 1
end
end
| 21.666667 | 154 | 0.535385 |
fcc3f86cb98bb1b0a49cb0f718d11f16f421cc78 | 1,914 | lpr | Pascal | Samples/FreePascal/SingleBoard/RaspberryPI/Blinky/Blinky.lpr | LongDirtyAnimAlf/AsphyrePXL | 9151ff88eca1fa01dce083b09e7ea20076f6d334 | [
"Apache-2.0"
]
| 4 | 2020-04-24T07:43:43.000Z | 2021-08-29T08:36:08.000Z | Samples/FreePascal/SingleBoard/RaspberryPI/Blinky/Blinky.lpr | LongDirtyAnimAlf/AsphyrePXL | 9151ff88eca1fa01dce083b09e7ea20076f6d334 | [
"Apache-2.0"
]
| null | null | null | Samples/FreePascal/SingleBoard/RaspberryPI/Blinky/Blinky.lpr | LongDirtyAnimAlf/AsphyrePXL | 9151ff88eca1fa01dce083b09e7ea20076f6d334 | [
"Apache-2.0"
]
| 2 | 2020-08-18T09:42:33.000Z | 2021-04-22T08:15:27.000Z | program Blinky;
(*
* This file is part of Asphyre Framework, also known as Platform eXtended Library (PXL).
* Copyright (c) 2015 - 2017 Yuriy Kotsarenko. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*)
{
This example illustrates a simple use of GPIO on Raspberry PI to blink a LED.
Make sure to connect the LED to RPi pin #16 (BCM 23), please take a look at the accompanying diagram and photo.
}
uses
Crt, PXL.Boards.Types, PXL.Boards.RPi;
const
PinLED = 16;
var
SystemCore: TFastSystemCore = nil;
GPIO: TFastGPIO = nil;
TurnedOn: Boolean = False;
begin
SystemCore := TFastSystemCore.Create;
try
GPIO := TFastGPIO.Create(SystemCore);
try
// Switch LED pin for output.
GPIO.PinMode[PinLED] := TPinMode.Output;
WriteLn('Blinking LED, press any key to exit...');
while not KeyPressed do
begin
TurnedOn := not TurnedOn;
if TurnedOn then
GPIO.PinValue[PinLED] := TPinValue.High
else
GPIO.PinValue[PinLED] := TPinValue.Low;
SystemCore.Delay(500000); // wait for 500 ms
end;
// Eat the key pressed so it won't go to terminal after we exit.
ReadKey;
// Turn the LED off after we are done and switch it to "Input" just to be safe.
GPIO.PinMode[PinLED] := TPinMode.Input;
finally
GPIO.Free;
end;
finally
SystemCore.Free;
end;
end.
| 29.90625 | 113 | 0.684953 |
fcb5b2dc64e7d275ca11f53d5f5e501ffed2646b | 12,445 | dfm | Pascal | Unt00101.dfm | SaferProg1/TRF000 | 422ad71bc7424a02c96946f443a29491c77f17ca | [
"Unlicense"
]
| null | null | null | Unt00101.dfm | SaferProg1/TRF000 | 422ad71bc7424a02c96946f443a29491c77f17ca | [
"Unlicense"
]
| null | null | null | Unt00101.dfm | SaferProg1/TRF000 | 422ad71bc7424a02c96946f443a29491c77f17ca | [
"Unlicense"
]
| null | null | null | object frm00101: Tfrm00101
Left = 318
Top = 302
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = 'frm00101'
ClientHeight = 334
ClientWidth = 432
Color = clBtnFace
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Verdana'
Font.Style = []
KeyPreview = True
OldCreateOrder = False
Position = poScreenCenter
OnClose = FormClose
OnCreate = FormCreate
OnKeyPress = FormKeyPress
OnResize = FormResize
PixelsPerInch = 96
TextHeight = 13
object Image1: TImage
Left = 0
Top = 0
Width = 432
Height = 75
Align = alTop
ExplicitWidth = 464
end
object RzPanel1: TRzPanel
Left = 0
Top = 75
Width = 432
Height = 232
Align = alClient
BorderOuter = fsNone
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Verdana'
Font.Style = []
GradientDirection = gdHorizontalCenter
ParentFont = False
TabOrder = 0
VisualStyle = vsGradient
object Label1: TLabel
Left = 9
Top = 13
Width = 40
Height = 13
Caption = 'Codigo'
FocusControl = DBEdit1
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Verdana'
Font.Style = []
ParentFont = False
Transparent = True
end
object Label2: TLabel
Left = 75
Top = 14
Width = 82
Height = 13
Caption = 'Departamento'
FocusControl = DBEdit2
Transparent = True
end
object DBEdit1: TDBEdit
Left = 8
Top = 29
Width = 65
Height = 21
CharCase = ecUpperCase
Ctl3D = True
DataField = 'CODEPTO'
DataSource = frm00100.DS_DEPTO
ParentCtl3D = False
TabOrder = 0
end
object DBEdit2: TDBEdit
Left = 75
Top = 29
Width = 344
Height = 21
CharCase = ecUpperCase
Ctl3D = True
DataField = 'DEPARTAMENTO'
DataSource = frm00100.DS_DEPTO
ParentCtl3D = False
TabOrder = 1
end
object RzDBRadioGroup1: TRzDBRadioGroup
Left = 8
Top = 72
Width = 177
Height = 81
DataField = 'TIPO'
DataSource = frm00100.DS_DEPTO
Items.Strings = (
'Prod. Revenda/M.P./Acab.'
'Prod. Imobilizado'
'Outros')
Values.Strings = (
'R'
'I'
'O')
Caption = 'Tipo de Estoque'
ItemFrameColor = 8409372
ItemHighlightColor = 2203937
ItemHotTrack = True
TabOrder = 2
TabStop = True
Transparent = True
end
object RzDBRadioGroup2: TRzDBRadioGroup
Left = 191
Top = 72
Width = 228
Height = 137
DataField = 'TIPOPROD'
DataSource = frm00100.DS_DEPTO
Items.Strings = (
'Acabado'
'Servi'#231'o'
'SubProduto'
'Embalagem'
'Mat'#233'ria Prima'
'Em Processo'
'Intermedi'#225'rio'
'Uso e Consumo'
'At. Imobilizado'
'Merc. P/ Revenda'
'Outros Insumos'
'Outras')
Values.Strings = (
'PA'
'SE'
'SP'
'EM'
'MP'
'EP'
'PI'
'UC'
'AI'
'MR'
'OI'
'OT')
Caption = 'Tipo de Produto'
Columns = 2
ItemFrameColor = 8409372
ItemHighlightColor = 2203937
ItemHotTrack = True
TabOrder = 3
TabStop = True
Transparent = True
end
end
object RzPanel2: TRzPanel
Left = 0
Top = 307
Width = 432
Height = 27
Align = alBottom
BorderOuter = fsNone
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
GradientDirection = gdHorizontalCenter
ParentFont = False
TabOrder = 1
VisualStyle = vsGradient
object RFBexcluirDepto: TRzRapidFireButton
Left = 556
Top = 3
Width = 100
Height = 24
Caption = ' Excluir'
Flat = True
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Verdana'
Font.Style = []
ParentFont = False
end
object Image5: TImage
Left = 561
Top = 6
Width = 18
Height = 18
AutoSize = True
Center = True
Picture.Data = {
0954506E67496D61676589504E470D0A1A0A0000000D49484452000000120000
0012080600000056CE8E57000000017352474200AECE1CE90000000467414D41
0000B18F0BFC6105000000097048597300000EC300000EC301C76FA864000003
6B4944415478DA7D934B6C1B4518C7FF33DEB563AF1F59BB0EB69B1837117938
AA142AB7AA42102A08544225D40B677A214A7B01C42114890A0924A080145420
A8EA014E1C0021403D94882045495415D2409BB44925B77938268E49FC58BF76
BD3BCC3A69153969BFDD39ECCC7F7FF3FDBF998FE06131F49BF770133B20DB0C
ABF9B95A22959BF1EC3CBE7CA5B0979CD44F78CF5D09C65A3D673C9274D26115
A22EA9018CCFE7F245A3A2EBD31B4AF1FBD1E9D5110C9FCC3E1414FB7CF4786B
D07FE1F1704B9B4FB241160C3458B624651DC8E814C9AC8295E595BF6F2DA706
67DF3A3EB50BD4C321DDE1C00F4DA11647C8C6D02C51480285B0ADA832064563
582C18486B1489C5786A7A69B37FE1CD637F3D00C91F5EDEFF4CB36F2AD4D6D1
E2137444240B444A60F035B6634773A806C33D0ECBF1ECEEDD9E9DF965963D8D
F37D4A0D74ECEBB1F7DB3AA2EFD8440B5AEC04820961D81D5C6DD98625CA40A1
50C2FC9DF9C1C9D3CF8D107C3A299FF0614A8EB477B888063787E984602F4E2D
B84581AF6634037943C0FADD5BE357FE49BE40BADFFB2E16693D7055F43E46DD
7C3BCA7454942C98AE831052C76010ED12043E3483DBAB52A86B4BCAFCC25C94
F4BDFD55AFA7EBC989BCAD916743905714BC7BB80987F63772277520FE8C258A
189E4943122907113833CBFADAECF57672F4F58F7B3DDD47269216376CC44059
ADE2EC5311F404DC7B3A1B5BDCC0853F1370F012A8A0F02BABFAC68DA976D236
74F1507320782D2934D28AAAC1C20BADF1621A6CEF2A516E57DCD6381BACF097
53B93B7797A204E72EBBFAC4CC44DA153C184FE760B5D09A8547C5D635003A9B
DC706EAE8C4EA6E4976A45383874F1AC2710FAE06AAA08ADACF16DF1E8E0D938
1C76C4640BD2C9B557E73E79ED9BAD6A9EBAB4EF68401D2FCBC1CE9944860B79
3F982756DF896C0B424511B190076C7D69FCDABFDDCFE3DB672B0FA4FE81CF7A
9FF0DA7E2E39FDBEDBEB0A4AA50A07B11D5DC46AAF53B2A3CB2F816653F1B912
7D313F7C7A6157D3FA06CFC72292F50B51721D496B04997215457E8AE67D328F
5BB65BE1B5545129E4466F14C8196DE48D85FAA635AB62DE7E0D3DFDE1705774
40961BFB055DEB84AE0AA64D26D8549DD09BA9FF367F4CFEF1D325ACC5D35C2F
F0A19BE9EECCE83ECC5C3070EA23A773FA779FB798A0253E91F5857575DFCBEB
F875A0B4AD23F721E6CFFF0355846368FEB005ED0000000049454E44AE426082}
end
object RFBvoltar: TRzRapidFireButton
Left = 319
Top = 1
Width = 100
Height = 24
Caption = ' Voltar'
Flat = True
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Verdana'
Font.Style = []
ParentFont = False
OnClick = RFBvoltarClick
end
object Image6: TImage
Left = 329
Top = 4
Width = 18
Height = 18
AutoSize = True
Center = True
Picture.Data = {
0954506E67496D61676589504E470D0A1A0A0000000D49484452000000120000
0012080600000056CE8E57000000017352474200AECE1CE90000000467414D41
0000B18F0BFC6105000000097048597300000EC300000EC301C76FA864000002
D64944415478DAD5D44B4854511807F0FF9D6BE3340F1D1B6D2CD3C45127EDA1
A43DAEA9581466508B9995E146A8A848E8B109A524850A520AB222A84D519A15
8489AB28549CCC5C683A56504D8D358AE36B1CE771EFB98F8E0A81D1A2858B3A
F07136E7FC38DFC7F71D064BB498FF083ADE6ADE9461D861D148B1608161A21E
EF7DEF77E05AC9E8DF41F6479A1DC56BCEE426441F498D3725C59B62C0D05393
337E8C4FCDB8DF7926EF373DE8BF8CE78766174107EE766418F4DA9A2E4FB8EA
EBA9FA4FB6C6CAC77BB3D26C29260324912020480889327819502D5343AD48E8
F9E07A75AD6BA40C17777B7E413B1B5A0BF61414764C7C77F70D8D4C7C2ECDCF
B2472D8FA400011115042519410A058882191A50A99011AB47BF73A8ED7A5D9F
0D9DE5FC3C5450DBC85972721D8516330C320F8955C3C7130892820085024442
90022199A244C6342F41C5B2E0CC1ABCE977563D292FBA380F7155B7B9D49CED
8EDC94D548D4B1704D87119ABB4C9159BA139901A1A514686A027D9D2F2CC0ED
E36131E9902A7A271EBEE8DD3C7AF3849BC9AEA8E336E6E53BD2925643914404
694DE65E31173423487C1063A39E1185E7BF282C1BA3D1476712AD1183530425
6BA330EEFA58DD72D256C3AC3F5CCD6572458E55ABCC10894881052C4C536143
7E79F89BFBDE4048532BD4957E41F91D7D6A92B63841A39C23067396DE6844AC
7F64F0E18596AD4C7AD969CEBA7DA743B7622504225044849F1761D4464233F5
437AFAD69587A6CA9EC53DD660CE898A685E93662DD412BFDCEE74E531E9F663
5CE2B65D0E5E1B0D89105A9F05485214ECB3C623E01D1D68FB3C7ED07BF5E8E0
22ACEC4ADCE604DDCB2CAB6583D3E3AD6692ED87F2E3ADB99DCB7486F91A4934
25914698827AAD065B92CDE8E9EE7EDD7DE37CDEEFBDAB2EAF2FDCBF2EAEDDEB
197EC624959E3532FC14C7F2F3ED003662E150049D8BA028200C350CBAC8D94F
CD373BFF341AD915976EA97C63CA520D2DF3EF7D233F014880594C8FE3E64400
00000049454E44AE426082}
OnClick = RFBvoltarClick
end
object RFBfinalizar: TRzRapidFireButton
Left = 9
Top = 1
Width = 100
Height = 24
Caption = ' Finalizar'
Flat = True
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Verdana'
Font.Style = []
ParentFont = False
OnClick = RFBfinalizarClick
end
object Image2: TImage
Left = 20
Top = 6
Width = 18
Height = 18
AutoSize = True
Center = True
Picture.Data = {
0954506E67496D61676589504E470D0A1A0A0000000D49484452000000120000
0012080600000056CE8E57000000017352474200AECE1CE90000000467414D41
0000B18F0BFC6105000000097048597300000EC300000EC301C76FA864000003
694944415478DAAD936F4C1B651CC7BF0F77E5E8B5B4D0F6A0AD6E09D4105DC6
E856609D4AC4685C346E73C6BF972C99332ED9E20B8D66F18DEF5C168DD90B0D
8946CD82F11C9B21081B6E61848D3160F88F2CF14FA6441052A8B48552FAC7DE
3D77F5690F5E2C117CE35D7E972777793EF7FB7E9FEF8FE07FBA48F171B0F3FA
31AF54F3204DAFC0EFB4A2AD4E02D50B1B6EE23982D1E91822590DC98C9AFB63
397DA2047AE9DCCDDE234FEDDE4FB280ADA02358CD41DFE4EF1CABC9650A55E0
71EDA705BCDF33784F0974F4FC84F2C2A3AD72269581A8A5B1D3E784BA4947AC
214C2EAC80737AF0C3EF33F49DEEEB0D25D02B5DE3CA93ED6179299942959E41
B3DF811C354CDD1B80BE5F5805A974E3F6CC2C7DEFEB1113F4F2D931E591B6B0
1C4D2421218B166F25329A0E4236067DB79046C1E141646E9676F40D99A023CA
0D65CFFD61793696849F19D5ECB56355FD6F101C1292D139FAD1C5ABEBA01165
474B589EFA6B095BB91C829215899CC636FC3BA98CBDBE15CB815449506311FA
D937D74CD0E12F8695865D61F9E7F925D4F3593CE0B723B549473CFB30124943
AB94202423B4F3F2B0093AD439A46C69324182BA0A5739598FD886E18BE70DD8
DD121CA979DAD33F6882E44F2E2BAE6DCDF2ADB938CAF93268ECE48DC29DA862
1838A6A928B7B82E183AAA6D15F0FDBD48BFBAB0067ABEA347111B42F2B7338B
A8E67454D02C5C761139554326AFAD4924502985A61BCC2302223A506E73A29E
C668DF7A47CF9C3EAB90FA9DF2D8F422AC4CDA5B2D3EC453ABD87E770D9A037E
64B33958798277FB27F0F1CD29545905546DA987CDE3C536234E2F5DEC37414F
9F3A739E0642CF0EFC32070FA7E2B5260FDEFC7208AF3FB11BA79F6B43315F22
9B8BB77BC7F1C1E8149CA200BB6F2B6CEE5A84F8241DBCD06D82F69CF8B023D8
DA7AFCD27412D168146F04DD38D93B81C30F37E1E4E34144E22B10888E530393
E8FA711EB05A60F332904B429B2D4BAFF4AD8170FC4CED431EADABB1B1B1FDEA
54142FD659F1F9F86D1CD815C0ABE100A24B2BE00D151DA3BFA1EFD704C086B5
42BA0BA2CB8326B28C81EE7375646D982DB877EF7DEDFB1EFBD4E7147704AA45
38980F0576336B60940C06FE4CA41049E54AE617380BF87201D1C5843A363C12
2A82CA5809AC0C78437610CD8578CC3C734DBD33406E0F2C9502B4E23A9F07D4
3C2C35B505179799FF0738AF60594A7C4BD40000000049454E44AE426082}
OnClick = RFBfinalizarClick
end
object RxSplitter1: TRxSplitter
Left = 0
Top = 24
Width = 432
Height = 3
Align = alBottom
end
end
end
| 35.659026 | 74 | 0.707995 |
47f78ea6f48b26ccb535738419cc254ccb69179a | 936 | pas | Pascal | Containers/U_DCExceptions.pas | dsapolska/dccontainers | f098cc9491b99cee8cc95758b6acdb1f01cbdba0 | [
"MIT"
]
| 6 | 2019-02-01T02:33:13.000Z | 2022-02-21T11:29:31.000Z | Containers/U_DCExceptions.pas | dsapolska/dccontainers | f098cc9491b99cee8cc95758b6acdb1f01cbdba0 | [
"MIT"
]
| null | null | null | Containers/U_DCExceptions.pas | dsapolska/dccontainers | f098cc9491b99cee8cc95758b6acdb1f01cbdba0 | [
"MIT"
]
| 1 | 2020-09-26T03:04:57.000Z | 2020-09-26T03:04:57.000Z | unit U_DCExceptions;
interface
uses
SysUtils;
type
EDCKeyNotFound = class(Exception)
public
constructor Create(const AKey : string); overload;
constructor Create(const AKey : integer); overload;
end;
EDCValueIncorrectFormat = class(Exception)
public
constructor Create(const AValueType, ARequestedType : string);
end;
implementation
{ EDCKeyNotFound }
constructor EDCKeyNotFound.Create(const AKey: string);
const
EX_MSG = 'Object not found for key "%s"';
begin
Message:=format(EX_MSG, [AKey]);
end;
constructor EDCKeyNotFound.Create(const AKey: integer);
const
EX_MSG = 'Object not found for key "%d"';
begin
Message:=format(EX_MSG, [AKey]);
end;
{ EDCValueIncorrectFormat }
constructor EDCValueIncorrectFormat.Create(const AValueType,
ARequestedType: string);
const
EX_MSG = 'Can''t get value of type %s for %s';
begin
Message:=format(EX_MSG, [ARequestedType, AValueType]);
end;
end.
| 19.102041 | 66 | 0.739316 |
fcc04822fc53c23011fab238ed63bf7f7b8c2bde | 1,764 | pas | Pascal | src/ZapMQ.Message.RPC.pas | atkins126/ZapMQ-Delphi-Wrapper | cb18de9d162032c60a2dd08699dc248c4a644fa9 | [
"MIT"
]
| 5 | 2021-02-18T11:55:28.000Z | 2021-05-17T16:29:57.000Z | src/ZapMQ.Message.RPC.pas | atkins126/ZapMQ-Delphi-Wrapper | cb18de9d162032c60a2dd08699dc248c4a644fa9 | [
"MIT"
]
| null | null | null | src/ZapMQ.Message.RPC.pas | atkins126/ZapMQ-Delphi-Wrapper | cb18de9d162032c60a2dd08699dc248c4a644fa9 | [
"MIT"
]
| 2 | 2021-02-19T05:13:18.000Z | 2021-03-05T08:40:14.000Z | unit ZapMQ.Message.RPC;
interface
uses
ZapMQ.Message.JSON, ZapMQ.Handler;
type
TZapRPCMessage = class
private
FHandler: TZapMQHandlerRPC;
FQueueName: string;
FJSONMessage: TZapJSONMessage;
FBirthTime : Cardinal;
procedure SetHandler(const Value: TZapMQHandlerRPC);
procedure SetQueueName(const Value: string);
procedure SetJSONMessage(const Value: TZapJSONMessage);
public
function IsExpired : Boolean;
property QueueName : string read FQueueName write SetQueueName;
property Handler : TZapMQHandlerRPC read FHandler write SetHandler;
property JSONMessage : TZapJSONMessage read FJSONMessage write SetJSONMessage;
constructor Create(const pZapMessage : TZapJSONMessage;
const pHandler : TZapMQHandlerRPC; const pQueueName : string); overload;
destructor Destroy; override;
end;
implementation
uses
Windows;
{ TZapRPCMessage }
constructor TZapRPCMessage.Create(const pZapMessage: TZapJSONMessage;
const pHandler: TZapMQHandlerRPC; const pQueueName : string);
begin
FHandler := pHandler;
JSONMessage := pZapMessage;
QueueName := pQueueName;
FBirthTime := GetTickCount;
end;
destructor TZapRPCMessage.Destroy;
begin
JSONMessage.Free;
inherited;
end;
function TZapRPCMessage.IsExpired: Boolean;
begin
Result := (FJSONMessage.TTL > 0) and ((FBirthTime + FJSONMessage.TTL) < GetTickCount);
end;
procedure TZapRPCMessage.SetHandler(const Value: TZapMQHandlerRPC);
begin
FHandler := Value;
end;
procedure TZapRPCMessage.SetJSONMessage(const Value: TZapJSONMessage);
begin
FJSONMessage := Value;
end;
procedure TZapRPCMessage.SetQueueName(const Value: string);
begin
FQueueName := Value;
end;
end.
| 24.84507 | 89 | 0.738662 |
c3a7f379d819f026caa1f72c5a12b1b33b51b1c2 | 9,427 | pas | Pascal | server/endpoint_loinc.pas | grahamegrieve/fhirserver | 28f69977bde75490adac663e31a3dd77bc016f7c | [
"BSD-3-Clause"
]
| 132 | 2015-02-02T00:22:40.000Z | 2021-08-11T12:08:08.000Z | server/endpoint_loinc.pas | grahamegrieve/fhirserver | 28f69977bde75490adac663e31a3dd77bc016f7c | [
"BSD-3-Clause"
]
| 113 | 2015-03-20T01:55:20.000Z | 2021-10-08T16:15:28.000Z | server/endpoint_loinc.pas | grahamegrieve/fhirserver | 28f69977bde75490adac663e31a3dd77bc016f7c | [
"BSD-3-Clause"
]
| 49 | 2015-04-11T14:59:43.000Z | 2021-03-30T10:29:18.000Z | unit endpoint_loinc;
{
Copyright (c) 2001-2021, Health Intersections Pty Ltd (http://www.healthintersections.com.au)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
}
{$i fhir.inc}
{
This server exposes snomed and loinc browsers
}
interface
uses
Sysutils, Classes,
IdContext, IdCustomHTTPServer, IdOpenSSLX509,
fsl_base, fsl_utilities, fsl_threads, fsl_logging, fsl_json, fsl_http, fsl_npm, fsl_stream, fsl_htmlgen,
fdb_manager,
ftx_loinc_services, ftx_loinc_publisher,
fhir_objects,
server_config, utilities, server_constants,
tx_manager, telnet_server, time_tracker,
web_base, endpoint;
type
TLoincWebServer = class (TFhirWebServerEndpoint)
private
FTx : TCommonTerminologies;
function doRequest(AContext: TIdContext; request: TIdHTTPRequestInfo; response: TIdHTTPResponseInfo; id: String; secure: boolean): String;
procedure returnContent(request : TIdHTTPRequestInfo; response: TIdHTTPResponseInfo; path: String; secure : boolean; title, content : String); overload;
public
destructor Destroy; override;
function link : TLoincWebServer; overload;
function description : String; override;
function PlainRequest(AContext: TIdContext; ip : String; request: TIdHTTPRequestInfo; response: TIdHTTPResponseInfo; id : String; tt : TTimeTracker) : String; override;
function SecureRequest(AContext: TIdContext; ip : String; request: TIdHTTPRequestInfo; response: TIdHTTPResponseInfo; cert : TIdOpenSSLX509; id : String; tt : TTimeTracker) : String; override;
function logId : string; override;
end;
TLoincWebEndPoint = class (TFHIRServerEndPoint)
private
FLoincServer : TLoincWebServer;
public
constructor Create(config : TFHIRServerConfigSection; settings : TFHIRServerSettings; db : TFDBManager; common : TCommonTerminologies);
destructor Destroy; override;
function summary : String; override;
function makeWebEndPoint(common : TFHIRWebServerCommon) : TFhirWebServerEndpoint; override;
procedure InstallDatabase; override;
procedure UninstallDatabase; override;
procedure LoadPackages(plist : String); override;
procedure updateAdminPassword; override;
procedure Load; override;
Procedure Unload; override;
function cacheSize(magic : integer) : UInt64; override;
procedure clearCache; override;
procedure SetCacheStatus(status : boolean); override;
procedure getCacheInfo(ci: TCacheInformation); override;
end;
implementation
{ TLoincWebEndPoint }
function TLoincWebEndPoint.cacheSize(magic : integer): UInt64;
begin
result := inherited cacheSize(magic);
end;
procedure TLoincWebEndPoint.clearCache;
begin
inherited;
end;
constructor TLoincWebEndPoint.Create(config : TFHIRServerConfigSection; settings : TFHIRServerSettings; db : TFDBManager; common : TCommonTerminologies);
begin
inherited create(config, settings, db, common, nil);
end;
destructor TLoincWebEndPoint.Destroy;
begin
inherited;
end;
procedure TLoincWebEndPoint.getCacheInfo(ci: TCacheInformation);
begin
inherited;
end;
function TLoincWebEndPoint.makeWebEndPoint(common: TFHIRWebServerCommon): TFhirWebServerEndpoint;
begin
FLoincServer := TLoincWebServer.Create(config.name, config['path'].value, common);
FLoincServer.FTx := Terminologies.Link;
WebEndPoint := FLoincServer;
result := FLoincServer;
end;
procedure TLoincWebEndPoint.SetCacheStatus(status: boolean);
begin
inherited;
end;
function TLoincWebEndPoint.summary: String;
begin
result := 'Loinc Server';
end;
procedure TLoincWebEndPoint.InstallDatabase;
begin
raise EFslException.Create('This operation is not supported for this endpoint');
end;
procedure TLoincWebEndPoint.Load;
begin
end;
procedure TLoincWebEndPoint.LoadPackages(plist: String);
begin
raise EFslException.Create('This operation is not supported for this endpoint');
end;
procedure TLoincWebEndPoint.UninstallDatabase;
begin
raise EFslException.Create('This operation is not supported for this endpoint');
end;
procedure TLoincWebEndPoint.Unload;
begin
// nothing
end;
procedure TLoincWebEndPoint.updateAdminPassword;
begin
raise EFslException.Create('This operation is not supported for this endpoint');
end;
{ TLoincWebServer }
function TLoincWebServer.description: String;
begin
result := 'LOINC browser';
end;
destructor TLoincWebServer.Destroy;
begin
FTx.Free;
inherited;
end;
function TLoincWebServer.doRequest(AContext: TIdContext; request: TIdHTTPRequestInfo; response: TIdHTTPResponseInfo; id: String; secure: boolean): String;
var
code, lang, country : String;
pub : TLoincPublisher;
html : THtmlPublisher;
i : integer;
st : TStringList;
begin
FTx.Loinc.RecordUse;
code := request.UnparsedParams;
lang := request.Document.Substring(PathWithSlash.Length);
result := 'Loinc doco '+request.UnparsedParams+' ('+request.Document.Substring(12)+')';
if ((lang = '') and (code = '')) or ((lang <> '') and not FTX.Loinc.supportsLang(THTTPLanguages.create(lang))) then
begin
st := TStringList.create;
try
for i := 0 to FTX.Loinc.Lang.count - 1 do
begin
FTX.Loinc.Lang.GetEntry(i, lang, country);
st.add(lang+'-'+country);
end;
st.sort;
html := THtmlPublisher.Create();
try
html.Version := SERVER_FULL_VERSION;
html.BaseURL := '/loinc/doco/';
html.Lang := THTTPLanguages.create(lang);
html.Heading(1, 'LOINC Languages');
html.StartList();
for i := 0 to st.count - 1 do
begin
html.StartListItem;
html.URL(st[i], st[i]);
html.EndListItem;
end;
html.EndList();
returnContent(request, response, request.Document, secure, 'LOINC Langauges', html.output);
finally
html.free;
end;
finally
st.free;
end;
end
else
begin
result := 'Loinc Doco: '+code;
try
html := THtmlPublisher.Create();
pub := TLoincPublisher.create(FTX.Loinc, AbsoluteURL(secure), THTTPLanguages.Create(lang));
try
html.Version := SERVER_FULL_VERSION;
html.BaseURL := PathWithSlash+lang;
html.Lang := THTTPLanguages.Create(Lang);
pub.PublishDict(code, PathWithSlash+lang, html);
returnContent(request, response, request.Document, secure, 'LOINC Content', html.output);
finally
html.free;
pub.free;
end;
except
on e:exception do
begin
response.ResponseNo := 500;
response.ContentText := 'error:'+FormatTextToXml(e.Message, xmlText);
end;
end;
end;
end;
function TLoincWebServer.link: TLoincWebServer;
begin
result := TLoincWebServer(inherited link);
end;
function TLoincWebServer.logId: string;
begin
result := 'LN';
end;
function TLoincWebServer.PlainRequest(AContext: TIdContext; ip : String; request: TIdHTTPRequestInfo; response: TIdHTTPResponseInfo; id: String; tt : TTimeTracker): String;
begin
result := doRequest(AContext, request, response, id, false);
end;
procedure TLoincWebServer.returnContent(request: TIdHTTPRequestInfo; response: TIdHTTPResponseInfo; path: String; secure: boolean; title, content : String);
var
vars : TFslMap<TFHIRObject>;
begin
vars := TFslMap<TFHIRObject>.create;
try
vars.add('title', TFHIRObjectText.Create(title));
vars.add('content', TFHIRObjectText.Create(content));
returnFile(request, response, nil, path, 'template-nfhir.html', secure, vars);
finally
vars.free;
end;
end;
function TLoincWebServer.SecureRequest(AContext: TIdContext; ip : String; request: TIdHTTPRequestInfo; response: TIdHTTPResponseInfo; cert: TIdOpenSSLX509; id: String; tt : TTimeTracker): String;
begin
result := doRequest(AContext, request, response, id, true);
end;
end.
| 33.429078 | 197 | 0.722711 |
c301d00eaaefb3d3ca118f481d6e51af8ca8004f | 592 | dpr | Pascal | ABM/CuentaContable/Project/CuentaContable.dpr | Civeloo/GeN-XE7 | 638b59def20424955972a568817d012df4cf2cde | [
"Apache-2.0"
]
| null | null | null | ABM/CuentaContable/Project/CuentaContable.dpr | Civeloo/GeN-XE7 | 638b59def20424955972a568817d012df4cf2cde | [
"Apache-2.0"
]
| null | null | null | ABM/CuentaContable/Project/CuentaContable.dpr | Civeloo/GeN-XE7 | 638b59def20424955972a568817d012df4cf2cde | [
"Apache-2.0"
]
| null | null | null | program CuentaContable;
uses
Forms,
CuentaContableF in '..\Form\CuentaContableF.pas' {CuentasContablesForm},
DataModule in '..\..\..\DataModule\DataModule.pas' {DM: TDataModule},
BuscarCuentaF in '..\..\..\Buscar\CuentaContable\Form\BuscarCuentaF.pas' {BuscarCuentaForm},
ImprimirDM in '..\..\..\DataModule\ImprimirDM.pas' {ImprimirDataModule: TDataModule};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.Title := 'Cuenta Contable';
Application.CreateForm(TCuentasContablesForm, CuentasContablesForm);
Application.Run;
end.
| 31.157895 | 94 | 0.748311 |
fcc955a8dc0bf152dfa0662b168c0b52fcb5a03e | 3,189 | pas | Pascal | windows/src/developer/TIKE/help/Keyman.Developer.System.HelpTopics.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 219 | 2017-06-21T03:37:03.000Z | 2022-03-27T12:09:28.000Z | windows/src/developer/TIKE/help/Keyman.Developer.System.HelpTopics.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 4,451 | 2017-05-29T02:52:06.000Z | 2022-03-31T23:53:23.000Z | windows/src/developer/TIKE/help/Keyman.Developer.System.HelpTopics.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 72 | 2017-05-26T04:08:37.000Z | 2022-03-03T10:26:20.000Z | unit Keyman.Developer.System.HelpTopics;
interface
const
SHelpTopic_Context_About = 'context/about-tike';
SHelpTopic_Context_BitmapEditorText = 'context/keyboard-editor#toc-icon-tab';
SHelpTopic_Context_CharacterMap = 'context/character-map';
SHelpTopic_Context_CharacterIdentifier = 'context/character-identifier';
SHelpTopic_Context_Debug = 'context/debug';
SHelpTopic_Context_DebugStatus = 'context/debug#toc-state';
SHelpTopic_Context_DebugStatus_CallStack = 'context/debug#toc-call-stack';
SHelpTopic_Context_DebugStatus_DeadKeys = 'context/debug#toc-deadkeys';
SHelpTopic_Context_DebugStatus_Elements = 'context/debug#toc-elements';
SHelpTopic_Context_DebugStatus_Key = 'context/debug#toc-state';
SHelpTopic_Context_DebugStatus_RegTest = 'context/debug#toc-regression-testing';
SHelpTopic_Context_DownloadProgress = 'context/download-progress';
SHelpTopic_Context_Help = 'context/help';
SHelpTopic_Context_KeyTest = 'context/key-test';
SHelpTopic_Context_KeyboardFonts = 'context/keyboard-fonts';
SHelpTopic_Context_ModelEditor = 'context/model-editor';
SHelpTopic_Context_Messages = 'context/messages';
SHelpTopic_Context_MustIncludeDebug = 'context/must-include-debug';
SHelpTopic_Context_New = 'context/new';
SHelpTopic_Context_NewProject = 'context/new-project';
SHelpTopic_Context_NewProjectParameters = 'context/new-project-parameters';
SHelpTopic_Context_NewModelProjectParameters = 'context/new-model-project-parameters';
SHelpTopic_Context_NewFileDetails = 'context/new-file-details';
SHelpTopic_Context_OnScreenKeyboardEditor = 'context/keyboard-editor#toc-on-screen-tab';
SHelpTopic_Context_Options = 'context/options';
SHelpTopic_Context_Project = 'context/project';
SHelpTopic_Context_RegressionTestFailure = 'context/debug#toc-regression-testing';
SHelpTopic_Context_SelectBCP47Language = 'context/select-bcp47-language';
SHelpTopic_Context_SelectKey = 'context/keyboard-editor#toc-layout-tab';
SHelpTopic_Context_SelectSystemKeyboard = 'context/select-system-keyboard';
SHelpTopic_Context_SelectWindowsLanguages = 'context/select-windows-languages';
SHelpTopic_Context_Startup = 'context/startup';
SHelpTopic_Context_TextEditor = 'context/editor';
SHelpTopic_Context_VisualKeyboardImportKMX = 'context/keyboard-editor#toc-on-screen-tab';
SHelpTopic_Context_VisualKeyboardExportHtmlParams = 'context/keyboard-editor#toc-on-screen-tab';
SHelpTopic_Context_Editor = 'context/editor';
SHelpTopic_Context_PackageEditor = 'context/package-editor';
SHelpTopic_Context_OSKEditor = 'context/keyboard-editor#toc-on-screen-tab';
SHelpTopic_Context_BitmapEditor = 'context/keyboard-editor#toc-icon-tab';
SHelpTopic_Context_KeyboardEditor = 'context/keyboard-editor';
SHelpTopic_Context_TouchLayoutBuilder = 'context/keyboard-editor#toc-touch-layout-tab';
SHelpTopic_Context_TestKeyboard = 'context/debug#toc-test-mode';
SHelpTopic_Context_WordlistEditor = 'context/wordlist-editor';
// For all .kmn language reference topics, prefix with this path:
SHelpTopic_LanguageReference_Prefix = 'language/reference/';
SHelpTopic_LanguageGuide_Prefix = 'language/guide/';
implementation
end.
| 55.947368 | 98 | 0.821574 |
47f6f0534658beb5b0e2e737cc7fb90caeba7d82 | 5,161 | pas | Pascal | src/entrylist.pas | my443/volcano-time-tracker | 298836a7670ef01a8953e9e1574201ab077c9a67 | [
"CC-BY-3.0"
]
| null | null | null | src/entrylist.pas | my443/volcano-time-tracker | 298836a7670ef01a8953e9e1574201ab077c9a67 | [
"CC-BY-3.0"
]
| null | null | null | src/entrylist.pas | my443/volcano-time-tracker | 298836a7670ef01a8953e9e1574201ab077c9a67 | [
"CC-BY-3.0"
]
| null | null | null | unit entrylist;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, sqldb, db, FileUtil, Forms, Controls, Graphics, Dialogs,
DBGrids, ExtCtrls, StdCtrls, ComCtrls, TimeEntry;
type
{ TEntries }
TEntries = class(TForm)
CloseTime: TButton;
DataSource1: TDataSource;
SumDatasource: TDataSource;
Proj_Title: TMemo;
NewTime: TButton;
EditTime: TButton;
DeleteTime: TButton;
DBGrid1: TDBGrid;
Panel1: TPanel;
SQLQuery1: TSQLQuery;
SumTransaction: TSQLTransaction;
StatusBar1: TStatusBar;
SUMQuery: TSQLQuery;
SQLTransaction1: TSQLTransaction;
procedure CloseTimeClick(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure DBGrid1DblClick(Sender: TObject);
procedure DeleteTimeClick(Sender: TObject);
procedure EditTimeClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure NewTimeClick(Sender: TObject);
procedure AddHours(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
var RecordID: integer;
ActivateForm: boolean;
ProjectName: string;
//NewTime: boolean;
end;
var
Entries: TEntries;
implementation
{$R *.lfm}
{ TEntries }
procedure TEntries.FormActivate(Sender: TObject);
var sum: String;
begin
ShortDateFormat := 'mm/dd/yy';
SQLQuery1.close;
AddHours(Entries);
// Then open the query to populate the grid.
SQLQuery1.SQL.text:='Select Time_PK as ID, Cast(Time_Date as Text) as Time_Date, Cast(Time_Hours as Text) as Hours, Cast(Time_Start as Text) as Time_Start, Cast(Time_End as Text) as Time_End, cast(Time_Memo as Text) as Memo from time where Time_ProjectFK='+chr(39)+IntToStr(RecordID)+chr(39);
//
SQLQUERY1.Open;
//ShowMessage(SQLQuery1.SQL.text);
DBGrid1.Refresh;
// You have to define the collumn widths programatically.
//dbGrid1.Columns[0].Width := 35;
dbGrid1.Columns[0].visible := False;
dbGrid1.Columns[1].Width := 100;
dbGrid1.Columns[2].Width := 64;
dbGrid1.Columns[3].Width := 64;
dbGrid1.Columns[4].Width := 64;
dbGrid1.Columns[5].Width := 135;
Proj_Title.Caption := ProjectName;
//Proj_ID.Caption := 'Project # '+IntToStr(RecordID);
StatusBar1.Panels[0].Text := 'Project # '+IntToStr(RecordID);
SQLQUERY1.Fields[0].Visible:=False;
end;
procedure TEntries.FormCreate(Sender: TObject);
begin
end;
procedure TEntries.EditTimeClick(Sender: TObject);
begin
TimeForm.Newtime := False;
TimeForm.ProjectID := RecordID; // Give the TimeForm the Project ID
TimeForm.ProjectName := ProjectName; //Pass the Projectname to the timeform
TimeForm.ActivateForm:= True; // Tell the form it is the first-time activation
if SQLQuery1.Fields[0].AsString <> '' then
begin
TimeForm.RecordID := SQLQuery1.Fields[0].AsInteger; // Tell the TimeForm the time entry record selected.
TimeForm.ShowModal;
SQLQUERY1.REFRESH;
end;
AddHours(Entries);
//ShowMessage(SQLQuery1.Fields[0].AsString);
end;
procedure TEntries.DeleteTimeClick(Sender: TObject);
var query_string, id, message: string;
begin
if not DBGrid1.DataSource.DataSet.IsEmpty then
Begin
message := 'Are you sure that you want to delete this time Entry?';
case QuestionDlg ('Delete item.',message,mtCustom,[mrYes,'Delete Selection', mrNo, 'Cancel'],'') of
mrYes:
Begin
id := SQLQuery1.Fields[0].AsString;
query_string := 'delete from time where Time_PK='+id;
SQLQuery1.SQL.Text := query_string;
SQLQuery1.ExecSQL;
SQLTransaction1.Commit;
AddHours(Entries);
end;
end;
end;
FormActivate(Entries);
end;
procedure TEntries.CloseTimeClick(Sender: TObject);
begin
Entries.Close;
end;
procedure TEntries.DBGrid1CellClick(Column: TColumn);
begin
EditTimeClick(Entries);
end;
procedure TEntries.DBGrid1DblClick(Sender: TObject);
begin
EditTimeClick(Entries);
end;
procedure TEntries.NewTimeClick(Sender: TObject);
begin
TimeForm.ProjectID := RecordID;
TimeForm.ProjectName := ProjectName;
TimeForm.ActivateForm := True;
TimeForm.NewTime := True;
TimeForm.ShowModal;
SQLQuery1.Refresh;
AddHours(Entries);
//Navigation.SQLTransaction1.Commit;
//Button1Click(Button1);
end;
procedure TEntries.AddHours(Sender: TObject);
var sum: string;
Begin
SQLQuery1.close;
// First find the number of hours.
SQLQuery1.SQL.text :='Select sum(Time_Hours) from time where Time_ProjectFK='+chr(39)+IntToStr(RecordID)+chr(39);
SQLQuery1.Open;
sum := SQLQuery1.Fields[0].AsString;
StatusBar1.Panels[1].Text := 'Total Hours: '+ sum;
SQLQuery1.Close;
// Then open the query to populate the grid.
SQLQuery1.SQL.text:='Select Time_PK as ID, Cast(Time_Date as Text) as Time_Date, Cast(Time_Hours as Text) as Hours, Cast(Time_Start as Text) as Time_Start, Cast(Time_End as Text) as Time_End, cast(Time_Memo as Text) as Memo from time where Time_ProjectFK='+chr(39)+IntToStr(RecordID)+chr(39);
//
SQLQUERY1.Open;
End;
end.
| 27.59893 | 295 | 0.700058 |
c3c0190be0c8a8b7351871455703a440ee03d6a2 | 2,710 | pas | Pascal | Components/SystemInformation.pas | ricardojr01/mathparser | 549e897aad33517bcf1d9fdfbfbcb2720304fb63 | [
"Apache-2.0"
]
| 8 | 2019-09-26T02:28:30.000Z | 2022-01-02T17:36:50.000Z | Components/SystemInformation.pas | ricardojr01/mathparser | 549e897aad33517bcf1d9fdfbfbcb2720304fb63 | [
"Apache-2.0"
]
| 2 | 2020-10-28T15:29:22.000Z | 2021-01-31T13:28:36.000Z | Components/SystemInformation.pas | ricardojr01/mathparser | 549e897aad33517bcf1d9fdfbfbcb2720304fb63 | [
"Apache-2.0"
]
| 3 | 2020-10-25T09:46:58.000Z | 2021-02-02T03:02:07.000Z | { *********************************************************************** }
{ }
{ SystemInformation }
{ }
{ Copyright (c) 2013 Pisarev Yuriy (post@pisarev.net) }
{ }
{ *********************************************************************** }
unit SystemInformation;
{$B-}
interface
uses
Windows, SystemTypes;
type
WKSTA_INFO_100 = record
wki100_platform_id: Integer;
wki100_computername: PWideChar;
wki100_langroup: PWideChar;
wki100_ver_major: Integer;
wki100_ver_minor: Integer;
end;
TNetApiBufferFree = function(BufPtr: Pointer): Integer; stdcall;
TNetWkstaGetInfo = function(ServerName: PWideChar; Level: Integer; var BufPtr: Pointer): Integer; stdcall;
function GetComputerName(out DomainName: string): Boolean; overload;
function GetComputerName: string; overload;
function GetDomainName(out DomainName: string): Boolean; overload;
function GetDomainName: string; overload;
var
UserName, ComputerName, DomainName: string;
implementation
const
NetApi32Name = 'netapi32.dll';
NetApiBufferFreeName = 'NetApiBufferFree';
NetWkstaGetInfoName = 'NetWkstaGetInfo';
var
NetApi32: THandle;
NetApiBufferFree: TNetApiBufferFree;
NetWkstaGetInfo: TNetWkstaGetInfo;
function GetComputerName(out DomainName: string): Boolean;
var
Buffer: ^WKSTA_INFO_100;
begin
Result := NetWkstaGetInfo(nil, 100, Pointer(Buffer)) = 0;
if Result then
try
DomainName := WideCharToString(Buffer^.wki100_computername);
finally
NetApiBufferFree(Buffer);
end;
end;
function GetComputerName: string;
begin
if not GetComputerName(Result) then Result := '';
end;
function GetDomainName(out DomainName: string): Boolean;
var
Buffer: ^WKSTA_INFO_100;
begin
Result := NetWkstaGetInfo(nil, 100, Pointer(Buffer)) = 0;
if Result then
try
DomainName := WideCharToString(Buffer^.wki100_langroup);
finally
NetApiBufferFree(Buffer);
end;
end;
function GetDomainName: string;
begin
if not GetDomainName(Result) then Result := '';
end;
initialization
if NetApi32 = 0 then NetApi32 := LoadLibrary(NetApi32Name);
if not Assigned(NetApiBufferFree) then NetApiBufferFree := GetProcAddress(NetApi32, NetApiBufferFreeName);
if not Assigned(NetWkstaGetInfo) then NetWkstaGetInfo := GetProcAddress(NetApi32, NetWkstaGetInfoName);
ComputerName := GetComputerName;
DomainName := GetDomainName;
finalization
if NetApi32 <> 0 then FreeLibrary(NetApi32);
end.
| 27.938144 | 108 | 0.6369 |
c38b761f5efbf86d5d0ed61161574ac895d33def | 2,698 | pas | Pascal | 2021/solutions/day10.pas | MKolman/advent-of-code | 04ce3f20c5042c23ff0b73958a5b2dd9ecc2c23e | [
"MIT"
]
| 4 | 2021-12-02T07:56:22.000Z | 2021-12-27T07:20:01.000Z | 2021/solutions/day10.pas | MKolman/advent-of-code | 04ce3f20c5042c23ff0b73958a5b2dd9ecc2c23e | [
"MIT"
]
| null | null | null | 2021/solutions/day10.pas | MKolman/advent-of-code | 04ce3f20c5042c23ff0b73958a5b2dd9ecc2c23e | [
"MIT"
]
| 1 | 2021-12-02T19:50:29.000Z | 2021-12-02T19:50:29.000Z | program Hello;
const
STACK_SIZE = 1000;
var
stack: Array[0..STACK_SIZE] of Char;
topPointer: Integer;
c: Char;
valid: Boolean;
part1: Int64;
part2: Array[0..STACK_SIZE] of Int64;
numValid: Integer;
tmp: Int64;
i, j: Integer;
begin
stack[0] := 'x';
topPointer := 1;
valid := true;
part1 := 0;
numValid := 0;
while not eof do
begin
read(c);
if c = AnsiChar(#10) then begin
if valid then begin
part2[numvalid] := 0;
for i := topPointer-1 downto 1 do begin
part2[numValid] := part2[numValid] * 5;
if stack[i] = ')' then part2[numValid] := part2[numValid] + 1
else if stack[i] = ']' then part2[numValid] := part2[numValid] + 2
else if stack[i] = '}' then part2[numValid] := part2[numValid] + 3
else if stack[i] = '>' then part2[numValid] := part2[numValid] + 4;
end;
numValid := numValid + 1;
end;
valid := true;
topPointer := 1;
end else if valid = false then
continue
else if c = '(' then begin
stack[topPointer] := ')';
topPointer := topPointer + 1;
end else if c = '[' then begin
stack[topPointer] := ']';
topPointer := topPointer + 1;
end else if c = '{' then begin
stack[topPointer] := '}';
topPointer := topPointer + 1;
end else if c = '<' then begin
stack[topPointer] := '>';
topPointer := topPointer + 1;
end else if c = stack[topPointer - 1] then
topPointer := topPointer - 1
else if c = ')' then begin
part1 := part1 + 3;
valid := false;
end else if c = ']' then begin
part1 := part1 + 57;
valid := false;
end else if c = '}' then begin
part1 := part1 + 1197;
valid := false;
end else if c = '>' then begin
part1 := part1 + 25137;
valid := false;
end;
end;
writeln(part1);
{ Bubble sort }
for i := 0 to numValid-1 do begin
for j := 0 to i-1 do begin
if part2[i] < part2[j] then begin
tmp := part2[i];
part2[i] := part2[j];
part2[j] := tmp;
end;
end;
end;
writeln(part2[numValid div 2]);
end.
| 33.308642 | 91 | 0.435137 |
c34422ca944f347aaa2141fede768739c846854f | 15,610 | pas | Pascal | QRCodeGenLib/src/QRCodeGen/QlpQrTemplate.pas | Xor-el/QRCodeGenLib4Pascal | f6002de875450ba3b5420cf0612dd0eb04e7de89 | [
"MIT"
]
| 39 | 2018-10-11T14:14:18.000Z | 2021-06-12T17:25:45.000Z | QRCodeGenLib/src/QRCodeGen/QlpQrTemplate.pas | Xor-el/QRCodeGenLib4Pascal | f6002de875450ba3b5420cf0612dd0eb04e7de89 | [
"MIT"
]
| 2 | 2020-02-11T01:21:52.000Z | 2021-08-24T16:36:54.000Z | QRCodeGenLib/src/QRCodeGen/QlpQrTemplate.pas | Xor-el/QRCodeGenLib4Pascal | f6002de875450ba3b5420cf0612dd0eb04e7de89 | [
"MIT"
]
| 5 | 2018-10-11T14:14:21.000Z | 2021-12-26T07:05:55.000Z | unit QlpQrTemplate;
{$I ..\Include\QRCodeGenLib.inc}
interface
uses
Math,
SyncObjs,
QlpIQrTemplate,
QlpQrCodeCommons,
QlpBits,
QlpQRCodeGenLibTypes;
resourcestring
SVersionOutOfRange = 'Version out of range';
SVersionNumberOutOfRange = 'Version number out of range';
SInvalidState = 'Invalid state encountered.';
type
TQrTemplate = class sealed(TInterfacedObject, IQrTemplate)
strict private
const
MIN_VERSION = TQrCodeCommons.MIN_VERSION;
MAX_VERSION = TQrCodeCommons.MAX_VERSION;
class var
FCache: array [0 .. MAX_VERSION + 1] of IQrTemplate;
FIsPending: array [0 .. MAX_VERSION + 1] of Boolean;
FLock: TCriticalSection;
var
FVersion: Int32; // In the range [1, 40].
FSize: Int32; // Derived from version.
// "FIsFunction" Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
// Otherwise when the constructor is running, System.length(FIsFunction) == System.length(FTemplate).
FIsFunction: TQRCodeGenLibInt32Array;
FTemplate: TQRCodeGenLibInt32Array;
// Length and values depend on version.
FDataOutputBitIndexes: TQRCodeGenLibInt32Array;
// System.length(FMasks) == 8, and System.length(FMasks[i]) == System.length(FTemplate).
FMasks: TQRCodeGenLibMatrixInt32Array;
function GetTemplate(): TQRCodeGenLibInt32Array; inline;
function GetDataOutputBitIndexes(): TQRCodeGenLibInt32Array; inline;
function GetMasks(): TQRCodeGenLibMatrixInt32Array;
// Returns the value of the bit at the given coordinates in the given grid.
function GetModule(const AGrid: TQRCodeGenLibInt32Array; Ax, Ay: Int32)
: Int32; inline;
// Returns an ascending list of positions of alignment patterns for this version number.
// Each position is in the range [0,177], and are used on both the x and y axes.
// This could be implemented as lookup table of 40 variable-length lists of unsigned bytes.
function GetAlignmentPatternPositions(): TQRCodeGenLibInt32Array;
// Computes and returns an array of bit indexes, based on this object's various fields.
function GenerateZigZagScan(): TQRCodeGenLibInt32Array;
// Computes and returns a new array of masks, based on this object's various fields.
function GenerateMasks(): TQRCodeGenLibMatrixInt32Array;
// Reads this object's version field, and draws and marks all function modules.
procedure DrawFunctionPatterns();
// Draws two blank copies of the format bits.
procedure DrawDummyFormatBits();
// Draws two copies of the version bits (with its own error correction code),
// based on this object's version field, iff 7 <= version <= 40.
procedure DrawVersion();
// Draws a 9*9 finder pattern including the border separator,
// with the center module at (Ax, Ay). Modules can be out of bounds.
procedure DrawFinderPattern(Ax, Ay: Int32);
// Draws a 5*5 alignment pattern, with the center module
// at (Ax, Ay). All modules must be in bounds.
procedure DrawAlignmentPattern(Ax, Ay: Int32);
// Marks the module at the given coordinates as a function module.
// Also either sets that module black or keeps its color unchanged.
procedure DarkenFunctionModule(Ax, Ay, AEnable: Int32); inline;
// Creates a QR Code template for the given version number.
constructor Create(AVersion: Int32);
class constructor CreateQrTemplate();
class destructor DestroyQrTemplate();
public
property Template: TQRCodeGenLibInt32Array read GetTemplate;
property DataOutputBitIndexes: TQRCodeGenLibInt32Array
read GetDataOutputBitIndexes;
property Masks: TQRCodeGenLibMatrixInt32Array read GetMasks;
class function GetInstance(AVersion: Int32): IQrTemplate; static;
// Returns the number of data bits that can be stored in a QR Code of the given version number, after
// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
class function GetNumRawDataModules(AVersion: Int32): Int32; static;
end;
implementation
{ TQrTemplate }
constructor TQrTemplate.Create(AVersion: Int32);
begin
Inherited Create();
if ((AVersion < MIN_VERSION) or (AVersion > MAX_VERSION)) then
begin
raise EArgumentOutOfRangeQRCodeGenLibException.CreateRes
(@SVersionOutOfRange);
end;
FVersion := AVersion;
FSize := (AVersion * 4) + 17;
System.SetLength(FTemplate, ((FSize * FSize) + 31) shr 5);
System.SetLength(FIsFunction, System.Length(FTemplate));
DrawFunctionPatterns(); // Reads and writes fields
FMasks := GenerateMasks(); // Reads fields, returns array
FDataOutputBitIndexes := GenerateZigZagScan(); // Reads fields, returns array
FIsFunction := Nil;
end;
class constructor TQrTemplate.CreateQrTemplate;
var
LIdx: Int32;
begin
// Initialize static array to their default state to avoid junk values inside.
for LIdx := System.Low(FCache) to System.High(FCache) do
begin
FCache[LIdx] := Nil;
FIsPending[LIdx] := False;
end;
FLock := TCriticalSection.Create;
end;
function TQrTemplate.GetModule(const AGrid: TQRCodeGenLibInt32Array;
Ax, Ay: Int32): Int32;
var
LIdx: Int32;
begin
{$IFDEF DEBUG}
System.Assert((0 <= Ax) and (Ax < FSize));
System.Assert((0 <= Ay) and (Ay < FSize));
{$ENDIF DEBUG}
LIdx := (Ay * FSize) + Ax;
result := TQrCodeCommons.GetBit(AGrid[TBits.Asr32(LIdx, 5)], LIdx);
end;
class function TQrTemplate.GetNumRawDataModules(AVersion: Int32): Int32;
var
numAlign: Int32;
begin
if ((AVersion < MIN_VERSION) or (AVersion > MAX_VERSION)) then
begin
raise EArgumentOutOfRangeQRCodeGenLibException.CreateRes
(@SVersionNumberOutOfRange);
end;
result := (((16 * AVersion) + 128) * AVersion) + 64;
if (AVersion >= 2) then
begin
numAlign := (AVersion div 7) + 2;
result := result - ((((25 * numAlign) - 10) * numAlign) - 55);
if (AVersion >= 7) then
begin
result := result - 36;
end;
end;
end;
procedure TQrTemplate.DarkenFunctionModule(Ax, Ay, AEnable: Int32);
var
LIdx: Int32;
begin
{$IFDEF DEBUG}
System.Assert((0 <= Ax) and (Ax < FSize));
System.Assert((0 <= Ay) and (Ay < FSize));
System.Assert((AEnable = 0) or (AEnable = 1));
{$ENDIF DEBUG}
LIdx := (Ay * FSize) + Ax;
FTemplate[TBits.Asr32(LIdx, 5)] := FTemplate[TBits.Asr32(LIdx, 5)] or
(TBits.LeftShift32(AEnable, LIdx));
FIsFunction[TBits.Asr32(LIdx, 5)] := FIsFunction[TBits.Asr32(LIdx, 5)] or
(TBits.LeftShift32(1, LIdx));
end;
class destructor TQrTemplate.DestroyQrTemplate;
var
LIdx: Int32;
begin
// Initialize static array to their default state to clear former contents.
for LIdx := System.Low(FCache) to System.High(FCache) do
begin
FCache[LIdx] := Nil;
FIsPending[LIdx] := False;
end;
FLock.Free;
end;
procedure TQrTemplate.DrawAlignmentPattern(Ax, Ay: Int32);
var
Ldy, Ldx: Int32;
begin
for Ldy := -2 to 2 do
begin
for Ldx := -2 to 2 do
begin
DarkenFunctionModule(Ax + Ldx, Ay + Ldy,
Abs(Max(Abs(Ldx), Abs(Ldy)) - 1));
end;
end;
end;
procedure TQrTemplate.DrawDummyFormatBits;
var
LIdx: Int32;
begin
// Draw first copy
for LIdx := 0 to 5 do
begin
DarkenFunctionModule(8, LIdx, 0);
end;
DarkenFunctionModule(8, 7, 0);
DarkenFunctionModule(8, 8, 0);
DarkenFunctionModule(7, 8, 0);
for LIdx := 9 to System.Pred(15) do
begin
DarkenFunctionModule(14 - LIdx, 8, 0);
end;
// Draw second copy
for LIdx := 0 to System.Pred(8) do
begin
DarkenFunctionModule(FSize - 1 - LIdx, 8, 0);
end;
for LIdx := 8 to System.Pred(15) do
begin
DarkenFunctionModule(8, FSize - 15 + LIdx, 0);
end;
DarkenFunctionModule(8, FSize - 8, 1); // Always black
end;
procedure TQrTemplate.DrawFinderPattern(Ax, Ay: Int32);
var
Ldy, Ldx, LDist, Lxx, Lyy, LEnable: Int32;
begin
for Ldy := -4 to 4 do
begin
for Ldx := -4 to 4 do
begin
LDist := Max(Abs(Ldy), Abs(Ldx)); // Chebyshev/infinity norm
Lxx := Ax + Ldx;
Lyy := Ay + Ldy;
if ((0 <= Lxx) and (Lxx < FSize) and (0 <= Lyy) and (Lyy < FSize)) then
begin
if ((LDist <> 2) and (LDist <> 4)) then
begin
LEnable := 1;
end
else
begin
LEnable := 0;
end;
DarkenFunctionModule(Lxx, Lyy, LEnable);
end;
end;
end;
end;
procedure TQrTemplate.DrawFunctionPatterns;
var
LIIdx, LJIdx, LNumAlign: Int32;
LAlignPatPos: TQRCodeGenLibInt32Array;
begin
// Draw horizontal and vertical timing patterns
for LIIdx := 0 to System.Pred(FSize) do
begin
DarkenFunctionModule(6, LIIdx, (not LIIdx) and 1);
DarkenFunctionModule(LIIdx, 6, (not LIIdx) and 1);
end;
// Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules)
DrawFinderPattern(3, 3);
DrawFinderPattern(FSize - 4, 3);
DrawFinderPattern(3, FSize - 4);
// Draw numerous alignment patterns
LAlignPatPos := GetAlignmentPatternPositions();
LNumAlign := System.Length(LAlignPatPos);
for LIIdx := 0 to System.Pred(LNumAlign) do
begin
for LJIdx := 0 to System.Pred(LNumAlign) do
begin
if (not(((LIIdx = 0) and (LJIdx = 0)) or ((LIIdx = 0) and
(LJIdx = LNumAlign - 1)) or ((LIIdx = LNumAlign - 1) and (LJIdx = 0))))
then
begin
DrawAlignmentPattern(LAlignPatPos[LIIdx], LAlignPatPos[LJIdx]);
end;
end;
end;
// Draw configuration data
DrawDummyFormatBits();
DrawVersion();
end;
procedure TQrTemplate.DrawVersion;
var
LRem, LIdx, LBit, LBits, La, Lb: Int32;
begin
if (FVersion < 7) then
begin
Exit;
end;
// Calculate error correction code and pack bits
LRem := FVersion; // version is uint6, in the range [7, 40]
LIdx := 0;
while LIdx < 12 do
begin
LRem := (LRem shl 1) xor ((TBits.Asr32(LRem, 11)) * $1F25);
System.Inc(LIdx);
end;
LBits := (FVersion shl 12) or LRem; // uint18
{$IFDEF DEBUG}
System.Assert(TBits.Asr32(LBits, 18) = 0);
{$ENDIF DEBUG}
// Draw two copies
for LIdx := 0 to System.Pred(18) do
begin
LBit := TQrCodeCommons.GetBit(LBits, LIdx);
La := FSize - 11 + (LIdx mod 3);
Lb := LIdx div 3;
DarkenFunctionModule(La, Lb, LBit);
DarkenFunctionModule(Lb, La, LBit);
end;
end;
function TQrTemplate.GenerateMasks: TQRCodeGenLibMatrixInt32Array;
var
LMask, Ly, LIdx, Lx, LBit: Int32;
LInvert: Boolean;
LMaskModules: TQRCodeGenLibInt32Array;
begin
System.SetLength(result, 8);
for LMask := System.Low(result) to System.High(result) do
begin
// resize dimension of inner array
System.SetLength(result[LMask], System.Length(FTemplate));
LMaskModules := result[LMask];
Ly := 0;
LIdx := 0;
while Ly < FSize do
begin
Lx := 0;
while Lx < FSize do
begin
case LMask of
0:
begin
LInvert := (Lx + Ly) and 1 = 0;
end;
1:
begin
LInvert := Ly and 1 = 0;
end;
2:
begin
LInvert := Lx mod 3 = 0;
end;
3:
begin
LInvert := (Lx + Ly) mod 3 = 0;
end;
4:
begin
LInvert := ((Lx div 3) + (Ly shr 1)) and 1 = 0;
end;
5:
begin
LInvert := ((Lx * Ly) and 1) + Lx * Ly mod 3 = 0;
end;
6:
begin
LInvert := (((Lx * Ly) and 1) + Lx * Ly mod 3) and 1 = 0;
end;
7:
begin
LInvert := (((Lx + Ly) and 1) + Lx * Ly mod 3) and 1 = 0;
end
else
begin
raise EInvalidOperationQRCodeGenLibException.CreateRes
(@SInvalidState);
end;
end;
if LInvert then
begin
LBit := 1 and (not GetModule(FIsFunction, Lx, Ly));
end
else
begin
LBit := 0 and (not GetModule(FIsFunction, Lx, Ly));
end;
LMaskModules[TBits.Asr32(LIdx, 5)] := LMaskModules[TBits.Asr32(LIdx, 5)
] or (TBits.LeftShift32(LBit, LIdx));
System.Inc(Lx);
System.Inc(LIdx);
end;
System.Inc(Ly);
end;
end;
end;
function TQrTemplate.GenerateZigZagScan: TQRCodeGenLibInt32Array;
var
LIIdx, LJIdx, LRight, LVert, Lx, Ly: Int32;
LUpward: Boolean;
begin
System.SetLength(result, ((GetNumRawDataModules(FVersion) div 8) * 8));
LIIdx := 0; // Bit index into the data
LRight := FSize - 1;
while LRight >= 1 do
begin // Index of right column in each column pair
if (LRight = 6) then
begin
LRight := 5;
end;
LVert := 0;
while LVert < FSize do
begin
// Vertical counter
LJIdx := 0;
while LJIdx < 2 do
begin
Lx := LRight - LJIdx; // Actual x coordinate
LUpward := ((LRight + 1) and 2) = 0;
// Actual y coordinate
if LUpward then
begin
Ly := FSize - 1 - LVert;
end
else
begin
Ly := LVert;
end;
if ((GetModule(FIsFunction, Lx, Ly) = 0) and
(LIIdx < System.Length(result))) then
begin
result[LIIdx] := (Ly * FSize) + Lx;
System.Inc(LIIdx);
end;
System.Inc(LJIdx);
end;
System.Inc(LVert);
end;
System.Dec(LRight, 2);
end;
{$IFDEF DEBUG}
System.Assert(LIIdx = System.Length(result));
{$ENDIF DEBUG}
end;
function TQrTemplate.GetAlignmentPatternPositions: TQRCodeGenLibInt32Array;
var
LNumAlign, LStep, LIdx, LPos: Int32;
begin
if (FVersion = 1) then
begin
result := Nil;
Exit;
end
else
begin
LNumAlign := (FVersion div 7) + 2;
if (FVersion = 32) then
begin
LStep := 26;
end
else
begin
LStep := (((FVersion * 4) + (LNumAlign * 2) + 1)
div ((LNumAlign * 2) - 2)) * 2;
end;
System.SetLength(result, LNumAlign);
result[0] := 6;
LIdx := System.Length(result) - 1;
LPos := FSize - 7;
while LIdx >= 1 do
begin
result[LIdx] := LPos;
System.Dec(LIdx);
System.Dec(LPos, LStep);
end;
end;
end;
function TQrTemplate.GetDataOutputBitIndexes: TQRCodeGenLibInt32Array;
begin
result := System.Copy(FDataOutputBitIndexes);
end;
class function TQrTemplate.GetInstance(AVersion: Int32): IQrTemplate;
begin
if ((AVersion < MIN_VERSION) or (AVersion > MAX_VERSION)) then
begin
raise EArgumentOutOfRangeQRCodeGenLibException.CreateRes
(@SVersionOutOfRange);
end;
while True do
begin
FLock.Acquire;
try
result := FCache[AVersion];
if result <> Nil then
begin
Exit;
end;
if (not(FIsPending[AVersion])) then
begin
FIsPending[AVersion] := True;
Break;
end;
finally
FLock.Release;
end;
end;
result := TQrTemplate.Create(AVersion);
FLock.Acquire;
try
FCache[AVersion] := result;
FIsPending[AVersion] := False;
finally
FLock.Release;
end;
end;
function TQrTemplate.GetMasks: TQRCodeGenLibMatrixInt32Array;
var
LIdx: Int32;
begin
// since System.Copy() does not support jagged arrays (multidimensional dynamic arrays, we improvise)
System.SetLength(result, System.Length(FMasks));
for LIdx := System.Low(result) to System.High(result) do
begin
result[LIdx] := System.Copy(FMasks[LIdx]);
end;
end;
function TQrTemplate.GetTemplate: TQRCodeGenLibInt32Array;
begin
result := System.Copy(FTemplate);
end;
end.
| 27.434095 | 119 | 0.644971 |
f196447649fb6c18fcdb1583601b53350d23f7a5 | 5,214 | pas | Pascal | package/indy-10.2.0.3/fpc/IdFTPListParseChameleonNewt.pas | RonaldoSurdi/Sistema-gerenciamento-websites-delphi | 8cc7eec2d05312dc41f514bbd5f828f9be9c579e | [
"MIT"
]
| 1 | 2022-02-28T11:28:18.000Z | 2022-02-28T11:28:18.000Z | package/indy-10.2.0.3/fpc/IdFTPListParseChameleonNewt.pas | RonaldoSurdi/Sistema-gerenciamento-websites-delphi | 8cc7eec2d05312dc41f514bbd5f828f9be9c579e | [
"MIT"
]
| null | null | null | package/indy-10.2.0.3/fpc/IdFTPListParseChameleonNewt.pas | RonaldoSurdi/Sistema-gerenciamento-websites-delphi | 8cc7eec2d05312dc41f514bbd5f828f9be9c579e | [
"MIT"
]
| null | null | null | {
$Project$
$Workfile$
$Revision$
$DateUTC$
$Id$
This file is part of the Indy (Internet Direct) project, and is offered
under the dual-licensing agreement described on the Indy website.
(http://www.indyproject.org/)
Copyright:
(c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
}
{
$Log$
}
{
Rev 1.0 11/29/2004 2:44:16 AM JPMugaas
New FTP list parsers for some legacy FTP servers.
}
unit IdFTPListParseChameleonNewt;
interface
{$i IdCompilerDefines.inc}
uses
Classes,
IdFTPList, IdFTPListParseBase,IdFTPListTypes;
type
TIdChameleonNewtFTPListItem = class(TIdDOSBaseFTPListItem);
TIdFTPLPChameleonNewt = class(TIdFTPLPBaseDOS)
protected
class function MakeNewItem(AOwner : TIdFTPListItems) : TIdFTPListItem; override;
class function ParseLine(const AItem : TIdFTPListItem; const APath : String = ''): Boolean; override;
public
class function GetIdent : String; override;
class function CheckListing(AListing : TStrings; const ASysDescript : String = ''; const ADetails : Boolean = True): Boolean; override;
end;
implementation
uses
IdFTPCommon, IdGlobal, IdGlobalProtocols, SysUtils;
{ TIdFTPLPChameleonNewt }
class function TIdFTPLPChameleonNewt.CheckListing(AListing: TStrings;
const ASysDescript: String; const ADetails: Boolean): Boolean;
{Look for something like this:
. <DIR> Nov 16 1994 17:16
.. <DIR> Nov 16 1994 17:16
INSTALL <DIR> Nov 16 1994 17:17
CMT <DIR> Nov 21 1994 10:17
DESIGN1.DOC 11264 May 11 1995 14:20 A
README.TXT 1045 May 10 1995 11:01
WPKIT1.EXE 960338 Jun 21 1995 17:01 R
CMT.CSV 0 Jul 06 1995 14:56 RHA
}
var
i : Integer;
LBuf, LBuf2 : String;
LInt : Integer;
begin
Result := False;
for i := 0 to AListing.Count -1 do
begin
LBuf := AListing[i];
//filename and extension - we assume an 8.3 filename type because
//Windows 3.1 only supports that.
Fetch(LBuf);
LBuf := TrimLeft(LBuf);
//<DIR> or file size
LBuf2 := Fetch(LBuf);
Result := (LBuf2 = '<DIR>') or IsNumeric(LBuf2); {Do not localize}
if not Result then begin
Exit;
end;
LBuf := TrimLeft(LBuf);
//month
LBuf2 := Fetch(LBuf);
Result := StrToMonth(LBuf2) > 0;
if not Result then begin
Exit;
end;
//day
LBuf := TrimLeft(LBuf);
LInt := IndyStrToInt64(Fetch(LBuf), 0);
Result := (LInt > 0) and (LInt < 32);
if not Result then begin
Exit;
end;
//year
LBuf := TrimLeft(LBuf);
Result := IsNumeric(Fetch(LBuf));
if not Result then begin
Exit;
end;
//time
LBuf := TrimLeft(LBuf);
LBuf2 := Fetch(LBuf);
Result := IsHHMMSS(LBuf2, ':');
if not Result then begin
Exit;
end;
//attributes
repeat
LBuf := TrimLeft(LBuf);
if LBuf = '' then begin
Break;
end;
LBuf2 := Fetch(LBuf);
Result := IsValidAttr(LBuf2);
until not Result;
end;
end;
class function TIdFTPLPChameleonNewt.GetIdent: String;
begin
Result := 'NetManage Chameleon/Newt'; {Do not localize}
end;
class function TIdFTPLPChameleonNewt.MakeNewItem(AOwner: TIdFTPListItems): TIdFTPListItem;
begin
Result := TIdChameleonNewtFTPListItem.Create(AOwner);
end;
class function TIdFTPLPChameleonNewt.ParseLine(const AItem: TIdFTPListItem;
const APath: String): Boolean;
var
LI : TIdChameleonNewtFTPListItem;
LBuf, LBuf2 : String;
LDay, LMonth, LYear : Integer;
begin
LI := AItem as TIdChameleonNewtFTPListItem;
LBuf := AItem.Data;
//filename and extension - we assume an 8.3 filename type because
//Windows 3.1 only supports that.
LI.FileName := Fetch(LBuf);
LBuf := TrimLeft(LBuf);
//<DIR> or file size
LBuf2 := Fetch(LBuf);
if LBuf2 = '<DIR>' then {Do not localize}
begin
LI.ItemType := ditDirectory;
LI.SizeAvail := False;
end else
begin
LI.ItemType := ditFile;
Result := IsNumeric(LBuf2);
if not Result then begin
Exit;
end;
LI.Size := IndyStrToInt64(LBuf2, 0);
end;
//month
LBuf := TrimLeft(LBuf);
LBuf2 := Fetch(LBuf);
LMonth := StrToMonth(LBuf2);
Result := LMonth > 0;
if not Result then begin
Exit;
end;
//day
LBuf := TrimLeft(LBuf);
LBuf2 := Fetch(LBuf);
LDay := IndyStrToInt64(LBuf2, 0);
Result := (LDay > 0) and (LDay < 32);
if not Result then begin
Exit;
end;
//year
LBuf := TrimLeft(LBuf);
LBuf2 := Fetch(LBuf);
Result := IsNumeric(LBuf2);
if not Result then begin
Exit;
end;
LYear := Y2Year(IndyStrToInt(LBuf2, 0));
LI.ModifiedDate := EncodeDate(LYear, LMonth, LDay);
//time
LBuf := TrimLeft(LBuf);
LBuf2 := Fetch(LBuf);
Result := IsHHMMSS(LBuf2, ':');
if not Result then begin
Exit;
end;
LI.ModifiedDate := LI.ModifiedDate + TimeHHMMSS(LBuf2);
//attributes
repeat
LBuf := TrimLeft(LBuf);
if LBuf = '' then begin
Break;
end;
LBuf2 := Fetch(LBuf);
Result := LI.FAttributes.AddAttribute(LBuf2);
until not Result;
end;
initialization
RegisterFTPListParser(TIdFTPLPChameleonNewt);
finalization
UnRegisterFTPListParser(TIdFTPLPChameleonNewt);
end.
| 24.828571 | 139 | 0.653049 |
c3dc9ad9b3a5be111bb05fde7cf9b0d57b2e54f2 | 82,897 | pas | Pascal | iscbase/network/ssl_openssl_lib.pas | isyscore/isc-fpbase | ce2469c977eba901005982dc7f89fee2d0718f76 | [
"MIT"
]
| 3 | 2021-06-10T12:33:29.000Z | 2021-12-13T06:59:48.000Z | iscbase/network/ssl_openssl_lib.pas | isyscore/isc-fpbase | ce2469c977eba901005982dc7f89fee2d0718f76 | [
"MIT"
]
| null | null | null | iscbase/network/ssl_openssl_lib.pas | isyscore/isc-fpbase | ce2469c977eba901005982dc7f89fee2d0718f76 | [
"MIT"
]
| null | null | null | {==============================================================================|
| Project : Ararat Synapse | 003.008.000 |
|==============================================================================|
| Content: SSL support by OpenSSL |
|==============================================================================|
| Copyright (c)1999-2017, Lukas Gebauer |
| All rights reserved |
| |
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the following conditions are met: |
| |
| Redistributions of source code must retain the above copyright notice, this |
| list of conditions and the following disclaimer. |
| |
| Redistributions in binary form must reproduce the above copyright notice, |
| this list of conditions and the following disclaimer in the documentation |
| and/or other materials provided with the distribution. |
| |
| Neither the name of Lukas Gebauer nor the names of its contributors may |
| be used to endorse or promote products derived from this software without |
| specific prior written permission. |
| |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR |
| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| DAMAGE. |
|==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
| Portions created by Lukas Gebauer are Copyright (c)2002-2017. |
| Portions created by Petr Fejfar are Copyright (c)2011-2012. |
| All rights reserved |
|==============================================================================|
| Contributor(s): |
| Tomas Hajny (OS2 support) |
|==============================================================================|
| History: see HISTORY.HTM from distribution package |
| (Found at URL: http://www.ararat.cz/synapse/) |
|==============================================================================}
{
Special thanks to Gregor Ibic <gregor.ibic@intelicom.si>
(Intelicom d.o.o., http://www.intelicom.si)
for good inspiration about begin with SSL programming.
}
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$H+}
{$IFDEF VER125}
{$DEFINE BCB}
{$ENDIF}
{$IFDEF BCB}
{$ObjExportAll On}
(*$HPPEMIT 'namespace ssl_openssl_lib { using System::Shortint; }' *)
{$ENDIF}
//old Delphi does not have MSWINDOWS define.
{$IFDEF WIN32}
{$IFNDEF MSWINDOWS}
{$DEFINE MSWINDOWS}
{$ENDIF}
{$ENDIF}
{:@abstract(OpenSSL support)
This unit is Pascal interface to OpenSSL library (used by @link(ssl_openssl) unit).
OpenSSL is loaded dynamicly on-demand. If this library is not found in system,
requested OpenSSL function just return errorcode.
}
unit ssl_openssl_lib;
interface
uses
{$IFDEF CIL}
System.Runtime.InteropServices,
System.Text,
{$ENDIF}
Classes,
synafpc,
//=== ct9999 ===================
{$IFNDEF WINDOWS}
{$IFDEF FPC}
BaseUnix, SysUtils;
{$ELSE}
Libc, SysUtils;
{$ENDIF}
{$ELSE}
Windows;
{$ENDIF}
//===============================
{$IFDEF CIL}
const
{$IF DEFINED(LINUX) or DEFINED(FREEBSD) or DEFINED(SUNOS)} //=== ct9999 ====
DLLSSLName = 'libssl.so';
DLLUtilName = 'libcrypto.so';
{$ELSE}
DLLSSLName = 'ssleay32.dll';
DLLUtilName = 'libeay32.dll';
{$ENDIF}
{$ELSE}
var
{$IFNDEF MSWINDOWS}
{$IFDEF DARWIN}
DLLSSLName: string = 'libssl.dylib';
DLLUtilName: string = 'libcrypto.dylib';
{$ELSE}
{$IFDEF OS2}
{$IFDEF OS2GCC}
DLLSSLName: string = 'kssl.dll';
DLLUtilName: string = 'kcrypto.dll';
{$ELSE OS2GCC}
DLLSSLName: string = 'ssl.dll';
DLLUtilName: string = 'crypto.dll';
{$ENDIF OS2GCC}
{$ELSE OS2}
DLLSSLName: string = 'libssl.so';
DLLUtilName: string = 'libcrypto.so';
{$ENDIF OS2}
{$ENDIF}
{$ELSE}
DLLSSLName: string = 'ssleay32.dll';
DLLSSLName2: string = 'libssl32.dll';
DLLUtilName: string = 'libeay32.dll';
{$ENDIF}
{$ENDIF}
type
{$IFDEF CIL}
SslPtr = IntPtr;
{$ELSE}
SslPtr = Pointer;
{$ENDIF}
PSslPtr = ^SslPtr;
PSSL_CTX = SslPtr;
PSSL = SslPtr;
PSSL_METHOD = SslPtr;
PX509 = SslPtr;
PX509_NAME = SslPtr;
PEVP_MD = SslPtr;
PInteger = ^Integer;
PBIO_METHOD = SslPtr;
PBIO = SslPtr;
EVP_PKEY = SslPtr;
PRSA = SslPtr;
PASN1_UTCTIME = SslPtr;
PASN1_INTEGER = SslPtr;
PPasswdCb = SslPtr;
PFunction = procedure;
PSTACK = SslPtr; {pf}
TSkPopFreeFunc = procedure(p:SslPtr); cdecl; {pf}
TX509Free = procedure(x: PX509); cdecl; {pf}
DES_cblock = array[0..7] of Byte;
PDES_cblock = ^DES_cblock;
des_ks_struct = packed record
ks: DES_cblock;
weak_key: Integer;
end;
des_key_schedule = array[1..16] of des_ks_struct;
const
EVP_MAX_MD_SIZE = 16 + 20;
SSL_ERROR_NONE = 0;
SSL_ERROR_SSL = 1;
SSL_ERROR_WANT_READ = 2;
SSL_ERROR_WANT_WRITE = 3;
SSL_ERROR_WANT_X509_LOOKUP = 4;
SSL_ERROR_SYSCALL = 5; //look at error stack/return value/errno
SSL_ERROR_ZERO_RETURN = 6;
SSL_ERROR_WANT_CONNECT = 7;
SSL_ERROR_WANT_ACCEPT = 8;
SSL_OP_NO_SSLv2 = $01000000;
SSL_OP_NO_SSLv3 = $02000000;
SSL_OP_NO_TLSv1 = $04000000;
SSL_OP_ALL = $000FFFFF;
SSL_VERIFY_NONE = $00;
SSL_VERIFY_PEER = $01;
OPENSSL_DES_DECRYPT = 0;
OPENSSL_DES_ENCRYPT = 1;
X509_V_OK = 0;
X509_V_ILLEGAL = 1;
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = 2;
X509_V_ERR_UNABLE_TO_GET_CRL = 3;
X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = 4;
X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = 5;
X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = 6;
X509_V_ERR_CERT_SIGNATURE_FAILURE = 7;
X509_V_ERR_CRL_SIGNATURE_FAILURE = 8;
X509_V_ERR_CERT_NOT_YET_VALID = 9;
X509_V_ERR_CERT_HAS_EXPIRED = 10;
X509_V_ERR_CRL_NOT_YET_VALID = 11;
X509_V_ERR_CRL_HAS_EXPIRED = 12;
X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 13;
X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = 14;
X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = 15;
X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 16;
X509_V_ERR_OUT_OF_MEM = 17;
X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = 18;
X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = 19;
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 20;
X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = 21;
X509_V_ERR_CERT_CHAIN_TOO_LONG = 22;
X509_V_ERR_CERT_REVOKED = 23;
X509_V_ERR_INVALID_CA = 24;
X509_V_ERR_PATH_LENGTH_EXCEEDED = 25;
X509_V_ERR_INVALID_PURPOSE = 26;
X509_V_ERR_CERT_UNTRUSTED = 27;
X509_V_ERR_CERT_REJECTED = 28;
//These are 'informational' when looking for issuer cert
X509_V_ERR_SUBJECT_ISSUER_MISMATCH = 29;
X509_V_ERR_AKID_SKID_MISMATCH = 30;
X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH = 31;
X509_V_ERR_KEYUSAGE_NO_CERTSIGN = 32;
X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER = 33;
X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION = 34;
//The application is not happy
X509_V_ERR_APPLICATION_VERIFICATION = 50;
SSL_FILETYPE_ASN1 = 2;
SSL_FILETYPE_PEM = 1;
EVP_PKEY_RSA = 6;
SSL_CTRL_SET_TLSEXT_HOSTNAME = 55;
TLSEXT_NAMETYPE_host_name = 0;
var
SSLLibHandle: TLibHandle = 0;
SSLUtilHandle: TLibHandle = 0;
SSLLibFile: string = '';
SSLUtilFile: string = '';
{$IFDEF CIL}
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_get_error')]
function SslGetError(s: PSSL; ret_code: Integer): Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_library_init')]
function SslLibraryInit: Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_load_error_strings')]
procedure SslLoadErrorStrings; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_set_cipher_list')]
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: String): Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_new')]
function SslCtxNew(meth: PSSL_METHOD):PSSL_CTX; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_free')]
procedure SslCtxFree (arg0: PSSL_CTX); external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_set_fd')]
function SslSetFd(s: PSSL; fd: Integer):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSLv2_method')]
function SslMethodV2 : PSSL_METHOD; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSLv3_method')]
function SslMethodV3 : PSSL_METHOD; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'TLSv1_method')]
function SslMethodTLSV1:PSSL_METHOD; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'TLSv1_1_method')]
function SslMethodTLSV11:PSSL_METHOD; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'TLSv1_2_method')]
function SslMethodTLSV12:PSSL_METHOD; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSLv23_method')]
function SslMethodV23 : PSSL_METHOD; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'TLS_method')]
function SslMethodTLS : PSSL_METHOD; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_use_PrivateKey')]
function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_use_PrivateKey_ASN1')]
function SslCtxUsePrivateKeyASN1(pk: integer; ctx: PSSL_CTX; d: String; len: integer):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_use_RSAPrivateKey_file')]
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_use_certificate')]
function SslCtxUseCertificate(ctx: PSSL_CTX; x: SslPtr):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_use_certificate_ASN1')]
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: integer; d: String):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_use_certificate_file')]
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer;external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_use_certificate_chain_file')]
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: String):Integer;external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_check_private_key')]
function SslCtxCheckPrivateKeyFile(ctx: PSSL_CTX):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_set_default_passwd_cb')]
procedure SslCtxSetDefaultPasswdCb(ctx: PSSL_CTX; cb: PPasswdCb); external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_set_default_passwd_cb_userdata')]
procedure SslCtxSetDefaultPasswdCbUserdata(ctx: PSSL_CTX; u: IntPtr); external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_load_verify_locations')]
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; CAfile: string; CApath: String):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_ctrl')]
function SslCtxCtrl(ctx: PSSL_CTX; cmd: integer; larg: integer; parg: IntPtr): integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_new')]
function SslNew(ctx: PSSL_CTX):PSSL; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_free')]
procedure SslFree(ssl: PSSL); external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_accept')]
function SslAccept(ssl: PSSL):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_connect')]
function SslConnect(ssl: PSSL):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_shutdown')]
function SslShutdown(s: PSSL):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_read')]
function SslRead(ssl: PSSL; buf: StringBuilder; num: Integer):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_peek')]
function SslPeek(ssl: PSSL; buf: StringBuilder; num: Integer):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_write')]
function SslWrite(ssl: PSSL; buf: String; num: Integer):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_pending')]
function SslPending(ssl: PSSL):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_get_version')]
function SslGetVersion(ssl: PSSL):String; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_get_peer_certificate')]
function SslGetPeerCertificate(s: PSSL):PX509; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_set_verify')]
procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: Integer; arg2: PFunction); external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_get_current_cipher')]
function SSLGetCurrentCipher(s: PSSL): SslPtr; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CIPHER_get_name')]
function SSLCipherGetName(c: SslPtr):String; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CIPHER_get_bits')]
function SSLCipherGetBits(c: SslPtr; var alg_bits: Integer):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_get_verify_result')]
function SSLGetVerifyResult(ssl: PSSL):Integer;external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_ctrl')]
function SslCtrl(ssl: PSSL; cmd: integer; larg: integer; parg: IntPtr): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_new')]
function X509New: PX509; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_free')]
procedure X509Free(x: PX509); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_NAME_oneline')]
function X509NameOneline(a: PX509_NAME; buf: StringBuilder; size: Integer): String; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_get_subject_name')]
function X509GetSubjectName(a: PX509):PX509_NAME; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_get_issuer_name')]
function X509GetIssuerName(a: PX509):PX509_NAME; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_NAME_hash')]
function X509NameHash(x: PX509_NAME):Cardinal; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_digest')]
function X509Digest (data: PX509; _type: PEVP_MD; md: StringBuilder; var len: Integer):Integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_set_version')]
function X509SetVersion(x: PX509; version: integer): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_set_pubkey')]
function X509SetPubkey(x: PX509; pkey: EVP_PKEY): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_set_issuer_name')]
function X509SetIssuerName(x: PX509; name: PX509_NAME): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_NAME_add_entry_by_txt')]
function X509NameAddEntryByTxt(name: PX509_NAME; field: string; _type: integer;
bytes: string; len, loc, _set: integer): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_sign')]
function X509Sign(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_print')]
function X509print(b: PBIO; a: PX509): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_gmtime_adj')]
function X509GmtimeAdj(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_set_notBefore')]
function X509SetNotBefore(x: PX509; tm: PASN1_UTCTIME): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_set_notAfter')]
function X509SetNotAfter(x: PX509; tm: PASN1_UTCTIME): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_get_serialNumber')]
function X509GetSerialNumber(x: PX509): PASN1_INTEGER; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'EVP_PKEY_new')]
function EvpPkeyNew: EVP_PKEY; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'EVP_PKEY_free')]
procedure EvpPkeyFree(pk: EVP_PKEY); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'EVP_PKEY_assign')]
function EvpPkeyAssign(pkey: EVP_PKEY; _type: integer; key: Prsa): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'EVP_get_digestbyname')]
function EvpGetDigestByName(Name: String): PEVP_MD; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'EVP_cleanup')]
procedure EVPcleanup; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSLeay_version')]
function SSLeayversion(t: integer): String; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ERR_error_string_n')]
procedure ErrErrorString(e: integer; buf: StringBuilder; len: integer); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ERR_get_error')]
function ErrGetError: integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ERR_clear_error')]
procedure ErrClearError; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ERR_free_strings')]
procedure ErrFreeStrings; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ERR_remove_state')]
procedure ErrRemoveState(pid: integer); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'OPENSSL_add_all_algorithms_noconf')]
procedure OPENSSLaddallalgorithms; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'CRYPTO_cleanup_all_ex_data')]
procedure CRYPTOcleanupAllExData; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'RAND_screen')]
procedure RandScreen; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_new')]
function BioNew(b: PBIO_METHOD): PBIO; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_free_all')]
procedure BioFreeAll(b: PBIO); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_s_mem')]
function BioSMem: PBIO_METHOD; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_ctrl_pending')]
function BioCtrlPending(b: PBIO): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_read')]
function BioRead(b: PBIO; Buf: StringBuilder; Len: integer): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_write')]
function BioWrite(b: PBIO; var Buf: String; Len: integer): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'd2i_PKCS12_bio')]
function d2iPKCS12bio(b:PBIO; Pkcs12: SslPtr): SslPtr; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'PKCS12_parse')]
function PKCS12parse(p12: SslPtr; pass: string; var pkey, cert, ca: SslPtr): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'PKCS12_free')]
procedure PKCS12free(p12: SslPtr); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'RSA_generate_key')]
function RsaGenerateKey(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ASN1_UTCTIME_new')]
function Asn1UtctimeNew: PASN1_UTCTIME; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ASN1_UTCTIME_free')]
procedure Asn1UtctimeFree(a: PASN1_UTCTIME); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ASN1_INTEGER_set')]
function Asn1IntegerSet(a: PASN1_INTEGER; v: integer): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'i2d_X509_bio')]
function i2dX509bio(b: PBIO; x: PX509): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'i2d_PrivateKey_bio')]
function i2dPrivateKeyBio(b: PBIO; pkey: EVP_PKEY): integer; external;
// 3DES functions
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'DES_set_odd_parity')]
procedure DESsetoddparity(Key: des_cblock); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'DES_set_key_checked')]
function DESsetkeychecked(key: des_cblock; schedule: des_key_schedule): Integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'DES_ecb_encrypt')]
procedure DESecbencrypt(Input: des_cblock; output: des_cblock; ks: des_key_schedule; enc: Integer); external;
{$ELSE}
// libssl.dll
function SslGetError(s: PSSL; ret_code: Integer):Integer;
function SslLibraryInit:Integer;
procedure SslLoadErrorStrings;
// function SslCtxSetCipherList(arg0: PSSL_CTX; str: PChar):Integer;
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: AnsiString):Integer;
function SslCtxNew(meth: PSSL_METHOD):PSSL_CTX;
procedure SslCtxFree(arg0: PSSL_CTX);
function SslSetFd(s: PSSL; fd: Integer):Integer;
function SslMethodV2:PSSL_METHOD;
function SslMethodV3:PSSL_METHOD;
function SslMethodTLSV1:PSSL_METHOD;
function SslMethodTLSV11:PSSL_METHOD;
function SslMethodTLSV12:PSSL_METHOD;
function SslMethodV23:PSSL_METHOD;
function SslMethodTLS:PSSL_METHOD;
function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer;
function SslCtxUsePrivateKeyASN1(pk: integer; ctx: PSSL_CTX; d: AnsiString; len: integer):Integer;
// function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer;
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: AnsiString; _type: Integer):Integer;
function SslCtxUseCertificate(ctx: PSSL_CTX; x: SslPtr):Integer;
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: integer; d: AnsiString):Integer;
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: AnsiString; _type: Integer):Integer;
// function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: PChar):Integer;
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: AnsiString):Integer;
function SslCtxCheckPrivateKeyFile(ctx: PSSL_CTX):Integer;
procedure SslCtxSetDefaultPasswdCb(ctx: PSSL_CTX; cb: PPasswdCb);
procedure SslCtxSetDefaultPasswdCbUserdata(ctx: PSSL_CTX; u: SslPtr);
// function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):Integer;
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: AnsiString; const CApath: AnsiString):Integer;
function SslCtxCtrl(ctx: PSSL_CTX; cmd: integer; larg: integer; parg: SslPtr): integer;
function SslNew(ctx: PSSL_CTX):PSSL;
procedure SslFree(ssl: PSSL);
function SslAccept(ssl: PSSL):Integer;
function SslConnect(ssl: PSSL):Integer;
function SslShutdown(ssl: PSSL):Integer;
function SslRead(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
function SslPeek(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
function SslWrite(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
function SslPending(ssl: PSSL):Integer;
function SslGetVersion(ssl: PSSL):AnsiString;
function SslGetPeerCertificate(ssl: PSSL):PX509;
procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: Integer; arg2: PFunction);
function SSLGetCurrentCipher(s: PSSL):SslPtr;
function SSLCipherGetName(c: SslPtr): AnsiString;
function SSLCipherGetBits(c: SslPtr; var alg_bits: Integer):Integer;
function SSLGetVerifyResult(ssl: PSSL):Integer;
function SSLCtrl(ssl: PSSL; cmd: integer; larg: integer; parg: SslPtr):Integer;
// libeay.dll
function X509New: PX509;
procedure X509Free(x: PX509);
function X509NameOneline(a: PX509_NAME; var buf: AnsiString; size: Integer):AnsiString;
function X509GetSubjectName(a: PX509):PX509_NAME;
function X509GetIssuerName(a: PX509):PX509_NAME;
function X509NameHash(x: PX509_NAME):Cardinal;
// function SslX509Digest(data: PX509; _type: PEVP_MD; md: PChar; len: PInteger):Integer;
function X509Digest(data: PX509; _type: PEVP_MD; md: AnsiString; var len: Integer):Integer;
function X509print(b: PBIO; a: PX509): integer;
function X509SetVersion(x: PX509; version: integer): integer;
function X509SetPubkey(x: PX509; pkey: EVP_PKEY): integer;
function X509SetIssuerName(x: PX509; name: PX509_NAME): integer;
function X509NameAddEntryByTxt(name: PX509_NAME; field: Ansistring; _type: integer;
bytes: Ansistring; len, loc, _set: integer): integer;
function X509Sign(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer;
function X509GmtimeAdj(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME;
function X509SetNotBefore(x: PX509; tm: PASN1_UTCTIME): integer;
function X509SetNotAfter(x: PX509; tm: PASN1_UTCTIME): integer;
function X509GetSerialNumber(x: PX509): PASN1_INTEGER;
function EvpPkeyNew: EVP_PKEY;
procedure EvpPkeyFree(pk: EVP_PKEY);
function EvpPkeyAssign(pkey: EVP_PKEY; _type: integer; key: Prsa): integer;
function EvpGetDigestByName(Name: AnsiString): PEVP_MD;
procedure EVPcleanup;
// function ErrErrorString(e: integer; buf: PChar): PChar;
function SSLeayversion(t: integer): Ansistring;
procedure ErrErrorString(e: integer; var buf: Ansistring; len: integer);
function ErrGetError: integer;
procedure ErrClearError;
procedure ErrFreeStrings;
procedure ErrRemoveState(pid: integer);
procedure OPENSSLaddallalgorithms;
procedure CRYPTOcleanupAllExData;
procedure RandScreen;
function BioNew(b: PBIO_METHOD): PBIO;
procedure BioFreeAll(b: PBIO);
function BioSMem: PBIO_METHOD;
function BioCtrlPending(b: PBIO): integer;
function BioRead(b: PBIO; var Buf: AnsiString; Len: integer): integer;
function BioWrite(b: PBIO; Buf: AnsiString; Len: integer): integer;
function d2iPKCS12bio(b:PBIO; Pkcs12: SslPtr): SslPtr;
function PKCS12parse(p12: SslPtr; pass: Ansistring; var pkey, cert, ca: SslPtr): integer;
procedure PKCS12free(p12: SslPtr);
function RsaGenerateKey(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA;
function Asn1UtctimeNew: PASN1_UTCTIME;
procedure Asn1UtctimeFree(a: PASN1_UTCTIME);
function Asn1IntegerSet(a: PASN1_INTEGER; v: integer): integer;
function Asn1IntegerGet(a: PASN1_INTEGER): integer; {pf}
function i2dX509bio(b: PBIO; x: PX509): integer;
function d2iX509bio(b:PBIO; x:PX509): PX509; {pf}
function PEMReadBioX509(b:PBIO; {var x:PX509;}x:PSslPtr; callback:PFunction; cb_arg: SslPtr): PX509; {pf}
procedure SkX509PopFree(st: PSTACK; func: TSkPopFreeFunc); {pf}
function i2dPrivateKeyBio(b: PBIO; pkey: EVP_PKEY): integer;
// 3DES functions
procedure DESsetoddparity(Key: des_cblock);
function DESsetkeychecked(key: des_cblock; schedule: des_key_schedule): Integer;
procedure DESecbencrypt(Input: des_cblock; output: des_cblock; ks: des_key_schedule; enc: Integer);
{$ENDIF}
function IsSSLloaded: Boolean;
function InitSSLInterface: Boolean;
function DestroySSLInterface: Boolean;
var
_X509Free: TX509Free = nil; {pf}
implementation
uses
{$IFDEF OS2}
Sockets,
{$ENDIF OS2}
SyncObjs;
{$IFNDEF CIL}
type
// libssl.dll
TSslGetError = function(s: PSSL; ret_code: Integer):Integer; cdecl;
TSslLibraryInit = function:Integer; cdecl;
TSslLoadErrorStrings = procedure; cdecl;
TSslCtxSetCipherList = function(arg0: PSSL_CTX; str: PAnsiChar):Integer; cdecl;
TSslCtxNew = function(meth: PSSL_METHOD):PSSL_CTX; cdecl;
TSslCtxFree = procedure(arg0: PSSL_CTX); cdecl;
TSslSetFd = function(s: PSSL; fd: Integer):Integer; cdecl;
TSslMethodV2 = function:PSSL_METHOD; cdecl;
TSslMethodV3 = function:PSSL_METHOD; cdecl;
TSslMethodTLSV1 = function:PSSL_METHOD; cdecl;
TSslMethodTLSV11 = function:PSSL_METHOD; cdecl;
TSslMethodTLSV12 = function:PSSL_METHOD; cdecl;
TSslMethodV23 = function:PSSL_METHOD; cdecl;
TSslMethodTLS = function:PSSL_METHOD; cdecl;
TSslCtxUsePrivateKey = function(ctx: PSSL_CTX; pkey: sslptr):Integer; cdecl;
TSslCtxUsePrivateKeyASN1 = function(pk: integer; ctx: PSSL_CTX; d: sslptr; len: integer):Integer; cdecl;
TSslCtxUsePrivateKeyFile = function(ctx: PSSL_CTX; const _file: PAnsiChar; _type: Integer):Integer; cdecl;
TSslCtxUseCertificate = function(ctx: PSSL_CTX; x: SslPtr):Integer; cdecl;
TSslCtxUseCertificateASN1 = function(ctx: PSSL_CTX; len: Integer; d: SslPtr):Integer; cdecl;
TSslCtxUseCertificateFile = function(ctx: PSSL_CTX; const _file: PAnsiChar; _type: Integer):Integer; cdecl;
TSslCtxUseCertificateChainFile = function(ctx: PSSL_CTX; const _file: PAnsiChar):Integer; cdecl;
TSslCtxCheckPrivateKeyFile = function(ctx: PSSL_CTX):Integer; cdecl;
TSslCtxSetDefaultPasswdCb = procedure(ctx: PSSL_CTX; cb: SslPtr); cdecl;
TSslCtxSetDefaultPasswdCbUserdata = procedure(ctx: PSSL_CTX; u: SslPtr); cdecl;
TSslCtxLoadVerifyLocations = function(ctx: PSSL_CTX; const CAfile: PAnsiChar; const CApath: PAnsiChar):Integer; cdecl;
TSslCtxCtrl = function(ctx: PSSL_CTX; cmd: integer; larg: integer; parg: SslPtr): integer; cdecl;
TSslNew = function(ctx: PSSL_CTX):PSSL; cdecl;
TSslFree = procedure(ssl: PSSL); cdecl;
TSslAccept = function(ssl: PSSL):Integer; cdecl;
TSslConnect = function(ssl: PSSL):Integer; cdecl;
TSslShutdown = function(ssl: PSSL):Integer; cdecl;
TSslRead = function(ssl: PSSL; buf: PAnsiChar; num: Integer):Integer; cdecl;
TSslPeek = function(ssl: PSSL; buf: PAnsiChar; num: Integer):Integer; cdecl;
TSslWrite = function(ssl: PSSL; const buf: PAnsiChar; num: Integer):Integer; cdecl;
TSslPending = function(ssl: PSSL):Integer; cdecl;
TSslGetVersion = function(ssl: PSSL):PAnsiChar; cdecl;
TSslGetPeerCertificate = function(ssl: PSSL):PX509; cdecl;
TSslCtxSetVerify = procedure(ctx: PSSL_CTX; mode: Integer; arg2: SslPtr); cdecl;
TSSLGetCurrentCipher = function(s: PSSL):SslPtr; cdecl;
TSSLCipherGetName = function(c: Sslptr):PAnsiChar; cdecl;
TSSLCipherGetBits = function(c: SslPtr; alg_bits: PInteger):Integer; cdecl;
TSSLGetVerifyResult = function(ssl: PSSL):Integer; cdecl;
TSSLCtrl = function(ssl: PSSL; cmd: integer; larg: integer; parg: SslPtr):Integer; cdecl;
TSSLSetTlsextHostName = function(ssl: PSSL; buf: PAnsiChar):Integer; cdecl;
// libeay.dll
TX509New = function: PX509; cdecl;
TX509NameOneline = function(a: PX509_NAME; buf: PAnsiChar; size: Integer):PAnsiChar; cdecl;
TX509GetSubjectName = function(a: PX509):PX509_NAME; cdecl;
TX509GetIssuerName = function(a: PX509):PX509_NAME; cdecl;
TX509NameHash = function(x: PX509_NAME):Cardinal; cdecl;
TX509Digest = function(data: PX509; _type: PEVP_MD; md: PAnsiChar; len: PInteger):Integer; cdecl;
TX509print = function(b: PBIO; a: PX509): integer; cdecl;
TX509SetVersion = function(x: PX509; version: integer): integer; cdecl;
TX509SetPubkey = function(x: PX509; pkey: EVP_PKEY): integer; cdecl;
TX509SetIssuerName = function(x: PX509; name: PX509_NAME): integer; cdecl;
TX509NameAddEntryByTxt = function(name: PX509_NAME; field: PAnsiChar; _type: integer;
bytes: PAnsiChar; len, loc, _set: integer): integer; cdecl;
TX509Sign = function(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer; cdecl;
TX509GmtimeAdj = function(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME; cdecl;
TX509SetNotBefore = function(x: PX509; tm: PASN1_UTCTIME): integer; cdecl;
TX509SetNotAfter = function(x: PX509; tm: PASN1_UTCTIME): integer; cdecl;
TX509GetSerialNumber = function(x: PX509): PASN1_INTEGER; cdecl;
TEvpPkeyNew = function: EVP_PKEY; cdecl;
TEvpPkeyFree = procedure(pk: EVP_PKEY); cdecl;
TEvpPkeyAssign = function(pkey: EVP_PKEY; _type: integer; key: Prsa): integer; cdecl;
TEvpGetDigestByName = function(Name: PAnsiChar): PEVP_MD; cdecl;
TEVPcleanup = procedure; cdecl;
TSSLeayversion = function(t: integer): PAnsiChar; cdecl;
TErrErrorString = procedure(e: integer; buf: PAnsiChar; len: integer); cdecl;
TErrGetError = function: integer; cdecl;
TErrClearError = procedure; cdecl;
TErrFreeStrings = procedure; cdecl;
TErrRemoveState = procedure(pid: integer); cdecl;
TOPENSSLaddallalgorithms = procedure; cdecl;
TCRYPTOcleanupAllExData = procedure; cdecl;
TRandScreen = procedure; cdecl;
TBioNew = function(b: PBIO_METHOD): PBIO; cdecl;
TBioFreeAll = procedure(b: PBIO); cdecl;
TBioSMem = function: PBIO_METHOD; cdecl;
TBioCtrlPending = function(b: PBIO): integer; cdecl;
TBioRead = function(b: PBIO; Buf: PAnsiChar; Len: integer): integer; cdecl;
TBioWrite = function(b: PBIO; Buf: PAnsiChar; Len: integer): integer; cdecl;
Td2iPKCS12bio = function(b:PBIO; Pkcs12: SslPtr): SslPtr; cdecl;
TPKCS12parse = function(p12: SslPtr; pass: PAnsiChar; var pkey, cert, ca: SslPtr): integer; cdecl;
TPKCS12free = procedure(p12: SslPtr); cdecl;
TRsaGenerateKey = function(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA; cdecl;
TAsn1UtctimeNew = function: PASN1_UTCTIME; cdecl;
TAsn1UtctimeFree = procedure(a: PASN1_UTCTIME); cdecl;
TAsn1IntegerSet = function(a: PASN1_INTEGER; v: integer): integer; cdecl;
TAsn1IntegerGet = function(a: PASN1_INTEGER): integer; cdecl; {pf}
Ti2dX509bio = function(b: PBIO; x: PX509): integer; cdecl;
Td2iX509bio = function(b:PBIO; x:PX509): PX509; cdecl; {pf}
TPEMReadBioX509 = function(b:PBIO; {var x:PX509;}x:PSslPtr; callback:PFunction; cb_arg:SslPtr): PX509; cdecl; {pf}
TSkX509PopFree = procedure(st: PSTACK; func: TSkPopFreeFunc); cdecl; {pf}
Ti2dPrivateKeyBio= function(b: PBIO; pkey: EVP_PKEY): integer; cdecl;
// 3DES functions
TDESsetoddparity = procedure(Key: des_cblock); cdecl;
TDESsetkeychecked = function(key: des_cblock; schedule: des_key_schedule): Integer; cdecl;
TDESecbencrypt = procedure(Input: des_cblock; output: des_cblock; ks: des_key_schedule; enc: Integer); cdecl;
//thread lock functions
TCRYPTOnumlocks = function: integer; cdecl;
TCRYPTOSetLockingCallback = procedure(cb: Sslptr); cdecl;
var
// libssl.dll
_SslGetError: TSslGetError = nil;
_SslLibraryInit: TSslLibraryInit = nil;
_SslLoadErrorStrings: TSslLoadErrorStrings = nil;
_SslCtxSetCipherList: TSslCtxSetCipherList = nil;
_SslCtxNew: TSslCtxNew = nil;
_SslCtxFree: TSslCtxFree = nil;
_SslSetFd: TSslSetFd = nil;
_SslMethodV2: TSslMethodV2 = nil;
_SslMethodV3: TSslMethodV3 = nil;
_SslMethodTLSV1: TSslMethodTLSV1 = nil;
_SslMethodTLSV11: TSslMethodTLSV11 = nil;
_SslMethodTLSV12: TSslMethodTLSV12 = nil;
_SslMethodV23: TSslMethodV23 = nil;
_SslMethodTLS: TSslMethodTLS = nil;
_SslCtxUsePrivateKey: TSslCtxUsePrivateKey = nil;
_SslCtxUsePrivateKeyASN1: TSslCtxUsePrivateKeyASN1 = nil;
_SslCtxUsePrivateKeyFile: TSslCtxUsePrivateKeyFile = nil;
_SslCtxUseCertificate: TSslCtxUseCertificate = nil;
_SslCtxUseCertificateASN1: TSslCtxUseCertificateASN1 = nil;
_SslCtxUseCertificateFile: TSslCtxUseCertificateFile = nil;
_SslCtxUseCertificateChainFile: TSslCtxUseCertificateChainFile = nil;
_SslCtxCheckPrivateKeyFile: TSslCtxCheckPrivateKeyFile = nil;
_SslCtxSetDefaultPasswdCb: TSslCtxSetDefaultPasswdCb = nil;
_SslCtxSetDefaultPasswdCbUserdata: TSslCtxSetDefaultPasswdCbUserdata = nil;
_SslCtxLoadVerifyLocations: TSslCtxLoadVerifyLocations = nil;
_SslCtxCtrl: TSslCtxCtrl = nil;
_SslNew: TSslNew = nil;
_SslFree: TSslFree = nil;
_SslAccept: TSslAccept = nil;
_SslConnect: TSslConnect = nil;
_SslShutdown: TSslShutdown = nil;
_SslRead: TSslRead = nil;
_SslPeek: TSslPeek = nil;
_SslWrite: TSslWrite = nil;
_SslPending: TSslPending = nil;
_SslGetVersion: TSslGetVersion = nil;
_SslGetPeerCertificate: TSslGetPeerCertificate = nil;
_SslCtxSetVerify: TSslCtxSetVerify = nil;
_SSLGetCurrentCipher: TSSLGetCurrentCipher = nil;
_SSLCipherGetName: TSSLCipherGetName = nil;
_SSLCipherGetBits: TSSLCipherGetBits = nil;
_SSLGetVerifyResult: TSSLGetVerifyResult = nil;
_SSLCtrl: TSSLCtrl = nil;
// libeay.dll
_X509New: TX509New = nil;
_X509NameOneline: TX509NameOneline = nil;
_X509GetSubjectName: TX509GetSubjectName = nil;
_X509GetIssuerName: TX509GetIssuerName = nil;
_X509NameHash: TX509NameHash = nil;
_X509Digest: TX509Digest = nil;
_X509print: TX509print = nil;
_X509SetVersion: TX509SetVersion = nil;
_X509SetPubkey: TX509SetPubkey = nil;
_X509SetIssuerName: TX509SetIssuerName = nil;
_X509NameAddEntryByTxt: TX509NameAddEntryByTxt = nil;
_X509Sign: TX509Sign = nil;
_X509GmtimeAdj: TX509GmtimeAdj = nil;
_X509SetNotBefore: TX509SetNotBefore = nil;
_X509SetNotAfter: TX509SetNotAfter = nil;
_X509GetSerialNumber: TX509GetSerialNumber = nil;
_EvpPkeyNew: TEvpPkeyNew = nil;
_EvpPkeyFree: TEvpPkeyFree = nil;
_EvpPkeyAssign: TEvpPkeyAssign = nil;
_EvpGetDigestByName: TEvpGetDigestByName = nil;
_EVPcleanup: TEVPcleanup = nil;
_SSLeayversion: TSSLeayversion = nil;
_ErrErrorString: TErrErrorString = nil;
_ErrGetError: TErrGetError = nil;
_ErrClearError: TErrClearError = nil;
_ErrFreeStrings: TErrFreeStrings = nil;
_ErrRemoveState: TErrRemoveState = nil;
_OPENSSLaddallalgorithms: TOPENSSLaddallalgorithms = nil;
_CRYPTOcleanupAllExData: TCRYPTOcleanupAllExData = nil;
_RandScreen: TRandScreen = nil;
_BioNew: TBioNew = nil;
_BioFreeAll: TBioFreeAll = nil;
_BioSMem: TBioSMem = nil;
_BioCtrlPending: TBioCtrlPending = nil;
_BioRead: TBioRead = nil;
_BioWrite: TBioWrite = nil;
_d2iPKCS12bio: Td2iPKCS12bio = nil;
_PKCS12parse: TPKCS12parse = nil;
_PKCS12free: TPKCS12free = nil;
_RsaGenerateKey: TRsaGenerateKey = nil;
_Asn1UtctimeNew: TAsn1UtctimeNew = nil;
_Asn1UtctimeFree: TAsn1UtctimeFree = nil;
_Asn1IntegerSet: TAsn1IntegerSet = nil;
_Asn1IntegerGet: TAsn1IntegerGet = nil; {pf}
_i2dX509bio: Ti2dX509bio = nil;
_d2iX509bio: Td2iX509bio = nil; {pf}
_PEMReadBioX509: TPEMReadBioX509 = nil; {pf}
_SkX509PopFree: TSkX509PopFree = nil; {pf}
_i2dPrivateKeyBio: Ti2dPrivateKeyBio = nil;
// 3DES functions
_DESsetoddparity: TDESsetoddparity = nil;
_DESsetkeychecked: TDESsetkeychecked = nil;
_DESecbencrypt: TDESecbencrypt = nil;
//thread lock functions
_CRYPTOnumlocks: TCRYPTOnumlocks = nil;
_CRYPTOSetLockingCallback: TCRYPTOSetLockingCallback = nil;
{$ENDIF}
var
SSLCS: TCriticalSection;
SSLloaded: boolean = false;
{$IFNDEF CIL}
Locks: TList;
{$ENDIF}
{$IFNDEF CIL}
// libssl.dll
function SslGetError(s: PSSL; ret_code: Integer):Integer;
begin
if InitSSLInterface and Assigned(_SslGetError) then
Result := _SslGetError(s, ret_code)
else
Result := SSL_ERROR_SSL;
end;
function SslLibraryInit:Integer;
begin
if InitSSLInterface and Assigned(_SslLibraryInit) then
Result := _SslLibraryInit
else
Result := 1;
end;
procedure SslLoadErrorStrings;
begin
if InitSSLInterface and Assigned(_SslLoadErrorStrings) then
_SslLoadErrorStrings;
end;
//function SslCtxSetCipherList(arg0: PSSL_CTX; str: PChar):Integer;
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: AnsiString):Integer;
begin
if InitSSLInterface and Assigned(_SslCtxSetCipherList) then
Result := _SslCtxSetCipherList(arg0, PAnsiChar(str))
else
Result := 0;
end;
function SslCtxNew(meth: PSSL_METHOD):PSSL_CTX;
begin
if InitSSLInterface and Assigned(_SslCtxNew) then
Result := _SslCtxNew(meth)
else
Result := nil;
end;
procedure SslCtxFree(arg0: PSSL_CTX);
begin
if InitSSLInterface and Assigned(_SslCtxFree) then
_SslCtxFree(arg0);
end;
function SslSetFd(s: PSSL; fd: Integer):Integer;
begin
if InitSSLInterface and Assigned(_SslSetFd) then
Result := _SslSetFd(s, fd)
else
Result := 0;
end;
function SslMethodV2:PSSL_METHOD;
begin
if InitSSLInterface and Assigned(_SslMethodV2) then
Result := _SslMethodV2
else
Result := nil;
end;
function SslMethodV3:PSSL_METHOD;
begin
if InitSSLInterface and Assigned(_SslMethodV3) then
Result := _SslMethodV3
else
Result := nil;
end;
function SslMethodTLSV1:PSSL_METHOD;
begin
if InitSSLInterface and Assigned(_SslMethodTLSV1) then
Result := _SslMethodTLSV1
else
Result := nil;
end;
function SslMethodTLSV11:PSSL_METHOD;
begin
if InitSSLInterface and Assigned(_SslMethodTLSV11) then
Result := _SslMethodTLSV11
else
Result := nil;
end;
function SslMethodTLSV12:PSSL_METHOD;
begin
if InitSSLInterface and Assigned(_SslMethodTLSV12) then
Result := _SslMethodTLSV12
else
Result := nil;
end;
function SslMethodV23:PSSL_METHOD;
begin
if InitSSLInterface and Assigned(_SslMethodV23) then
Result := _SslMethodV23
else
Result := nil;
end;
function SslMethodTLS:PSSL_METHOD;
begin
if InitSSLInterface and Assigned(_SslMethodTLS) then
Result := _SslMethodTLS
else
Result := nil;
end;
function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer;
begin
if InitSSLInterface and Assigned(_SslCtxUsePrivateKey) then
Result := _SslCtxUsePrivateKey(ctx, pkey)
else
Result := 0;
end;
function SslCtxUsePrivateKeyASN1(pk: integer; ctx: PSSL_CTX; d: AnsiString; len: integer):Integer;
begin
if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyASN1) then
Result := _SslCtxUsePrivateKeyASN1(pk, ctx, Sslptr(d), len)
else
Result := 0;
end;
//function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer;
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: AnsiString; _type: Integer):Integer;
begin
if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyFile) then
Result := _SslCtxUsePrivateKeyFile(ctx, PAnsiChar(_file), _type)
else
Result := 0;
end;
function SslCtxUseCertificate(ctx: PSSL_CTX; x: SslPtr):Integer;
begin
if InitSSLInterface and Assigned(_SslCtxUseCertificate) then
Result := _SslCtxUseCertificate(ctx, x)
else
Result := 0;
end;
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: integer; d: AnsiString):Integer;
begin
if InitSSLInterface and Assigned(_SslCtxUseCertificateASN1) then
Result := _SslCtxUseCertificateASN1(ctx, len, SslPtr(d))
else
Result := 0;
end;
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: AnsiString; _type: Integer):Integer;
begin
if InitSSLInterface and Assigned(_SslCtxUseCertificateFile) then
Result := _SslCtxUseCertificateFile(ctx, PAnsiChar(_file), _type)
else
Result := 0;
end;
//function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: PChar):Integer;
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: AnsiString):Integer;
begin
if InitSSLInterface and Assigned(_SslCtxUseCertificateChainFile) then
Result := _SslCtxUseCertificateChainFile(ctx, PAnsiChar(_file))
else
Result := 0;
end;
function SslCtxCheckPrivateKeyFile(ctx: PSSL_CTX):Integer;
begin
if InitSSLInterface and Assigned(_SslCtxCheckPrivateKeyFile) then
Result := _SslCtxCheckPrivateKeyFile(ctx)
else
Result := 0;
end;
procedure SslCtxSetDefaultPasswdCb(ctx: PSSL_CTX; cb: PPasswdCb);
begin
if InitSSLInterface and Assigned(_SslCtxSetDefaultPasswdCb) then
_SslCtxSetDefaultPasswdCb(ctx, cb);
end;
procedure SslCtxSetDefaultPasswdCbUserdata(ctx: PSSL_CTX; u: SslPtr);
begin
if InitSSLInterface and Assigned(_SslCtxSetDefaultPasswdCbUserdata) then
_SslCtxSetDefaultPasswdCbUserdata(ctx, u);
end;
//function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):Integer;
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: AnsiString; const CApath: AnsiString):Integer;
begin
if InitSSLInterface and Assigned(_SslCtxLoadVerifyLocations) then
Result := _SslCtxLoadVerifyLocations(ctx, SslPtr(CAfile), SslPtr(CApath))
else
Result := 0;
end;
function SslCtxCtrl(ctx: PSSL_CTX; cmd: integer; larg: integer; parg: SslPtr): integer;
begin
if InitSSLInterface and Assigned(_SslCtxCtrl) then
Result := _SslCtxCtrl(ctx, cmd, larg, parg)
else
Result := 0;
end;
function SslNew(ctx: PSSL_CTX):PSSL;
begin
if InitSSLInterface and Assigned(_SslNew) then
Result := _SslNew(ctx)
else
Result := nil;
end;
procedure SslFree(ssl: PSSL);
begin
if InitSSLInterface and Assigned(_SslFree) then
_SslFree(ssl);
end;
function SslAccept(ssl: PSSL):Integer;
begin
if InitSSLInterface and Assigned(_SslAccept) then
Result := _SslAccept(ssl)
else
Result := -1;
end;
function SslConnect(ssl: PSSL):Integer;
begin
if InitSSLInterface and Assigned(_SslConnect) then
Result := _SslConnect(ssl)
else
Result := -1;
end;
function SslShutdown(ssl: PSSL):Integer;
begin
if InitSSLInterface and Assigned(_SslShutdown) then
Result := _SslShutdown(ssl)
else
Result := -1;
end;
//function SslRead(ssl: PSSL; buf: PChar; num: Integer):Integer;
function SslRead(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
begin
if InitSSLInterface and Assigned(_SslRead) then
Result := _SslRead(ssl, PAnsiChar(buf), num)
else
Result := -1;
end;
//function SslPeek(ssl: PSSL; buf: PChar; num: Integer):Integer;
function SslPeek(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
begin
if InitSSLInterface and Assigned(_SslPeek) then
Result := _SslPeek(ssl, PAnsiChar(buf), num)
else
Result := -1;
end;
//function SslWrite(ssl: PSSL; const buf: PChar; num: Integer):Integer;
function SslWrite(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
begin
if InitSSLInterface and Assigned(_SslWrite) then
Result := _SslWrite(ssl, PAnsiChar(buf), num)
else
Result := -1;
end;
function SslPending(ssl: PSSL):Integer;
begin
if InitSSLInterface and Assigned(_SslPending) then
Result := _SslPending(ssl)
else
Result := 0;
end;
//function SslGetVersion(ssl: PSSL):PChar;
function SslGetVersion(ssl: PSSL):AnsiString;
begin
if InitSSLInterface and Assigned(_SslGetVersion) then
Result := _SslGetVersion(ssl)
else
Result := '';
end;
function SslGetPeerCertificate(ssl: PSSL):PX509;
begin
if InitSSLInterface and Assigned(_SslGetPeerCertificate) then
Result := _SslGetPeerCertificate(ssl)
else
Result := nil;
end;
//procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: Integer; arg2: SslPtr);
procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: Integer; arg2: PFunction);
begin
if InitSSLInterface and Assigned(_SslCtxSetVerify) then
_SslCtxSetVerify(ctx, mode, @arg2);
end;
function SSLGetCurrentCipher(s: PSSL):SslPtr;
begin
if InitSSLInterface and Assigned(_SSLGetCurrentCipher) then
{$IFDEF CIL}
{$ELSE}
Result := _SSLGetCurrentCipher(s)
{$ENDIF}
else
Result := nil;
end;
//function SSLCipherGetName(c: SslPtr):PChar;
function SSLCipherGetName(c: SslPtr):AnsiString;
begin
if InitSSLInterface and Assigned(_SSLCipherGetName) then
Result := _SSLCipherGetName(c)
else
Result := '';
end;
//function SSLCipherGetBits(c: SslPtr; alg_bits: PInteger):Integer;
function SSLCipherGetBits(c: SslPtr; var alg_bits: Integer):Integer;
begin
if InitSSLInterface and Assigned(_SSLCipherGetBits) then
Result := _SSLCipherGetBits(c, @alg_bits)
else
Result := 0;
end;
function SSLGetVerifyResult(ssl: PSSL):Integer;
begin
if InitSSLInterface and Assigned(_SSLGetVerifyResult) then
Result := _SSLGetVerifyResult(ssl)
else
Result := X509_V_ERR_APPLICATION_VERIFICATION;
end;
function SSLCtrl(ssl: PSSL; cmd: integer; larg: integer; parg: SslPtr):Integer;
begin
if InitSSLInterface and Assigned(_SSLCtrl) then
Result := _SSLCtrl(ssl, cmd, larg, parg)
else
Result := X509_V_ERR_APPLICATION_VERIFICATION;
end;
// libeay.dll
function X509New: PX509;
begin
if InitSSLInterface and Assigned(_X509New) then
Result := _X509New
else
Result := nil;
end;
procedure X509Free(x: PX509);
begin
if InitSSLInterface and Assigned(_X509Free) then
_X509Free(x);
end;
//function SslX509NameOneline(a: PX509_NAME; buf: PChar; size: Integer):PChar;
function X509NameOneline(a: PX509_NAME; var buf: AnsiString; size: Integer):AnsiString;
begin
if InitSSLInterface and Assigned(_X509NameOneline) then
Result := _X509NameOneline(a, PAnsiChar(buf),size)
else
Result := '';
end;
function X509GetSubjectName(a: PX509):PX509_NAME;
begin
if InitSSLInterface and Assigned(_X509GetSubjectName) then
Result := _X509GetSubjectName(a)
else
Result := nil;
end;
function X509GetIssuerName(a: PX509):PX509_NAME;
begin
if InitSSLInterface and Assigned(_X509GetIssuerName) then
Result := _X509GetIssuerName(a)
else
Result := nil;
end;
function X509NameHash(x: PX509_NAME):Cardinal;
begin
if InitSSLInterface and Assigned(_X509NameHash) then
Result := _X509NameHash(x)
else
Result := 0;
end;
//function SslX509Digest(data: PX509; _type: PEVP_MD; md: PChar; len: PInteger):Integer;
function X509Digest(data: PX509; _type: PEVP_MD; md: AnsiString; var len: Integer):Integer;
begin
if InitSSLInterface and Assigned(_X509Digest) then
Result := _X509Digest(data, _type, PAnsiChar(md), @len)
else
Result := 0;
end;
function EvpPkeyNew: EVP_PKEY;
begin
if InitSSLInterface and Assigned(_EvpPkeyNew) then
Result := _EvpPkeyNew
else
Result := nil;
end;
procedure EvpPkeyFree(pk: EVP_PKEY);
begin
if InitSSLInterface and Assigned(_EvpPkeyFree) then
_EvpPkeyFree(pk);
end;
function SSLeayversion(t: integer): Ansistring;
begin
if InitSSLInterface and Assigned(_SSLeayversion) then
Result := PAnsiChar(_SSLeayversion(t))
else
Result := '';
end;
procedure ErrErrorString(e: integer; var buf: Ansistring; len: integer);
begin
if InitSSLInterface and Assigned(_ErrErrorString) then
_ErrErrorString(e, Pointer(buf), len);
buf := PAnsiChar(Buf);
end;
function ErrGetError: integer;
begin
if InitSSLInterface and Assigned(_ErrGetError) then
Result := _ErrGetError
else
Result := SSL_ERROR_SSL;
end;
procedure ErrClearError;
begin
if InitSSLInterface and Assigned(_ErrClearError) then
_ErrClearError;
end;
procedure ErrFreeStrings;
begin
if InitSSLInterface and Assigned(_ErrFreeStrings) then
_ErrFreeStrings;
end;
procedure ErrRemoveState(pid: integer);
begin
if InitSSLInterface and Assigned(_ErrRemoveState) then
_ErrRemoveState(pid);
end;
procedure OPENSSLaddallalgorithms;
begin
if InitSSLInterface and Assigned(_OPENSSLaddallalgorithms) then
_OPENSSLaddallalgorithms;
end;
procedure EVPcleanup;
begin
if InitSSLInterface and Assigned(_EVPcleanup) then
_EVPcleanup;
end;
procedure CRYPTOcleanupAllExData;
begin
if InitSSLInterface and Assigned(_CRYPTOcleanupAllExData) then
_CRYPTOcleanupAllExData;
end;
procedure RandScreen;
begin
if InitSSLInterface and Assigned(_RandScreen) then
_RandScreen;
end;
function BioNew(b: PBIO_METHOD): PBIO;
begin
if InitSSLInterface and Assigned(_BioNew) then
Result := _BioNew(b)
else
Result := nil;
end;
procedure BioFreeAll(b: PBIO);
begin
if InitSSLInterface and Assigned(_BioFreeAll) then
_BioFreeAll(b);
end;
function BioSMem: PBIO_METHOD;
begin
if InitSSLInterface and Assigned(_BioSMem) then
Result := _BioSMem
else
Result := nil;
end;
function BioCtrlPending(b: PBIO): integer;
begin
if InitSSLInterface and Assigned(_BioCtrlPending) then
Result := _BioCtrlPending(b)
else
Result := 0;
end;
//function BioRead(b: PBIO; Buf: PChar; Len: integer): integer;
function BioRead(b: PBIO; var Buf: AnsiString; Len: integer): integer;
begin
if InitSSLInterface and Assigned(_BioRead) then
Result := _BioRead(b, PAnsiChar(Buf), Len)
else
Result := -2;
end;
//function BioWrite(b: PBIO; Buf: PChar; Len: integer): integer;
function BioWrite(b: PBIO; Buf: AnsiString; Len: integer): integer;
begin
if InitSSLInterface and Assigned(_BioWrite) then
Result := _BioWrite(b, PAnsiChar(Buf), Len)
else
Result := -2;
end;
function X509print(b: PBIO; a: PX509): integer;
begin
if InitSSLInterface and Assigned(_X509print) then
Result := _X509print(b, a)
else
Result := 0;
end;
function d2iPKCS12bio(b:PBIO; Pkcs12: SslPtr): SslPtr;
begin
if InitSSLInterface and Assigned(_d2iPKCS12bio) then
Result := _d2iPKCS12bio(b, Pkcs12)
else
Result := nil;
end;
function PKCS12parse(p12: SslPtr; pass: Ansistring; var pkey, cert, ca: SslPtr): integer;
begin
if InitSSLInterface and Assigned(_PKCS12parse) then
Result := _PKCS12parse(p12, SslPtr(pass), pkey, cert, ca)
else
Result := 0;
end;
procedure PKCS12free(p12: SslPtr);
begin
if InitSSLInterface and Assigned(_PKCS12free) then
_PKCS12free(p12);
end;
function RsaGenerateKey(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA;
begin
if InitSSLInterface and Assigned(_RsaGenerateKey) then
Result := _RsaGenerateKey(bits, e, callback, cb_arg)
else
Result := nil;
end;
function EvpPkeyAssign(pkey: EVP_PKEY; _type: integer; key: Prsa): integer;
begin
if InitSSLInterface and Assigned(_EvpPkeyAssign) then
Result := _EvpPkeyAssign(pkey, _type, key)
else
Result := 0;
end;
function X509SetVersion(x: PX509; version: integer): integer;
begin
if InitSSLInterface and Assigned(_X509SetVersion) then
Result := _X509SetVersion(x, version)
else
Result := 0;
end;
function X509SetPubkey(x: PX509; pkey: EVP_PKEY): integer;
begin
if InitSSLInterface and Assigned(_X509SetPubkey) then
Result := _X509SetPubkey(x, pkey)
else
Result := 0;
end;
function X509SetIssuerName(x: PX509; name: PX509_NAME): integer;
begin
if InitSSLInterface and Assigned(_X509SetIssuerName) then
Result := _X509SetIssuerName(x, name)
else
Result := 0;
end;
function X509NameAddEntryByTxt(name: PX509_NAME; field: Ansistring; _type: integer;
bytes: Ansistring; len, loc, _set: integer): integer;
begin
if InitSSLInterface and Assigned(_X509NameAddEntryByTxt) then
Result := _X509NameAddEntryByTxt(name, PAnsiChar(field), _type, PAnsiChar(Bytes), len, loc, _set)
else
Result := 0;
end;
function X509Sign(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer;
begin
if InitSSLInterface and Assigned(_X509Sign) then
Result := _X509Sign(x, pkey, md)
else
Result := 0;
end;
function Asn1UtctimeNew: PASN1_UTCTIME;
begin
if InitSSLInterface and Assigned(_Asn1UtctimeNew) then
Result := _Asn1UtctimeNew
else
Result := nil;
end;
procedure Asn1UtctimeFree(a: PASN1_UTCTIME);
begin
if InitSSLInterface and Assigned(_Asn1UtctimeFree) then
_Asn1UtctimeFree(a);
end;
function X509GmtimeAdj(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME;
begin
if InitSSLInterface and Assigned(_X509GmtimeAdj) then
Result := _X509GmtimeAdj(s, adj)
else
Result := nil;
end;
function X509SetNotBefore(x: PX509; tm: PASN1_UTCTIME): integer;
begin
if InitSSLInterface and Assigned(_X509SetNotBefore) then
Result := _X509SetNotBefore(x, tm)
else
Result := 0;
end;
function X509SetNotAfter(x: PX509; tm: PASN1_UTCTIME): integer;
begin
if InitSSLInterface and Assigned(_X509SetNotAfter) then
Result := _X509SetNotAfter(x, tm)
else
Result := 0;
end;
function i2dX509bio(b: PBIO; x: PX509): integer;
begin
if InitSSLInterface and Assigned(_i2dX509bio) then
Result := _i2dX509bio(b, x)
else
Result := 0;
end;
function d2iX509bio(b: PBIO; x: PX509): PX509; {pf}
begin
if InitSSLInterface and Assigned(_d2iX509bio) then
Result := _d2iX509bio(x,b)
else
Result := nil;
end;
function PEMReadBioX509(b:PBIO; {var x:PX509;}x:PSslPtr; callback:PFunction; cb_arg: SslPtr): PX509; {pf}
begin
if InitSSLInterface and Assigned(_PEMReadBioX509) then
Result := _PEMReadBioX509(b,x,callback,cb_arg)
else
Result := nil;
end;
procedure SkX509PopFree(st: PSTACK; func:TSkPopFreeFunc); {pf}
begin
if InitSSLInterface and Assigned(_SkX509PopFree) then
_SkX509PopFree(st,func);
end;
function i2dPrivateKeyBio(b: PBIO; pkey: EVP_PKEY): integer;
begin
if InitSSLInterface and Assigned(_i2dPrivateKeyBio) then
Result := _i2dPrivateKeyBio(b, pkey)
else
Result := 0;
end;
function EvpGetDigestByName(Name: AnsiString): PEVP_MD;
begin
if InitSSLInterface and Assigned(_EvpGetDigestByName) then
Result := _EvpGetDigestByName(PAnsiChar(Name))
else
Result := nil;
end;
function Asn1IntegerSet(a: PASN1_INTEGER; v: integer): integer;
begin
if InitSSLInterface and Assigned(_Asn1IntegerSet) then
Result := _Asn1IntegerSet(a, v)
else
Result := 0;
end;
function Asn1IntegerGet(a: PASN1_INTEGER): integer; {pf}
begin
if InitSSLInterface and Assigned(_Asn1IntegerGet) then
Result := _Asn1IntegerGet(a)
else
Result := 0;
end;
function X509GetSerialNumber(x: PX509): PASN1_INTEGER;
begin
if InitSSLInterface and Assigned(_X509GetSerialNumber) then
Result := _X509GetSerialNumber(x)
else
Result := nil;
end;
// 3DES functions
procedure DESsetoddparity(Key: des_cblock);
begin
if InitSSLInterface and Assigned(_DESsetoddparity) then
_DESsetoddparity(Key);
end;
function DESsetkeychecked(key: des_cblock; schedule: des_key_schedule): Integer;
begin
if InitSSLInterface and Assigned(_DESsetkeychecked) then
Result := _DESsetkeychecked(key, schedule)
else
Result := -1;
end;
procedure DESecbencrypt(Input: des_cblock; output: des_cblock; ks: des_key_schedule; enc: Integer);
begin
if InitSSLInterface and Assigned(_DESecbencrypt) then
_DESecbencrypt(Input, output, ks, enc);
end;
procedure locking_callback(mode, ltype: integer; lfile: PChar; line: integer); cdecl;
begin
if (mode and 1) > 0 then
TCriticalSection(Locks[ltype]).Enter
else
TCriticalSection(Locks[ltype]).Leave;
end;
procedure InitLocks;
var
n: integer;
max: integer;
begin
Locks := TList.Create;
max := _CRYPTOnumlocks;
for n := 1 to max do
Locks.Add(TCriticalSection.Create);
_CRYPTOsetlockingcallback(@locking_callback);
end;
procedure FreeLocks;
var
n: integer;
begin
_CRYPTOsetlockingcallback(nil);
for n := 0 to Locks.Count - 1 do
TCriticalSection(Locks[n]).Free;
Locks.Free;
end;
{$ENDIF}
function LoadLib(const Value: String): HModule;
begin
{$IFDEF CIL}
Result := LoadLibrary(Value);
{$ELSE}
Result := LoadLibrary({$IFDEF WINCE}PwideChar{$ELSE}PChar{$ENDIF}(Value)); //=== ct9999 ====
{$ENDIF}
end;
function GetProcAddr(module: HModule; const ProcName: string): SslPtr;
begin
{$IFDEF CIL}
Result := GetProcAddress(module, ProcName);
{$ELSE}
Result := GetProcAddress(module, {$IFDEF WINCE}PwideChar{$ELSE}PChar{$ENDIF}(ProcName)); //=== ct9999 ====
{$ENDIF}
end;
function InitSSLInterface: Boolean;
var
s: string;
x: integer;
begin
{pf}
if SSLLoaded then
begin
Result := TRUE;
exit;
end;
{/pf}
SSLCS.Enter;
try
if not IsSSLloaded then
begin
{$IFDEF CIL}
SSLLibHandle := 1;
SSLUtilHandle := 1;
{$ELSE}
SSLUtilHandle := LoadLib(DLLUtilName);
SSLLibHandle := LoadLib(DLLSSLName);
{$IFDEF MSWINDOWS}
if (SSLLibHandle = 0) then
SSLLibHandle := LoadLib(DLLSSLName2);
{$ENDIF}
{$ENDIF}
if (SSLLibHandle <> 0) and (SSLUtilHandle <> 0) then
begin
{$IFNDEF CIL}
_SslGetError := GetProcAddr(SSLLibHandle, 'SSL_get_error');
_SslLibraryInit := GetProcAddr(SSLLibHandle, 'SSL_library_init');
_SslLoadErrorStrings := GetProcAddr(SSLLibHandle, 'SSL_load_error_strings');
_SslCtxSetCipherList := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_cipher_list');
_SslCtxNew := GetProcAddr(SSLLibHandle, 'SSL_CTX_new');
_SslCtxFree := GetProcAddr(SSLLibHandle, 'SSL_CTX_free');
_SslSetFd := GetProcAddr(SSLLibHandle, 'SSL_set_fd');
_SslMethodV2 := GetProcAddr(SSLLibHandle, 'SSLv2_method');
_SslMethodV3 := GetProcAddr(SSLLibHandle, 'SSLv3_method');
_SslMethodTLSV1 := GetProcAddr(SSLLibHandle, 'TLSv1_method');
_SslMethodTLSV11 := GetProcAddr(SSLLibHandle, 'TLSv1_1_method');
_SslMethodTLSV12 := GetProcAddr(SSLLibHandle, 'TLSv1_2_method');
_SslMethodV23 := GetProcAddr(SSLLibHandle, 'SSLv23_method');
_SslMethodTLS := GetProcAddr(SSLLibHandle, 'TLS_method');
_SslCtxUsePrivateKey := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_PrivateKey');
_SslCtxUsePrivateKeyASN1 := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_PrivateKey_ASN1');
//use SSL_CTX_use_RSAPrivateKey_file instead SSL_CTX_use_PrivateKey_file,
//because SSL_CTX_use_PrivateKey_file not support DER format. :-O
_SslCtxUsePrivateKeyFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_RSAPrivateKey_file');
_SslCtxUseCertificate := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate');
_SslCtxUseCertificateASN1 := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate_ASN1');
_SslCtxUseCertificateFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate_file');
_SslCtxUseCertificateChainFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate_chain_file');
_SslCtxCheckPrivateKeyFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_check_private_key');
_SslCtxSetDefaultPasswdCb := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_default_passwd_cb');
_SslCtxSetDefaultPasswdCbUserdata := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_default_passwd_cb_userdata');
_SslCtxLoadVerifyLocations := GetProcAddr(SSLLibHandle, 'SSL_CTX_load_verify_locations');
_SslCtxCtrl := GetProcAddr(SSLLibHandle, 'SSL_CTX_ctrl');
_SslNew := GetProcAddr(SSLLibHandle, 'SSL_new');
_SslFree := GetProcAddr(SSLLibHandle, 'SSL_free');
_SslAccept := GetProcAddr(SSLLibHandle, 'SSL_accept');
_SslConnect := GetProcAddr(SSLLibHandle, 'SSL_connect');
_SslShutdown := GetProcAddr(SSLLibHandle, 'SSL_shutdown');
_SslRead := GetProcAddr(SSLLibHandle, 'SSL_read');
_SslPeek := GetProcAddr(SSLLibHandle, 'SSL_peek');
_SslWrite := GetProcAddr(SSLLibHandle, 'SSL_write');
_SslPending := GetProcAddr(SSLLibHandle, 'SSL_pending');
_SslGetPeerCertificate := GetProcAddr(SSLLibHandle, 'SSL_get_peer_certificate');
_SslGetVersion := GetProcAddr(SSLLibHandle, 'SSL_get_version');
_SslCtxSetVerify := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_verify');
_SslGetCurrentCipher := GetProcAddr(SSLLibHandle, 'SSL_get_current_cipher');
_SslCipherGetName := GetProcAddr(SSLLibHandle, 'SSL_CIPHER_get_name');
_SslCipherGetBits := GetProcAddr(SSLLibHandle, 'SSL_CIPHER_get_bits');
_SslGetVerifyResult := GetProcAddr(SSLLibHandle, 'SSL_get_verify_result');
_SslCtrl := GetProcAddr(SSLLibHandle, 'SSL_ctrl');
_X509New := GetProcAddr(SSLUtilHandle, 'X509_new');
_X509Free := GetProcAddr(SSLUtilHandle, 'X509_free');
_X509NameOneline := GetProcAddr(SSLUtilHandle, 'X509_NAME_oneline');
_X509GetSubjectName := GetProcAddr(SSLUtilHandle, 'X509_get_subject_name');
_X509GetIssuerName := GetProcAddr(SSLUtilHandle, 'X509_get_issuer_name');
_X509NameHash := GetProcAddr(SSLUtilHandle, 'X509_NAME_hash');
_X509Digest := GetProcAddr(SSLUtilHandle, 'X509_digest');
_X509print := GetProcAddr(SSLUtilHandle, 'X509_print');
_X509SetVersion := GetProcAddr(SSLUtilHandle, 'X509_set_version');
_X509SetPubkey := GetProcAddr(SSLUtilHandle, 'X509_set_pubkey');
_X509SetIssuerName := GetProcAddr(SSLUtilHandle, 'X509_set_issuer_name');
_X509NameAddEntryByTxt := GetProcAddr(SSLUtilHandle, 'X509_NAME_add_entry_by_txt');
_X509Sign := GetProcAddr(SSLUtilHandle, 'X509_sign');
_X509GmtimeAdj := GetProcAddr(SSLUtilHandle, 'X509_gmtime_adj');
_X509SetNotBefore := GetProcAddr(SSLUtilHandle, 'X509_set_notBefore');
_X509SetNotAfter := GetProcAddr(SSLUtilHandle, 'X509_set_notAfter');
_X509GetSerialNumber := GetProcAddr(SSLUtilHandle, 'X509_get_serialNumber');
_EvpPkeyNew := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_new');
_EvpPkeyFree := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_free');
_EvpPkeyAssign := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_assign');
_EVPCleanup := GetProcAddr(SSLUtilHandle, 'EVP_cleanup');
_EvpGetDigestByName := GetProcAddr(SSLUtilHandle, 'EVP_get_digestbyname');
_SSLeayversion := GetProcAddr(SSLUtilHandle, 'SSLeay_version');
_ErrErrorString := GetProcAddr(SSLUtilHandle, 'ERR_error_string_n');
_ErrGetError := GetProcAddr(SSLUtilHandle, 'ERR_get_error');
_ErrClearError := GetProcAddr(SSLUtilHandle, 'ERR_clear_error');
_ErrFreeStrings := GetProcAddr(SSLUtilHandle, 'ERR_free_strings');
_ErrRemoveState := GetProcAddr(SSLUtilHandle, 'ERR_remove_state');
_OPENSSLaddallalgorithms := GetProcAddr(SSLUtilHandle, 'OPENSSL_add_all_algorithms_noconf');
_CRYPTOcleanupAllExData := GetProcAddr(SSLUtilHandle, 'CRYPTO_cleanup_all_ex_data');
_RandScreen := GetProcAddr(SSLUtilHandle, 'RAND_screen');
_BioNew := GetProcAddr(SSLUtilHandle, 'BIO_new');
_BioFreeAll := GetProcAddr(SSLUtilHandle, 'BIO_free_all');
_BioSMem := GetProcAddr(SSLUtilHandle, 'BIO_s_mem');
_BioCtrlPending := GetProcAddr(SSLUtilHandle, 'BIO_ctrl_pending');
_BioRead := GetProcAddr(SSLUtilHandle, 'BIO_read');
_BioWrite := GetProcAddr(SSLUtilHandle, 'BIO_write');
_d2iPKCS12bio := GetProcAddr(SSLUtilHandle, 'd2i_PKCS12_bio');
_PKCS12parse := GetProcAddr(SSLUtilHandle, 'PKCS12_parse');
_PKCS12free := GetProcAddr(SSLUtilHandle, 'PKCS12_free');
_RsaGenerateKey := GetProcAddr(SSLUtilHandle, 'RSA_generate_key');
_Asn1UtctimeNew := GetProcAddr(SSLUtilHandle, 'ASN1_UTCTIME_new');
_Asn1UtctimeFree := GetProcAddr(SSLUtilHandle, 'ASN1_UTCTIME_free');
_Asn1IntegerSet := GetProcAddr(SSLUtilHandle, 'ASN1_INTEGER_set');
_Asn1IntegerGet := GetProcAddr(SSLUtilHandle, 'ASN1_INTEGER_get'); {pf}
_i2dX509bio := GetProcAddr(SSLUtilHandle, 'i2d_X509_bio');
_d2iX509bio := GetProcAddr(SSLUtilHandle, 'd2i_X509_bio'); {pf}
_PEMReadBioX509 := GetProcAddr(SSLUtilHandle, 'PEM_read_bio_X509'); {pf}
_SkX509PopFree := GetProcAddr(SSLUtilHandle, 'SK_X509_POP_FREE'); {pf}
_i2dPrivateKeyBio := GetProcAddr(SSLUtilHandle, 'i2d_PrivateKey_bio');
// 3DES functions
_DESsetoddparity := GetProcAddr(SSLUtilHandle, 'DES_set_odd_parity');
_DESsetkeychecked := GetProcAddr(SSLUtilHandle, 'DES_set_key_checked');
_DESecbencrypt := GetProcAddr(SSLUtilHandle, 'DES_ecb_encrypt');
//
_CRYPTOnumlocks := GetProcAddr(SSLUtilHandle, 'CRYPTO_num_locks');
_CRYPTOsetlockingcallback := GetProcAddr(SSLUtilHandle, 'CRYPTO_set_locking_callback');
{$ENDIF}
{$IFDEF CIL}
SslLibraryInit;
SslLoadErrorStrings;
OPENSSLaddallalgorithms;
RandScreen;
{$ELSE}
SetLength(s, 1024);
x := GetModuleFilename(SSLLibHandle,{$IFDEF WINCE}PwideChar{$ELSE}PChar{$ENDIF}(s),Length(s)); //=== ct9999 ====
SetLength(s, x);
SSLLibFile := s;
SetLength(s, 1024);
x := GetModuleFilename(SSLUtilHandle,{$IFDEF WINCE}PwideChar{$ELSE}PChar{$ENDIF}(s),Length(s)); //=== ct9999 ====
SetLength(s, x);
SSLUtilFile := s;
//init library
if assigned(_SslLibraryInit) then
_SslLibraryInit;
if assigned(_SslLoadErrorStrings) then
_SslLoadErrorStrings;
if assigned(_OPENSSLaddallalgorithms) then
_OPENSSLaddallalgorithms;
if assigned(_RandScreen) then
_RandScreen;
if assigned(_CRYPTOnumlocks) and assigned(_CRYPTOsetlockingcallback) then
InitLocks;
{$ENDIF}
SSLloaded := True;
{$IFDEF OS2}
Result := InitEMXHandles;
{$ELSE OS2}
Result := True;
{$ENDIF OS2}
end
else
begin
//load failed!
if SSLLibHandle <> 0 then
begin
{$IFNDEF CIL}
FreeLibrary(SSLLibHandle);
{$ENDIF}
SSLLibHandle := 0;
end;
if SSLUtilHandle <> 0 then
begin
{$IFNDEF CIL}
FreeLibrary(SSLUtilHandle);
{$ENDIF}
SSLLibHandle := 0;
end;
Result := False;
end;
end
else
//loaded before...
Result := true;
finally
SSLCS.Leave;
end;
end;
function DestroySSLInterface: Boolean;
begin
SSLCS.Enter;
try
if IsSSLLoaded then
begin
//deinit library
{$IFNDEF CIL}
if assigned(_CRYPTOnumlocks) and assigned(_CRYPTOsetlockingcallback) then
FreeLocks;
{$ENDIF}
EVPCleanup;
CRYPTOcleanupAllExData;
ErrRemoveState(0);
end;
SSLloaded := false;
if SSLLibHandle <> 0 then
begin
{$IFNDEF CIL}
FreeLibrary(SSLLibHandle);
{$ENDIF}
SSLLibHandle := 0;
end;
if SSLUtilHandle <> 0 then
begin
{$IFNDEF CIL}
FreeLibrary(SSLUtilHandle);
{$ENDIF}
SSLLibHandle := 0;
end;
{$IFNDEF CIL}
_SslGetError := nil;
_SslLibraryInit := nil;
_SslLoadErrorStrings := nil;
_SslCtxSetCipherList := nil;
_SslCtxNew := nil;
_SslCtxFree := nil;
_SslSetFd := nil;
_SslMethodV2 := nil;
_SslMethodV3 := nil;
_SslMethodTLSV1 := nil;
_SslMethodTLSV11 := nil;
_SslMethodTLSV12 := nil;
_SslMethodV23 := nil;
_SslMethodTLS := nil;
_SslCtxUsePrivateKey := nil;
_SslCtxUsePrivateKeyASN1 := nil;
_SslCtxUsePrivateKeyFile := nil;
_SslCtxUseCertificate := nil;
_SslCtxUseCertificateASN1 := nil;
_SslCtxUseCertificateFile := nil;
_SslCtxUseCertificateChainFile := nil;
_SslCtxCheckPrivateKeyFile := nil;
_SslCtxSetDefaultPasswdCb := nil;
_SslCtxSetDefaultPasswdCbUserdata := nil;
_SslCtxLoadVerifyLocations := nil;
_SslCtxCtrl := nil;
_SslNew := nil;
_SslFree := nil;
_SslAccept := nil;
_SslConnect := nil;
_SslShutdown := nil;
_SslRead := nil;
_SslPeek := nil;
_SslWrite := nil;
_SslPending := nil;
_SslGetPeerCertificate := nil;
_SslGetVersion := nil;
_SslCtxSetVerify := nil;
_SslGetCurrentCipher := nil;
_SslCipherGetName := nil;
_SslCipherGetBits := nil;
_SslGetVerifyResult := nil;
_SslCtrl := nil;
_X509New := nil;
_X509Free := nil;
_X509NameOneline := nil;
_X509GetSubjectName := nil;
_X509GetIssuerName := nil;
_X509NameHash := nil;
_X509Digest := nil;
_X509print := nil;
_X509SetVersion := nil;
_X509SetPubkey := nil;
_X509SetIssuerName := nil;
_X509NameAddEntryByTxt := nil;
_X509Sign := nil;
_X509GmtimeAdj := nil;
_X509SetNotBefore := nil;
_X509SetNotAfter := nil;
_X509GetSerialNumber := nil;
_EvpPkeyNew := nil;
_EvpPkeyFree := nil;
_EvpPkeyAssign := nil;
_EVPCleanup := nil;
_EvpGetDigestByName := nil;
_SSLeayversion := nil;
_ErrErrorString := nil;
_ErrGetError := nil;
_ErrClearError := nil;
_ErrFreeStrings := nil;
_ErrRemoveState := nil;
_OPENSSLaddallalgorithms := nil;
_CRYPTOcleanupAllExData := nil;
_RandScreen := nil;
_BioNew := nil;
_BioFreeAll := nil;
_BioSMem := nil;
_BioCtrlPending := nil;
_BioRead := nil;
_BioWrite := nil;
_d2iPKCS12bio := nil;
_PKCS12parse := nil;
_PKCS12free := nil;
_RsaGenerateKey := nil;
_Asn1UtctimeNew := nil;
_Asn1UtctimeFree := nil;
_Asn1IntegerSet := nil;
_Asn1IntegerGet := nil; {pf}
_SkX509PopFree := nil; {pf}
_i2dX509bio := nil;
_i2dPrivateKeyBio := nil;
// 3DES functions
_DESsetoddparity := nil;
_DESsetkeychecked := nil;
_DESecbencrypt := nil;
//
_CRYPTOnumlocks := nil;
_CRYPTOsetlockingcallback := nil;
{$ENDIF}
finally
SSLCS.Leave;
end;
Result := True;
end;
function IsSSLloaded: Boolean;
begin
Result := SSLLoaded;
end;
initialization
begin
SSLCS:= TCriticalSection.Create;
end;
finalization
begin
{$IFNDEF CIL}
DestroySSLInterface;
{$ENDIF}
SSLCS.Free;
end;
end.
| 37.442186 | 122 | 0.706238 |
fc63720470ef2e31cfdb0965b4e0556abcfce7f5 | 10,870 | pas | Pascal | Codigo/unitParametro.pas | MDsolucoesTI/Apolo | 76253d1dea34056f0363f76b802905e8150bba12 | [
"MIT"
]
| null | null | null | Codigo/unitParametro.pas | MDsolucoesTI/Apolo | 76253d1dea34056f0363f76b802905e8150bba12 | [
"MIT"
]
| null | null | null | Codigo/unitParametro.pas | MDsolucoesTI/Apolo | 76253d1dea34056f0363f76b802905e8150bba12 | [
"MIT"
]
| 1 | 2021-12-03T08:17:22.000Z | 2021-12-03T08:17:22.000Z | //////////////////////////////////////////////////////////////////////////
// Criacao...........: 08/2002
// Sistema...........: Apolo - Automacao Clinica Medica
// Analistas.........: Marilene Esquiavoni & Denny Paulista Azevedo Filho
// Desenvolvedores...: Marilene Esquiavoni & Denny Paulista Azevedo Filho
// Copyright.........: Marilene Esquiavoni & Denny Paulista Azevedo Filho
//////////////////////////////////////////////////////////////////////////
unit unitParametro;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
fcButton, fcImgBtn, RackCtls, StdCtrls, DBCtrls, ToolEdit, RXDBCtrl,
Mask, RXSplit, RXCtrls, ExtCtrls, SpeedBar, jpeg, ComCtrls, SRColBtn,
ExtDlgs, VerCPF, VerCNPJ, DCStdCtrls, LMDCustomComponent, LMDCustomHint,
LMDCustomShapeHint, LMDShapeHint, EDBZero, EHintBal, RxGrdCpt, fcImager;
type
TFrmParametro = class(TForm)
AbreFigura: TOpenPictureDialog;
VerCNPJ1: TVerCNPJ;
VerCPF1: TVerCPF;
Panel2: TPanel;
pgcConfig: TDCPageControl;
tbsDiversos: TDCPage;
tbsValores: TDCPage;
lbempresa: TRxLabel;
dbEmpresa: TDBEdit;
lbie: TRxLabel;
dbIE: TDBEdit;
lbprop: TRxLabel;
dbProp: TDBEdit;
lbcgc: TRxLabel;
dbCGC: TDBEdit;
dbCPF: TDBEdit;
lbcpf: TRxLabel;
lbendereco: TRxLabel;
DBend: TDBEdit;
lbnumero: TRxLabel;
lbcomplemento: TRxLabel;
DBcompl: TDBEdit;
lbuf: TRxLabel;
DBCBoxUF: TDBComboBox;
DBcep: TDBEdit;
lbcep: TRxLabel;
DBcidade: TDBEdit;
lbcidade: TRxLabel;
DBbairro: TDBEdit;
lbBairro: TRxLabel;
lbtel1: TRxLabel;
DBtel1: TDBEdit;
lbtel2: TRxLabel;
DBTel2: TDBEdit;
lbcelular: TRxLabel;
DBcel: TDBEdit;
lbicms: TRxLabel;
dbicms: TDBEdit;
lbMensPromo: TRxLabel;
dbMensPromo: TDBEdit;
lbMensRodape: TRxLabel;
dbMensRodape: TDBEdit;
Image7: TImage;
Label3: TLabel;
Label4: TLabel;
dblogo: TDBImage;
RxLabel19: TRxLabel;
RxLabel22: TRxLabel;
tbsEmpresa: TDCPage;
dbPis: TDBEdit;
RxLabel3: TRxLabel;
dbCofins: TDBEdit;
RxLabel4: TRxLabel;
dbCS: TDBEdit;
RxLabel5: TRxLabel;
dbNum: TEvDBZeroEdit;
Panel1: TPanel;
RxLabel15: TRxLabel;
Image1: TImage;
Panel4: TPanel;
btnCancelar: TfcImageBtn;
btnGravar: TfcImageBtn;
fcImager6: TfcImager;
Bevel1: TBevel;
RxLabel23: TRxLabel;
dbjurosdias: TDBEdit;
dbjurosvalor: TDBEdit;
RxLabel24: TRxLabel;
RxLabel25: TRxLabel;
dbjurosperc: TDBEdit;
RxLabel26: TRxLabel;
dbmultadias: TDBEdit;
dbmultaperc: TDBEdit;
RxLabel27: TRxLabel;
dbmultavalor: TDBEdit;
RxLabel28: TRxLabel;
RxLabel6: TRxLabel;
RxLabel7: TRxLabel;
RxLabel29: TRxLabel;
dbdescdias: TDBEdit;
dbdescvalor: TDBEdit;
RxLabel30: TRxLabel;
RxLabel31: TRxLabel;
dbdescperc: TDBEdit;
RxLabel8: TRxLabel;
RxLabel32: TRxLabel;
dbcredito: TDBEdit;
dbcomissao: TDBEdit;
RxLabel20: TRxLabel;
RxLabel9: TRxLabel;
RxLabel1: TRxLabel;
rbEntrada: TRadioButton;
rbSaida: TRadioButton;
RxLabel2: TRxLabel;
RxLabel10: TRxLabel;
Bevel6: TBevel;
Bevel7: TBevel;
Bevel8: TBevel;
Bevel4: TBevel;
Bevel5: TBevel;
Bevel2: TBevel;
Bevel3: TBevel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure dbCGCExit(Sender: TObject);
procedure dbCPFExit(Sender: TObject);
procedure DBcelExit(Sender: TObject);
procedure btempresaClick(Sender: TObject);
procedure btdiversosClick(Sender: TObject);
procedure btvaloresClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BtnGravarClick(Sender: TObject);
procedure btnCancelarClick(Sender: TObject);
procedure dblogoDblClick(Sender: TObject);
procedure rbEntradaClick(Sender: TObject);
procedure rbSaidaClick(Sender: TObject);
procedure tbsValoresShow(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure dblogoExit(Sender: TObject);
procedure btnConfirmarClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmParametro: TFrmParametro;
implementation
uses UnitDmdados, UnitPrincipal;
{$R *.DFM}
procedure TFrmParametro.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FrmPrincipal.StatusTeclas(False,'');
Action:= Cafree;
end;
procedure TFrmParametro.FormKeyPress(Sender: TObject; var Key: Char);
begin
If Key=#13 Then
Begin
Key:=#0;
Perform(wm_nextdlgctl,0,0);
End;
end;
procedure TFrmParametro.dbCGCExit(Sender: TObject);
begin
VerCnpj1.NumCnpj:= dbcgc.text;
If not VerCnpj1.valid Then
Begin
Showmessage('CGC inv�lido');
dbcgc.Clear;
dbcgc.setfocus;
End;
end;
procedure TFrmParametro.dbCPFExit(Sender: TObject);
begin
VerCpf1.NumeroCpf:= dbcpf.text;
If not VerCpf1.valid Then
Begin
Showmessage('CPF inv�lido');
dbcpf.Clear;
dbcpf.setfocus;
End;
end;
procedure TFrmParametro.DBcelExit(Sender: TObject);
begin
pgcConfig.ActivePage:=tbsDiversos;
end;
procedure TFrmParametro.btempresaClick(Sender: TObject);
begin
pgcConfig.ActivePage:=tbsEmpresa;
tbsempresa.Enabled:=true;
end;
procedure TFrmParametro.btdiversosClick(Sender: TObject);
begin
pgcConfig.ActivePage:=tbsDiversos;
tbsDiversos.Enabled:=true;
dbicms.SetFocus;
end;
procedure TFrmParametro.btvaloresClick(Sender: TObject);
begin
pgcConfig.ActivePage:=tbsValores;
tbsvalores.Enabled:=true;
dbjurosdias.SetFocus;
end;
procedure TFrmParametro.FormShow(Sender: TObject);
begin
FrmPrincipal.StatusTeclas(True,'[End] Gravar [Esc] Cancelar');
If dmDados.TbParametro.RecordCount=0 Then
Begin
dmDados.TbParametro.Append;
pgcConfig.ActivePage:=tbsEmpresa;
dbempresa.SetFocus;
End
Else
Begin
dmDados.TbParametro.First;
dmdados.TbParametro.Edit;
pgcConfig.ActivePage:=tbsEmpresa;
dbempresa.SetFocus;
End;
end;
procedure TFrmParametro.BtnGravarClick(Sender: TObject);
Var
Campos:String;
Vazio,Gravar:Boolean;
BEGIN
Campos:='';
Gravar:=True;
Vazio:=False;
If dbempresa.Text='' Then
Begin
If Length(Campos)>0 Then
Campos:=Campos+', ';
Campos:='Empresa';
Gravar:=False;
Vazio:=True;
End;
If dbCpf.Text=' ' Then
Begin
If Length(Campos)>0 Then
Campos:=Campos+', ';
Campos:=Campos+'CPF';
Gravar:=False;
Vazio:=True;
End
Else
Begin
VerCPF1.NumeroCPF:= dbcpf.text;
If not VerCpf1.valid Then
Begin
Showmessage('CPF inv�lido');
Gravar:=False;
End;
end;
If dbCgc.Text=' ' Then
Begin
If Length(Campos)>0 Then
Campos:=Campos+', ';
Campos:=Campos+'CNPJ';
Gravar:=False;
Vazio:=True;
End
Else
begin
VerCnpj1.NumCnpj:= dbcgc.text;
If not VerCnpj1.valid Then
Begin
Showmessage('CNPJ inv�lido');
Gravar:=False;
end;
end;
If Gravar Then
Begin
dmdados.TbParametro.Post;
ShowMessage('Dados gravados com sucesso');
Close;
End
Else
Begin
If Vazio Then
ShowMessage('O(s) Campo(s) '+Campos+' n�o tem Valor(es) ');
dbempresa.SetFocus;
end;
end;
procedure TFrmParametro.btnCancelarClick(Sender: TObject);
begin
dmdados.TbParametro.cancel;
Close;
end;
procedure TFrmParametro.dblogoDblClick(Sender: TObject);
begin
with AbreFigura do
if Execute then DMdados.tbparametroLogo.LoadFromFile(AbreFigura.FileName);
end;
procedure TFrmParametro.rbEntradaClick(Sender: TObject);
begin
dmDados.TbParametroDecoEntra.Value:='S';
end;
procedure TFrmParametro.rbSaidaClick(Sender: TObject);
begin
dmDados.TbParametroDecoEntra.Value:='N';
end;
procedure TFrmParametro.tbsValoresShow(Sender: TObject);
begin
if dmdados.TbParametroDecoEntra.Value='S' then
begin
rbEntrada.Checked:=True;
rbSaida.Checked:=False;
end
else
begin
rbEntrada.Checked:=True;
rbSaida.Checked:=False;
end;
end;
procedure TFrmParametro.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case (key) of
VK_END : BtnGravar.Click;
VK_ESCAPE : BtnCancelar.Click;
VK_F2 : dblogoDblClick(Sender);
VK_PRIOR : begin
if pgcConfig.ActivePage=tbsEmpresa then
pgcConfig.ActivePage:=tbsDiversos
else if pgcConfig.ActivePage=tbsDiversos then
pgcConfig.ActivePage:=tbsValores
else
pgcConfig.ActivePage:=tbsEmpresa;
end;
VK_NEXT : begin
if pgcConfig.ActivePage=tbsValores then
pgcConfig.ActivePage:=tbsDiversos
else if pgcConfig.ActivePage=tbsDiversos then
pgcConfig.ActivePage:=tbsEmpresa
else
pgcConfig.ActivePage:=tbsValores;
end;
end;
end;
procedure TFrmParametro.dblogoExit(Sender: TObject);
begin
pgcConfig.ActivePage:=tbsvalores;
end;
procedure TFrmParametro.btnConfirmarClick(Sender: TObject);
Var
Campos:String;
Vazio,Gravar:Boolean;
BEGIN
Campos:='';
Gravar:=True;
Vazio:=False;
If dbempresa.Text='' Then
Begin
If Length(Campos)>0 Then
Campos:=Campos+', ';
Campos:='Empresa';
Gravar:=False;
Vazio:=True;
End;
If dbCpf.Text=' ' Then
Begin
If Length(Campos)>0 Then
Campos:=Campos+', ';
Campos:=Campos+'CPF';
Gravar:=False;
Vazio:=True;
End
Else
Begin
VerCPF1.NumeroCPF:= dbcpf.text;
If not VerCpf1.valid Then
Begin
Showmessage('CPF inv�lido');
Gravar:=False;
End;
end;
If dbCgc.Text=' ' Then
Begin
If Length(Campos)>0 Then
Campos:=Campos+', ';
Campos:=Campos+'CNPJ';
Gravar:=False;
Vazio:=True;
End
Else
begin
VerCnpj1.NumCnpj:= dbcgc.text;
If not VerCnpj1.valid Then
Begin
Showmessage('CNPJ inv�lido');
Gravar:=False;
end;
end;
If Gravar Then
Begin
dmdados.TbParametro.Post;
ShowMessage('Dados gravados com sucesso');
Close;
End
Else
Begin
If Vazio Then
ShowMessage('O(s) Campo(s) '+Campos+' n�o tem Valor(es) ');
dbempresa.SetFocus;
end;
end;
end.
| 24.988506 | 79 | 0.637075 |
6a6c92b685418806de3dd12a7149f1152e3e7c5a | 2,225 | pas | Pascal | view/uUsuarioLoginView.pas | RickMao/mvcdelphi | 9f2b7ca714aba25e6918964975acba91298c998e | [
"Unlicense"
]
| null | null | null | view/uUsuarioLoginView.pas | RickMao/mvcdelphi | 9f2b7ca714aba25e6918964975acba91298c998e | [
"Unlicense"
]
| null | null | null | view/uUsuarioLoginView.pas | RickMao/mvcdelphi | 9f2b7ca714aba25e6918964975acba91298c998e | [
"Unlicense"
]
| 1 | 2019-10-31T17:41:00.000Z | 2019-10-31T17:41:00.000Z | unit uUsuarioLoginView;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
uUsuarioViewInterface, uUsuarioLoginScreen, uUsuarioControllerInterface;
type
TUsuarioView = class(TInterfacedObject, IUsuarioViewInterface)
protected
FLogado:Integer;
FTela:TUsuarioLoginScreen;
FController:IUsuarioControllerInterface;
function getNome:String;
function getSenha:String;
procedure setNome(const Value: String);
procedure setSenha(const Value: String);
property Nome:String read getNome write setNome;
property Senha:String read getSenha write setSenha;
procedure btnLogarclick(Sender:TObject);
procedure btnCancelarclick(Sender:TObject);
public
constructor Cria_Se;
destructor Destrua_Se;
function login:Integer;
procedure recebeControle(Controller:IUsuarioControllerInterface);
end;
implementation
uses
uUsuarioController;
{ TUsuarioView }
procedure TUsuarioView.btnCancelarclick(Sender: TObject);
begin
FLogado:=2;
FTela.Close;
end;
procedure TUsuarioView.btnLogarclick(Sender: TObject);
begin
if FController.login then FLogado:=1;
FTela.Close;
end;
constructor TUsuarioView.Cria_Se;
begin
inherited;
Application.CreateForm(TUsuarioLoginScreen, FTela);
FTela.btnCancelar.OnClick:=btnCancelarclick;
FTela.btnLogar.OnClick:=btnLogarclick;
FLogado:=0;
end;
destructor TUsuarioView.Destrua_Se;
begin
FreeAndNil(FTela);
inherited;
end;
function TUsuarioView.getNome: String;
begin
Result:=FTela.Nome.Text;
end;
function TUsuarioView.getSenha: String;
begin
Result:=FTela.Senha.Text;
end;
function TUsuarioView.login: Integer;
begin
FTela.Nome.Clear;
FTela.Senha.Clear;
FTela.ShowModal;
Result:=FLogado;
end;
procedure TUsuarioView.recebeControle(Controller: IUsuarioControllerInterface);
begin
FController:=Controller;
end;
procedure TUsuarioView.setNome(const Value: String);
begin
FTela.Nome.Text:=Value;
end;
procedure TUsuarioView.setSenha(const Value: String);
begin
FTela.Senha.Text:=Value;
end;
end.
| 22.474747 | 80 | 0.748315 |
c3895d6723d4886808a296dc817e9f3658c01e86 | 6,177 | dfm | Pascal | Demos/Modules/rdSetClient.dfm | maciej-izak/portal | 3ede43bee52fee8ef662e43194a9c1ff4148da54 | [
"MIT"
]
| 8 | 2019-01-16T15:58:54.000Z | 2022-01-22T02:57:19.000Z | Demos/Modules/rdSetClient.dfm | leivio/portal | 3ede43bee52fee8ef662e43194a9c1ff4148da54 | [
"MIT"
]
| 2 | 2019-06-17T05:36:35.000Z | 2019-11-08T17:50:14.000Z | Demos/Modules/rdSetClient.dfm | leivio/portal | 3ede43bee52fee8ef662e43194a9c1ff4148da54 | [
"MIT"
]
| 8 | 2019-01-17T04:43:43.000Z | 2020-09-12T00:45:38.000Z | object rdClientSettings: TrdClientSettings
Left = 554
Top = 226
BorderIcons = []
BorderStyle = bsDialog
Caption = 'Connection Settings'
ClientHeight = 340
ClientWidth = 273
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Arial'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PrintScale = poNone
Scaled = False
PixelsPerInch = 120
TextHeight = 14
object Label2: TLabel
Left = 56
Top = 104
Width = 19
Height = 14
Alignment = taRightJustify
Caption = 'Port'
end
object Label7: TLabel
Left = 14
Top = 236
Width = 57
Height = 14
Alignment = taRightJustify
Caption = 'Secure Key'
end
object Label13: TLabel
Left = 28
Top = 32
Width = 42
Height = 14
Alignment = taRightJustify
Caption = 'Address'
end
object Label22: TLabel
Left = 12
Top = 284
Width = 258
Height = 14
Caption = 'More Compression = less Traffic but more CPU usage'
end
object Label18: TLabel
Left = 12
Top = 260
Width = 63
Height = 14
Caption = 'Compression'
end
object Label12: TLabel
Left = 8
Top = 8
Width = 210
Height = 14
Caption = 'Gateway information (where to connect) ...'
end
object eAddress: TEdit
Left = 80
Top = 28
Width = 185
Height = 22
Hint = 'Enter Gateway Address here'
TabOrder = 0
end
object ePort: TEdit
Left = 80
Top = 100
Width = 93
Height = 22
Hint = 'Enter Gateway Port here'
TabOrder = 6
end
object eSecureKey: TEdit
Left = 80
Top = 232
Width = 185
Height = 22
Hint = 'Enter the Secure Key set up on the Gateway'
PasswordChar = '*'
TabOrder = 8
end
object xProxy: TCheckBox
Left = 128
Top = 76
Width = 57
Height = 21
Hint = 'if you are behind a HTTP Proxy, check this box'
TabStop = False
Caption = 'Proxy'
TabOrder = 4
OnClick = xProxyClick
end
object xSSL: TCheckBox
Left = 80
Top = 76
Width = 49
Height = 21
TabStop = False
Caption = 'SSL'
TabOrder = 3
OnClick = xSSLClick
end
object eISAPI: TEdit
Left = 80
Top = 52
Width = 185
Height = 22
Hint = 'Enter the PATH to the Gateway ISAPI DLL'
Color = clGray
Enabled = False
TabOrder = 2
end
object xISAPI: TCheckBox
Left = 24
Top = 52
Width = 53
Height = 21
Hint = 'Is the Gateway running as an ISAPI DLL?'
TabStop = False
Caption = 'ISAPI'
TabOrder = 1
OnClick = xISAPIClick
end
object cbCompress: TComboBox
Left = 80
Top = 256
Width = 185
Height = 22
Style = csDropDownList
DropDownCount = 15
ItemHeight = 14
TabOrder = 9
Items.Strings = (
'Normal'
'Maximum'
'Minimum')
end
object btnCancel: TBitBtn
Left = 12
Top = 304
Width = 75
Height = 29
TabOrder = 11
OnClick = btnCancelClick
Kind = bkCancel
end
object btnOK: TBitBtn
Left = 188
Top = 304
Width = 75
Height = 29
Caption = 'OK'
Default = True
ModalResult = 1
TabOrder = 10
OnClick = btnOKClick
Glyph.Data = {
DE010000424DDE01000000000000760000002800000024000000120000000100
0400000000006801000000000000000000001000000000000000000000000000
80000080000000808000800000008000800080800000C0C0C000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
3333333333333333333333330000333333333333333333333333F33333333333
00003333344333333333333333388F3333333333000033334224333333333333
338338F3333333330000333422224333333333333833338F3333333300003342
222224333333333383333338F3333333000034222A22224333333338F338F333
8F33333300003222A3A2224333333338F3838F338F33333300003A2A333A2224
33333338F83338F338F33333000033A33333A222433333338333338F338F3333
0000333333333A222433333333333338F338F33300003333333333A222433333
333333338F338F33000033333333333A222433333333333338F338F300003333
33333333A222433333333333338F338F00003333333333333A22433333333333
3338F38F000033333333333333A223333333333333338F830000333333333333
333A333333333333333338330000333333333333333333333333333333333333
0000}
NumGlyphs = 2
end
object xWinHTTP: TCheckBox
Left = 188
Top = 76
Width = 77
Height = 21
Hint = 'if you want to use the WinHTTP API, check this box'
TabStop = False
Caption = 'WinHTTP'
TabOrder = 5
OnClick = xProxyClick
end
object gProxy: TGroupBox
Left = 8
Top = 128
Width = 261
Height = 97
Caption = 'Proxy Settings (leave empty for default)'
Enabled = False
TabOrder = 7
object Label1: TLabel
Left = 8
Top = 24
Width = 51
Height = 14
Alignment = taRightJustify
Caption = 'Proxy URL'
end
object Label4: TLabel
Left = 10
Top = 48
Width = 49
Height = 14
Alignment = taRightJustify
Caption = 'Username'
end
object Label5: TLabel
Left = 9
Top = 72
Width = 50
Height = 14
Alignment = taRightJustify
Caption = 'Password'
end
object eProxyAddr: TEdit
Left = 68
Top = 20
Width = 185
Height = 22
Hint = 'Enter the Address of your Proxy including http:// or https://'
Color = clGray
TabOrder = 0
end
object eProxyUsername: TEdit
Left = 68
Top = 44
Width = 185
Height = 22
Hint = 'Enter Username needed to log in to the Proxy'
Color = clGray
TabOrder = 1
end
object eProxyPassword: TEdit
Left = 68
Top = 68
Width = 185
Height = 22
Hint = 'Enter Password needed to log in to the Proxy'
Color = clGray
PasswordChar = '*'
TabOrder = 2
end
end
end
| 23.94186 | 77 | 0.615833 |
c3459d6dbf54f2dc2baef30f45c0a31961be6f1d | 1,162 | dfm | Pascal | ExtensionBuilder/frm_Functions.dfm | bgarrels/php4delphi | 041fed9bb6898faed25076f6ff893bfee93e41cd | [
"PHP-3.0"
]
| 19 | 2015-08-10T15:42:28.000Z | 2021-11-23T02:04:02.000Z | ExtensionBuilder/frm_Functions.dfm | bgarrels/php4delphi | 041fed9bb6898faed25076f6ff893bfee93e41cd | [
"PHP-3.0"
]
| 2 | 2018-06-22T12:45:58.000Z | 2020-11-30T09:05:57.000Z | ExtensionBuilder/frm_Functions.dfm | bgarrels/php4delphi | 041fed9bb6898faed25076f6ff893bfee93e41cd | [
"PHP-3.0"
]
| 13 | 2015-05-02T14:39:20.000Z | 2021-11-18T19:50:05.000Z | object frmFunctions: TfrmFunctions
Left = 414
Top = 217
BorderStyle = bsDialog
Caption = 'Functions'
ClientHeight = 442
ClientWidth = 370
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 Label1: TLabel
Left = 20
Top = 8
Width = 259
Height = 52
Caption =
'This wizard will create PHP extension project for you'#13#10#13#10'Please ' +
'enter name of the functions you want to include'#13#10'in this project'
end
object Functions: TMemo
Left = 16
Top = 68
Width = 337
Height = 319
TabOrder = 0
end
object btnOK: TButton
Left = 208
Top = 408
Width = 75
Height = 25
Caption = 'OK'
Default = True
ModalResult = 1
TabOrder = 1
end
object btnCancel: TButton
Left = 284
Top = 408
Width = 75
Height = 25
Cancel = True
Caption = 'Cancel'
ModalResult = 2
TabOrder = 2
end
end
| 21.127273 | 85 | 0.598967 |
c39dc11830adec991fb3eddccf7ff0972f7bb2a1 | 1,336 | dpr | Pascal | references/jcl/jcl/packages/d24/JclVersionControlExpertDLL.dpr | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 851 | 2018-02-05T09:54:56.000Z | 2022-03-24T23:13:10.000Z | references/jcl/jcl/packages/d24/JclVersionControlExpertDLL.dpr | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 200 | 2018-02-06T18:52:39.000Z | 2022-03-24T19:59:14.000Z | references/jcl/jcl/packages/d24/JclVersionControlExpertDLL.dpr | zekiguven/alcinoe | e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c | [
"Apache-2.0"
]
| 197 | 2018-03-20T20:49:55.000Z | 2022-03-21T17:38:14.000Z | Library JclVersionControlExpertDLL;
{
-----------------------------------------------------------------------------
DO NOT EDIT THIS FILE, IT IS GENERATED BY THE PACKAGE GENERATOR
ALWAYS EDIT THE RELATED XML FILE (JclVersionControlExpertDLL-L.xml)
Last generated: 21-01-2016 14:44:39 UTC
-----------------------------------------------------------------------------
}
{$R *.res}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO OFF}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS OFF}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO OFF}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST ON}
{$MINENUMSIZE 1}
{$IMAGEBASE $58200000}
{$DESCRIPTION 'JCL Integration of version control systems in the IDE'}
{$LIBSUFFIX '240'}
{$IMPLICITBUILD OFF}
{$DEFINE BCB}
{$DEFINE WIN32}
{$DEFINE CONDITIONALEXPRESSIONS}
{$DEFINE RELEASE}
uses
ToolsAPI,
JclVersionControlImpl in '..\..\experts\versioncontrol\JclVersionControlImpl.pas' ,
JclVersionCtrlCommonOptions in '..\..\experts\versioncontrol\JclVersionCtrlCommonOptions.pas' {JclVersionCtrlOptionsFrame: TFrame}
;
exports
JCLWizardInit name WizardEntryPoint;
end.
| 25.692308 | 133 | 0.63024 |
47bb23bed70177ed6b5d0b8443ef8898a216d669 | 581 | dpr | Pascal | Management Studio/ManagementStudio.dpr | MurilloLazzaretti/worker-control | f8fb7bc21fc399755d097017345197e7305244c1 | [
"MIT"
]
| 1 | 2021-05-17T16:31:12.000Z | 2021-05-17T16:31:12.000Z | Management Studio/ManagementStudio.dpr | MurilloLazzaretti/worker-control | f8fb7bc21fc399755d097017345197e7305244c1 | [
"MIT"
]
| null | null | null | Management Studio/ManagementStudio.dpr | MurilloLazzaretti/worker-control | f8fb7bc21fc399755d097017345197e7305244c1 | [
"MIT"
]
| 1 | 2021-03-18T03:45:44.000Z | 2021-03-18T03:45:44.000Z | program ManagementStudio;
uses
Vcl.Forms,
uMain in 'src\uMain.pas' {FrmMain},
Vcl.Themes,
Vcl.Styles,
ManagementStudio.Config in 'src\ManagementStudio.Config.pas',
ManagementStudio.Worker in 'src\ManagementStudio.Worker.pas',
ManagementStudio.ServiceManager in 'src\ManagementStudio.ServiceManager.pas';
{$R *.res}
begin
ReportMemoryLeaksOnShutdown := True;
Application.Initialize;
Application.MainFormOnTaskbar := True;
TStyleManager.TrySetStyle('Amethyst Kamri');
Application.CreateForm(TFrmMain, FrmMain);
Application.Run;
end.
| 26.409091 | 80 | 0.745267 |
c340149e5a0a13165f6ade4ec97347ebed89f9dc | 13,606 | pas | Pascal | HODLER_Multiplatform_Win_And_iOS_Linux/additionalUnits/CryptoLib/src/Utils/HlpConverters.pas | devilking6105/HODLER-Open-Source-Multi-Asset-Wallet | 2554bce0ad3e3e08e4617787acf93176243ce758 | [
"Unlicense"
]
| 35 | 2018-11-04T12:02:34.000Z | 2022-02-15T06:00:19.000Z | HODLER_Multiplatform_Win_And_iOS_Linux/additionalUnits/CryptoLib/src/Utils/HlpConverters.pas | Ecoent/HODLER-Open-Source-Multi-Asset-Wallet | a8c54ecfc569d0ee959b6f0e7826c4ee4b5c4848 | [
"Unlicense"
]
| 85 | 2018-10-23T17:09:20.000Z | 2022-01-12T07:12:54.000Z | HODLER_Multiplatform_Win_And_iOS_Linux/additionalUnits/CryptoLib/src/Utils/HlpConverters.pas | Ecoent/HODLER-Open-Source-Multi-Asset-Wallet | a8c54ecfc569d0ee959b6f0e7826c4ee4b5c4848 | [
"Unlicense"
]
| 34 | 2018-10-30T00:40:37.000Z | 2022-02-15T06:00:15.000Z | unit HlpConverters;
{$I ..\Include\HashLib.inc}
interface
uses
{$IFDEF HAS_UNITSCOPE}
System.Classes,
System.StrUtils,
System.SysUtils,
{$ELSE}
Classes,
StrUtils,
SysUtils,
{$ENDIF HAS_UNITSCOPE}
HlpHashLibTypes,
HlpBits,
HlpBitConverter;
resourcestring
SEncodingInstanceNil = 'Encoding Instance Cannot Be Nil';
type
TConverters = class sealed(TObject)
strict private
class function SplitString(const S: String; Delimiter: Char)
: THashLibStringArray; static;
{$IFDEF DEBUG}
class procedure Check(const a_in: THashLibByteArray;
a_in_size, a_out_size: Int32); overload; static;
{$ENDIF DEBUG}
class procedure swap_copy_str_to_u32(src: Pointer; src_index: Int32;
dest: Pointer; dest_index: Int32; length: Int32); static;
class procedure swap_copy_str_to_u64(src: Pointer; src_index: Int32;
dest: Pointer; dest_index: Int32; length: Int32); static;
public
class function be2me_32(x: UInt32): UInt32; static; inline;
class function be2me_64(x: UInt64): UInt64; static; inline;
class function le2me_32(x: UInt32): UInt32; static; inline;
class function le2me_64(x: UInt64): UInt64; static; inline;
class procedure be32_copy(src: Pointer; src_index: Int32; dest: Pointer;
dest_index: Int32; length: Int32); static; inline;
class procedure le32_copy(src: Pointer; src_index: Int32; dest: Pointer;
dest_index: Int32; length: Int32); static; inline;
class procedure be64_copy(src: Pointer; src_index: Int32; dest: Pointer;
dest_index: Int32; length: Int32); static; inline;
class procedure le64_copy(src: Pointer; src_index: Int32; dest: Pointer;
dest_index: Int32; length: Int32); static; inline;
class function ReadBytesAsUInt32LE(a_in: PByte; a_index: Int32): UInt32;
static; inline;
class function ReadBytesAsUInt64LE(a_in: PByte; a_index: Int32): UInt64;
static; inline;
class function ReadUInt32AsBytesLE(a_in: UInt32): THashLibByteArray;
overload; static; inline;
class function ReadUInt64AsBytesLE(a_in: UInt64): THashLibByteArray;
overload; static; inline;
class procedure ReadUInt32AsBytesLE(a_in: UInt32;
const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
class procedure ReadUInt32AsBytesBE(a_in: UInt32;
const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
class procedure ReadUInt64AsBytesLE(a_in: UInt64;
const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
class procedure ReadUInt64AsBytesBE(a_in: UInt64;
const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
class function ConvertStringToBytes(const a_in: String;
const a_encoding: TEncoding): THashLibByteArray; overload; static;
class function ConvertBytesToString(const a_in: THashLibByteArray;
const a_encoding: TEncoding): String; overload; static;
class function ConvertHexStringToBytes(const a_in: String)
: THashLibByteArray; static; inline;
class function ConvertBytesToHexString(const a_in: THashLibByteArray;
a_group: Boolean): String; static;
end;
implementation
{ TConverters }
{$IFDEF DEBUG}
class procedure TConverters.Check(const a_in: THashLibByteArray;
a_in_size, a_out_size: Int32);
begin
System.Assert(((System.length(a_in) * a_in_size) mod a_out_size) = 0);
end;
{$ENDIF DEBUG}
class procedure TConverters.swap_copy_str_to_u32(src: Pointer; src_index: Int32;
dest: Pointer; dest_index: Int32; length: Int32);
var
lsrc, ldest, lend: PCardinal;
lbsrc: PByte;
lLength: Int32;
begin
// if all pointers and length are 32-bits aligned
if ((Int32(PByte(dest) - PByte(0)) or (PByte(src) - PByte(0)) or src_index or
dest_index or length) and 3) = 0 then
begin
// copy memory as 32-bit words
lsrc := PCardinal(PByte(src) + src_index);
lend := PCardinal((PByte(src) + src_index) + length);
ldest := PCardinal(PByte(dest) + dest_index);
while lsrc < lend do
begin
ldest^ := TBits.ReverseBytesUInt32(lsrc^);
System.Inc(ldest);
System.Inc(lsrc);
end;
end
else
begin
lbsrc := (PByte(src) + src_index);
lLength := length + dest_index;
while dest_index < lLength do
begin
PByte(dest)[dest_index xor 3] := lbsrc^;
System.Inc(lbsrc);
System.Inc(dest_index);
end;
end;
end;
class procedure TConverters.swap_copy_str_to_u64(src: Pointer; src_index: Int32;
dest: Pointer; dest_index: Int32; length: Int32);
var
lsrc, ldest, lend: PUInt64;
lbsrc: PByte;
lLength: Int32;
begin
// if all pointers and length are 64-bits aligned
if ((Int32(PByte(dest) - PByte(0)) or (PByte(src) - PByte(0)) or src_index or
dest_index or length) and 7) = 0 then
begin
// copy aligned memory block as 64-bit integers
lsrc := PUInt64(PByte(src) + src_index);
lend := PUInt64((PByte(src) + src_index) + length);
ldest := PUInt64(PByte(dest) + dest_index);
while lsrc < lend do
begin
ldest^ := TBits.ReverseBytesUInt64(lsrc^);
System.Inc(ldest);
System.Inc(lsrc);
end;
end
else
begin
lbsrc := (PByte(src) + src_index);
lLength := length + dest_index;
while dest_index < lLength do
begin
PByte(dest)[dest_index xor 7] := lbsrc^;
System.Inc(lbsrc);
System.Inc(dest_index);
end;
end;
end;
class function TConverters.be2me_32(x: UInt32): UInt32;
begin
if TBitConverter.IsLittleEndian then
result := TBits.ReverseBytesUInt32(x)
else
result := x;
end;
class function TConverters.be2me_64(x: UInt64): UInt64;
begin
if TBitConverter.IsLittleEndian then
result := TBits.ReverseBytesUInt64(x)
else
result := x;
end;
class procedure TConverters.be32_copy(src: Pointer; src_index: Int32;
dest: Pointer; dest_index: Int32; length: Int32);
begin
if TBitConverter.IsLittleEndian then
swap_copy_str_to_u32(src, src_index, dest, dest_index, length)
else
System.Move(Pointer(PByte(src) + src_index)^,
Pointer(PByte(dest) + dest_index)^, length);
end;
class procedure TConverters.be64_copy(src: Pointer; src_index: Int32;
dest: Pointer; dest_index: Int32; length: Int32);
begin
if TBitConverter.IsLittleEndian then
swap_copy_str_to_u64(src, src_index, dest, dest_index, length)
else
System.Move(Pointer(PByte(src) + src_index)^,
Pointer(PByte(dest) + dest_index)^, length);
end;
class function TConverters.le2me_32(x: UInt32): UInt32;
begin
if not TBitConverter.IsLittleEndian then
result := TBits.ReverseBytesUInt32(x)
else
result := x;
end;
class function TConverters.le2me_64(x: UInt64): UInt64;
begin
if not TBitConverter.IsLittleEndian then
result := TBits.ReverseBytesUInt64(x)
else
result := x;
end;
class procedure TConverters.le32_copy(src: Pointer; src_index: Int32;
dest: Pointer; dest_index: Int32; length: Int32);
begin
if TBitConverter.IsLittleEndian then
System.Move(Pointer(PByte(src) + src_index)^,
Pointer(PByte(dest) + dest_index)^, length)
else
swap_copy_str_to_u32(src, src_index, dest, dest_index, length);
end;
class procedure TConverters.le64_copy(src: Pointer; src_index: Int32;
dest: Pointer; dest_index: Int32; length: Int32);
begin
if TBitConverter.IsLittleEndian then
System.Move(Pointer(PByte(src) + src_index)^,
Pointer(PByte(dest) + dest_index)^, length)
else
swap_copy_str_to_u64(src, src_index, dest, dest_index, length);
end;
class function TConverters.ReadBytesAsUInt32LE(a_in: PByte;
a_index: Int32): UInt32;
begin
{$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
System.Move(a_in[a_index], result, System.SizeOf(UInt32));
{$ELSE}
result := PCardinal(a_in + a_index)^;
{$ENDIF FPC_REQUIRES_PROPER_ALIGNMENT}
result := le2me_32(result);
end;
class function TConverters.ReadBytesAsUInt64LE(a_in: PByte;
a_index: Int32): UInt64;
begin
{$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
System.Move(a_in[a_index], result, System.SizeOf(UInt64));
{$ELSE}
result := PUInt64(a_in + a_index)^;
{$ENDIF FPC_REQUIRES_PROPER_ALIGNMENT}
result := le2me_64(result);
end;
class function TConverters.ReadUInt32AsBytesLE(a_in: UInt32): THashLibByteArray;
begin
result := THashLibByteArray.Create(Byte(a_in), Byte(a_in shr 8),
Byte(a_in shr 16), Byte(a_in shr 24));
end;
class function TConverters.ReadUInt64AsBytesLE(a_in: UInt64): THashLibByteArray;
begin
result := THashLibByteArray.Create(Byte(a_in), Byte(a_in shr 8),
Byte(a_in shr 16), Byte(a_in shr 24), Byte(a_in shr 32), Byte(a_in shr 40),
Byte(a_in shr 48), Byte(a_in shr 56));
end;
class procedure TConverters.ReadUInt32AsBytesLE(a_in: UInt32;
const a_out: THashLibByteArray; a_index: Int32);
begin
a_out[a_index] := Byte(a_in);
a_out[a_index + 1] := Byte(a_in shr 8);
a_out[a_index + 2] := Byte(a_in shr 16);
a_out[a_index + 3] := Byte(a_in shr 24);
end;
class procedure TConverters.ReadUInt32AsBytesBE(a_in: UInt32;
const a_out: THashLibByteArray; a_index: Int32);
begin
a_out[a_index] := Byte(a_in shr 24);
a_out[a_index + 1] := Byte(a_in shr 16);
a_out[a_index + 2] := Byte(a_in shr 8);
a_out[a_index + 3] := Byte(a_in);
end;
class procedure TConverters.ReadUInt64AsBytesLE(a_in: UInt64;
const a_out: THashLibByteArray; a_index: Int32);
begin
a_out[a_index] := Byte(a_in);
a_out[a_index + 1] := Byte(a_in shr 8);
a_out[a_index + 2] := Byte(a_in shr 16);
a_out[a_index + 3] := Byte(a_in shr 24);
a_out[a_index + 4] := Byte(a_in shr 32);
a_out[a_index + 5] := Byte(a_in shr 40);
a_out[a_index + 6] := Byte(a_in shr 48);
a_out[a_index + 7] := Byte(a_in shr 56);
end;
class procedure TConverters.ReadUInt64AsBytesBE(a_in: UInt64;
const a_out: THashLibByteArray; a_index: Int32);
begin
a_out[a_index] := Byte(a_in shr 56);
a_out[a_index + 1] := Byte(a_in shr 48);
a_out[a_index + 2] := Byte(a_in shr 40);
a_out[a_index + 3] := Byte(a_in shr 32);
a_out[a_index + 4] := Byte(a_in shr 24);
a_out[a_index + 5] := Byte(a_in shr 16);
a_out[a_index + 6] := Byte(a_in shr 8);
a_out[a_index + 7] := Byte(a_in);
end;
class function TConverters.ConvertBytesToHexString
(const a_in: THashLibByteArray; a_group: Boolean): String;
var
I: Int32;
hex, workstring: String;
ar: THashLibStringArray;
begin
hex := UpperCase(TBitConverter.ToString(a_in));
if System.length(a_in) = 1 then
begin
result := hex;
Exit;
end;
if System.length(a_in) = 2 then
begin
result := StringReplace(hex, '-', '', [rfIgnoreCase, rfReplaceAll]);
Exit;
end;
if (a_group) then
begin
{$IFDEF DEBUG}
Check(a_in, 1, 4);
{$ENDIF DEBUG}
workstring := UpperCase(TBitConverter.ToString(a_in));
ar := TConverters.SplitString(workstring, '-');
hex := '';
I := 0;
while I < (System.length(ar) shr 2) do
begin
if (I <> 0) then
hex := hex + '-';
hex := hex + ar[I * 4] + ar[I * 4 + 1] + ar[I * 4 + 2] + ar[I * 4 + 3];
System.Inc(I);
end;
end
else
begin
hex := StringReplace(hex, '-', '', [rfIgnoreCase, rfReplaceAll]);
end;
result := hex;
end;
class function TConverters.ConvertHexStringToBytes(const a_in: String)
: THashLibByteArray;
var
l_in: String;
begin
l_in := a_in;
l_in := StringReplace(l_in, '-', '', [rfIgnoreCase, rfReplaceAll]);
{$IFDEF DEBUG}
System.Assert(System.length(l_in) and 1 = 0);
{$ENDIF DEBUG}
System.SetLength(result, System.length(l_in) shr 1);
{$IFNDEF NEXTGEN}
HexToBin(PChar(l_in), @result[0], System.length(result));
{$ELSE}
HexToBin(PChar(l_in), 0, result, 0, System.length(l_in));
{$ENDIF !NEXTGEN}
end;
class function TConverters.ConvertStringToBytes(const a_in: String;
const a_encoding: TEncoding): THashLibByteArray;
begin
if a_encoding = Nil then
begin
raise EArgumentNilHashLibException.CreateRes(@SEncodingInstanceNil);
end;
{$IFDEF FPC}
result := a_encoding.GetBytes(UnicodeString(a_in));
{$ELSE}
result := a_encoding.GetBytes(a_in);
{$ENDIF FPC}
end;
class function TConverters.ConvertBytesToString(const a_in: THashLibByteArray;
const a_encoding: TEncoding): String;
begin
if a_encoding = Nil then
begin
raise EArgumentNilHashLibException.CreateRes(@SEncodingInstanceNil);
end;
{$IFDEF FPC}
result := String(a_encoding.GetString(a_in));
{$ELSE}
result := a_encoding.GetString(a_in);
{$ENDIF FPC}
end;
class function TConverters.SplitString(const S: String; Delimiter: Char)
: THashLibStringArray;
var
PosStart, PosDel, SplitPoints, I, LowPoint, HighPoint, Len: Int32;
begin
result := Nil;
if S <> '' then
begin
{ Determine the length of the resulting array }
SplitPoints := 0;
{$IFDEF DELPHIXE3_UP}
LowPoint := System.Low(S);
HighPoint := System.High(S);
{$ELSE}
LowPoint := 1;
HighPoint := System.length(S);
{$ENDIF DELPHIXE3_UP}
for I := LowPoint to HighPoint do
begin
if (Delimiter = S[I]) then
System.Inc(SplitPoints);
end;
System.SetLength(result, SplitPoints + 1);
{ Split the string and fill the resulting array }
I := 0;
Len := System.length(Delimiter);
{$IFDEF DELPHIXE3_UP}
PosStart := System.Low(S);
HighPoint := System.High(S);
{$ELSE}
PosStart := 1;
HighPoint := System.length(S);
{$ENDIF DELPHIXE3_UP}
PosDel := System.Pos(Delimiter, S);
while PosDel > 0 do
begin
result[I] := System.Copy(S, PosStart, PosDel - PosStart);
PosStart := PosDel + Len;
PosDel := PosEx(Delimiter, S, PosStart);
System.Inc(I);
end;
result[I] := System.Copy(S, PosStart, HighPoint);
end;
end;
end.
| 27.486869 | 80 | 0.696825 |
c30af71d80effe06f573e752853d47bf8fd82d88 | 151 | pas | Pascal | Test/FunctionsMathComplex/abs.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| 79 | 2015-03-18T10:46:13.000Z | 2022-03-17T18:05:11.000Z | Test/FunctionsMathComplex/abs.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| 6 | 2016-03-29T14:39:00.000Z | 2020-09-14T10:04:14.000Z | Test/FunctionsMathComplex/abs.pas | skolkman/dwscript | b9f99d4b8187defac3f3713e2ae0f7b83b63d516 | [
"Condor-1.1"
]
| 25 | 2016-05-04T13:11:38.000Z | 2021-09-29T13:34:31.000Z | PrintLn(Abs( Complex(2, 0) ));
PrintLn(Abs( Complex(-2, 0) ));
const i = Complex(0, 3);
PrintLn(Abs(i));
PrintLn(Abs(ComplexNeg(i)));
| 12.583333 | 32 | 0.562914 |
fcc094130af516d7482a38c0a6c49757985ba8e5 | 11,055 | pas | Pascal | core/bs.textprocessor.pas | PVV-BS/BlackShark | 34dc339146ba1596f4db813a0fe95d103a0a8bf3 | [
"Linux-OpenIB"
]
| 1 | 2022-02-11T06:49:00.000Z | 2022-02-11T06:49:00.000Z | core/bs.textprocessor.pas | PVV-BS/BlackShark | 34dc339146ba1596f4db813a0fe95d103a0a8bf3 | [
"Linux-OpenIB"
]
| null | null | null | core/bs.textprocessor.pas | PVV-BS/BlackShark | 34dc339146ba1596f4db813a0fe95d103a0a8bf3 | [
"Linux-OpenIB"
]
| null | null | null | {
-- Begin License block --
Copyright (C) 2019-2022 Pavlov V.V. (PVV)
"Black Shark Graphics Engine" for Delphi and Lazarus (named
"Library" in the file "License(LGPL).txt" included in this distribution).
The Library is free software.
Last revised June, 2022
This file is part of "Black Shark Graphics Engine", and may only be
used, modified, and distributed under the terms of the project license
"License(LGPL).txt". By continuing to use, modify, or distribute this
file you indicate that you have read the license and understand and
accept it fully.
"Black Shark Graphics Engine" is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- End License block --
}
unit bs.textprocessor;
{$I BlackSharkCfg.inc}
interface
uses
bs.baseTypes
, bs.font
, bs.collections
, bs.align
;
type
PLineProp = ^TLineProp;
TLineProp = record
{ line width }
Width: BSFloat;
Height: BSFloat;
{ count blanks }
CountBlanks: int32;
{ count chars }
CountChars: int32;
{ blanks in lines b/w words }
InsideBlanks: int32;
IndexBegin: int32;
end;
TSelectorKey = function (Index: int32; out Code: int32): PKeyInfo of object;
TQueryAverageWidth = function (Index: int32): BSFloat of object;
TTextProcessor = class
private
FDelta: int8;
FWidth: BSFloat;
FInterligne: int16;
FAlignText: TObjectAlign;
FHeight: BSFloat;
FillCount: int32;
RectSize: TVec2f;
FLines: TListVec<TLineProp>;
FAllowBrakeWords: boolean;
FOnQueryKey: TSelectorKey;
FCountChars: int32;
FLineHeight: int32;
FOnQueryAverageWidthForCurrentPos: TQueryAverageWidth;
procedure SetAlignText(const Value: TObjectAlign);
procedure SetDelta(const Value: int8);
procedure SetInterligne(const Value: int16);
procedure SetAllowBrakeWords(const Value: boolean);
procedure SetCountChars(const Value: int32);
procedure SetLineHeight(const Value: int32);
public
constructor Create(AKeySelector: TSelectorKey; AQueryAverageWidth: TQueryAverageWidth);
destructor Destroy; override;
procedure Build(PositionBegin: int32 = 1);
procedure Add;
procedure BeginFill;
procedure EndFill;
function GetCharWidth(Key: PKeyInfo): int32;
procedure SetOutRect(Width, Height: BSFloat);
function GetIndexLineFromIndexChar(IndexChar: int32): int32;
function GetIndexLineFromOffsetY(OffsetY: BSFloat): int32;
property CountChars: int32 read FCountChars write SetCountChars;
{ size text in pixels }
property Width: BSFloat read FWidth;
property Height: BSFloat read FHeight;
{ distance b/w chars }
property Delta: int8 read FDelta write SetDelta;
{ distance b/w lines }
property Interligne: int16 read FInterligne write SetInterligne;
property AlignText: TObjectAlign read FAlignText write SetAlignText;
property AllowBrakeWords: boolean read FAllowBrakeWords write SetAllowBrakeWords;
property OnQueryKey: TSelectorKey read FOnQueryKey write FOnQueryKey;
property OnQueryAverageWidthForCurrentPos: TQueryAverageWidth read FOnQueryAverageWidthForCurrentPos write FOnQueryAverageWidthForCurrentPos;
property LineHeight: int32 read FLineHeight write SetLineHeight;
property Lines: TListVec<TLineProp> read FLines;
end;
implementation
uses
SysUtils
, Math
, bs.shader
{$ifdef ultibo}
, gles20
{$else}
, bs.gl.es
{$endif}
;
{ TTextProcessor }
procedure TTextProcessor.Add;
begin
inc(FCountChars);
if FillCount = 0 then
Build(FCountChars);
end;
procedure TTextProcessor.BeginFill;
begin
inc(FillCount);
end;
procedure TTextProcessor.Build(PositionBegin: int32 = 1);
var
i: int32;
{ chars in current a word }
chars: int32;
{ blanks befor current the word }
blanks_befor_word: int32;
prop: TLineProp;
word_width: BSFloat;
out_width: BSFloat;
sum_width: BSFloat;
add: BSFloat;
KeyInfo: PKeyInfo;
first_word: boolean;
word_reads: boolean;
code: int32;
avr_width_ch: BSFloat;
begin
if (FAlignText <> TObjectAlign.oaLeft) and (RectSize.x > 0) then
out_width := RectSize.x
else
out_width := MaxSingle;
prop.Width := 0.0;
prop.Height := 0.0;
prop.CountChars := 0;
prop.CountBlanks := 0;
prop.InsideBlanks := 0;
prop.IndexBegin := PositionBegin;
word_width := 0.0;
chars := 0;
blanks_befor_word := 0;
first_word := true;
word_reads := false;
FWidth := 0;
FHeight := 0;
if PositionBegin > 1 then
begin
for i := 1 to FLines.Count - 1 do
begin
if PositionBegin <= FLines.Items[i].IndexBegin then
begin
FLines.Count := i - 1;
if FLines.Count > 0 then
PositionBegin := FLines.Items[FLines.Count - 1].IndexBegin
else
PositionBegin := 0;
break;
end;
if FLines.Items[i].Width > FWidth then
FWidth := FLines.Items[i].Width;
end;
end else
begin
FLines.Count := 0;
end;
prop.IndexBegin := PositionBegin;
{ it sets var "add" and "sum_width" to avoid warning }
//add := 0.0;
//sum_width := 0.0;
avr_width_ch := FOnQueryAverageWidthForCurrentPos(PositionBegin);
for i := PositionBegin to FCountChars do
begin
inc(prop.CountChars);
KeyInfo := FOnQueryKey(i, code); //FMap.Items[i];
if code = $09 then
begin
if word_reads then
begin
blanks_befor_word := 0;
word_reads := false;
end;
add := avr_width_ch;
inc(prop.CountBlanks, 2);
inc(blanks_befor_word, 2);
//word_width := 0;
chars := 0;
sum_width := add;
end else
if (code = $20) then
begin
if word_reads then
begin
blanks_befor_word := 0;
word_reads := false;
end;
inc(prop.CountBlanks);
inc(blanks_befor_word);
add := avr_width_ch * 0.5;
chars := 0;
sum_width := add;
end else
if (KeyInfo = nil) then
begin
continue;
end else
begin
if (not word_reads) then
begin
if not first_word then
inc(prop.InsideBlanks, blanks_befor_word);
//blanks := 0;
word_width := 0;
word_reads := true;
end;
first_word := false;
sum_width := KeyInfo^.Rect.Width;
add := sum_width + FDelta;
word_width := word_width + add;
inc(chars);
end;
if (KeyInfo <> nil) and (KeyInfo.Rect.Height > prop.Height) then
prop.Height := KeyInfo.Rect.Height;
prop.Width := prop.Width + add;
if (code = $0d) or (prop.Width + sum_width > out_width) then
begin
if FAllowBrakeWords or (code = $0d) or (code = $20) or (code = $09) then
begin
if prop.Width > FWidth then
FWidth := prop.Width;
if FLineHeight = 0 then
FHeight := FHeight + prop.Height + FInterligne;
FLines.Add(prop);
prop.Width := 0.0;
prop.Height := 0.0;
prop.CountChars := 1;
prop.IndexBegin := i;
chars := 0;
word_width := 0.0;
word_reads := false;
end else
//if word_width + add < out_width then
begin // roll back on one word
dec(prop.CountChars, chars);
prop.Width := prop.Width - word_width;
if prop.Width > FWidth then
FWidth := prop.Width;
if FLineHeight = 0 then
FHeight := FHeight + prop.Height + FInterligne;
if (prop.CountChars > 0) and (prop.Width > 0) then
FLines.Add(prop);
prop.IndexBegin := i - chars + 1;
prop.Width := word_width;
prop.CountChars := chars;
word_reads := true;
//continue;
end;
blanks_befor_word := 0;
prop.InsideBlanks := 0;
prop.CountBlanks := 0;
end;
end;
if prop.Width > 0 then
begin
if prop.Width > FWidth then
FWidth := prop.Width;
if FLineHeight = 0 then
FHeight := FHeight + prop.Height + FInterligne;
FLines.Add(prop);
end;
if FLineHeight > 0 then
FHeight := FLines.Count * (FLineHeight + FInterligne);
end;
constructor TTextProcessor.Create(AKeySelector: TSelectorKey; AQueryAverageWidth: TQueryAverageWidth);
begin
Assert(Assigned(AKeySelector), 'A parameter AKeySelector must be valid!');
FDelta := 1;
FInterligne := 3;
FAllowBrakeWords := false;
FOnQueryKey := AKeySelector;
FOnQueryAverageWidthForCurrentPos := AQueryAverageWidth;
FLines := TListVec<TLineProp>.Create;
end;
destructor TTextProcessor.Destroy;
begin
FLines.Free;
inherited;
end;
procedure TTextProcessor.EndFill;
begin
dec(FillCount);
if FillCount < 0 then
FillCount := 0;
if FillCount = 0 then
Build(1);
end;
function TTextProcessor.GetCharWidth(Key: PKeyInfo): int32;
begin
if Key.Code = 9 then
Result := round(Key.Rect.Width) shl 1 // Tab has double blank
else
if Key.Code = 32 then
Result := round(Key.Rect.Width) // Blank without Delta
else
Result := round(Key.Rect.Width) + Delta;
end;
function TTextProcessor.GetIndexLineFromIndexChar(IndexChar: int32): int32;
var
l: PLineProp;
begin
for Result := 0 to FLines.Count - 1 do
begin
l := FLines.ShiftData[Result];
if (IndexChar < l.IndexBegin + l.CountChars) then
exit;
end;
if FLines.Count > 0 then
Result := 0
else
Result := -1;
end;
function TTextProcessor.GetIndexLineFromOffsetY(OffsetY: BSFloat): int32;
begin
if (FInterligne > 0) or (FLineHeight > 0) then
Result := round(OffsetY) {%H-}div (FLineHeight + FInterligne)
else
Result := 0;
if Result >= FLines.Count then
Result := -1;
end;
procedure TTextProcessor.SetAlignText(const Value: TObjectAlign);
begin
FAlignText := Value;
if FillCount = 0 then
Build(1);
end;
procedure TTextProcessor.SetAllowBrakeWords(const Value: boolean);
begin
FAllowBrakeWords := Value;
if FillCount = 0 then
Build(1);
end;
procedure TTextProcessor.SetCountChars(const Value: int32);
begin
FCountChars := Value;
if FillCount = 0 then
Build(1);
end;
procedure TTextProcessor.SetDelta(const Value: int8);
begin
FDelta := Value;
if FillCount = 0 then
Build(1);
end;
procedure TTextProcessor.SetInterligne(const Value: int16);
begin
FInterligne := Value;
if FillCount = 0 then
Build(1);
end;
procedure TTextProcessor.SetLineHeight(const Value: int32);
begin
FLineHeight := Value;
if FillCount = 0 then
Build(1);
end;
procedure TTextProcessor.SetOutRect(Width, Height: BSFloat);
begin
RectSize.x := Width;
RectSize.y := Height;
if FillCount = 0 then
Build(1);
end;
end.
| 26.134752 | 146 | 0.641972 |
c3e944a14c34345314b08cc61f1f0ff0d0ead212 | 5,231 | pas | Pascal | Components/JVCL/examples/JvValidators/MainFrm.pas | sabatex/Delphi | 0efbe6eb38bf8aa2bf269d1866741266e90b9cbf | [
"MIT"
]
| null | null | null | Components/JVCL/examples/JvValidators/MainFrm.pas | sabatex/Delphi | 0efbe6eb38bf8aa2bf269d1866741266e90b9cbf | [
"MIT"
]
| null | null | null | Components/JVCL/examples/JvValidators/MainFrm.pas | sabatex/Delphi | 0efbe6eb38bf8aa2bf269d1866741266e90b9cbf | [
"MIT"
]
| 1 | 2019-12-24T08:39:18.000Z | 2019-12-24T08:39:18.000Z | {******************************************************************
JEDI-VCL Demo
Copyright (C) 2002 Project JEDI
Original author:
Contributor(s):
You may retrieve the latest version of this file at the JEDI-JVCL
home page, located at http://jvcl.sourceforge.net
The contents of this file are used with permission, 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_1Final.html
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.
******************************************************************}
{$I jvcl.inc}
unit MainFrm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, JvValidators, JvErrorIndicator, ImgList, JvComponent;
type
TfrmMain = class(TForm)
Label1: TLabel;
edRequired: TEdit;
Label2: TLabel;
edRequired10Chars: TEdit;
Label3: TLabel;
edRegExpr: TEdit;
Label4: TLabel;
edRange0to100: TEdit;
udRange0to100: TUpDown;
btnCheck: TButton;
Label5: TLabel;
btnProviderCheck: TButton;
reResults: TRichEdit;
btnValSum: TButton;
JvValidators1: TJvValidators;
JvErrorIndicator1: TJvErrorIndicator;
JvValidationSummary1: TJvValidationSummary;
JvRequiredFieldValidator1: TJvRequiredFieldValidator;
JvCustomValidator1: TJvCustomValidator;
JvRegularExpressionValidator1: TJvRegularExpressionValidator;
JvRangeValidator1: TJvRangeValidator;
procedure FormCreate(Sender: TObject);
procedure btnCheckClick(Sender: TObject);
procedure btnProviderCheckClick(Sender: TObject);
procedure btnValSumClick(Sender: TObject);
procedure reResultsEnter(Sender: TObject);
procedure JvCustomValidator1Validate(Sender: TObject;
ValueToValidate: Variant; var Valid: Boolean);
procedure JvValidators1ValidateFailed(Sender: TObject;
BaseValidator: TJvBaseValidator; var Continue: Boolean);
procedure JvValidationSummary1Change(Sender: TObject);
private
{ Private declarations }
procedure ProviderErrorValidateFailed(Sender: TObject;
BaseValidator: TJvBaseValidator; var Continue: Boolean);
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$IFDEF COMPILER6_UP}
uses
Variants;
{$ENDIF}
{$R *.DFM}
procedure TfrmMain.FormCreate(Sender: TObject);
begin
reResults.WordWrap := true;
end;
procedure TfrmMain.btnCheckClick(Sender: TObject);
begin
reResults.Lines.Clear;
reResults.WordWrap := false;
JvErrorIndicator1.ClearErrors;
JvValidators1.ValidationSummary := nil;
JvValidators1.ErrorIndicator := nil;
JvValidators1.OnValidateFailed := JvValidators1ValidateFailed;
JvValidators1.Validate;
end;
procedure TfrmMain.btnProviderCheckClick(Sender: TObject);
begin
reResults.Lines.Clear;
reResults.WordWrap := false;
// calling BeginUpdate/EndUpdate delays the error reporting until all controls have been validated
JvErrorIndicator1.BeginUpdate;
try
JvErrorIndicator1.ClearErrors;
JvValidators1.ValidationSummary := nil;
// custom error messages for this type of check
JvValidators1.OnValidateFailed := ProviderErrorValidateFailed;
JvValidators1.Validate;
finally
JvErrorIndicator1.EndUpdate;
end;
end;
procedure TfrmMain.btnValSumClick(Sender: TObject);
begin
reResults.Lines.Clear;
reResults.WordWrap := false;
JvErrorIndicator1.ClearErrors;
JvValidators1.OnValidateFailed := nil;
JvValidators1.ErrorIndicator := nil;
// Setting the ValidationSummary for TJvValidators will delay
// triggering the OnChange event until after Validate has completed
JvValidationSummary1.Summaries.Clear;
JvValidators1.ValidationSummary := JvValidationSummary1;
JvValidators1.Validate;
end;
procedure TfrmMain.reResultsEnter(Sender: TObject);
begin
SelectNext(reResults,true,true);
end;
procedure TfrmMain.JvCustomValidator1Validate(Sender: TObject;
ValueToValidate: Variant; var Valid: Boolean);
begin
// custom validation
Valid := not VarIsNull(ValueToValidate) and (Length(string(ValueToValidate)) >= 10);
end;
procedure TfrmMain.JvValidators1ValidateFailed(Sender: TObject;
BaseValidator: TJvBaseValidator; var Continue: Boolean);
begin
// using the OnValidateFailed event
reResults.Lines.Add(Format('FAILED: %s',[BaseValidator.ErrorMessage]));
end;
procedure TfrmMain.ProviderErrorValidateFailed(Sender: TObject;
BaseValidator: TJvBaseValidator; var Continue: Boolean);
begin
JvErrorIndicator1.Error[BaseValidator.ControlToValidate] := BaseValidator.ErrorMessage;
reResults.Lines.Add(Format('PROVIDER: %s',[BaseValidator.ErrorMessage]));
end;
procedure TfrmMain.JvValidationSummary1Change(Sender: TObject);
var i:integer;
begin
// update all at once
reResults.Lines.Text := TJvValidationSummary(Sender).Summaries.Text;
for i := 0 to reResults.Lines.Count - 1 do
reResults.Lines[i] := 'SUMMARY: ' + reResults.Lines[i];
end;
end.
| 30.590643 | 100 | 0.74957 |
f127bd702f22e15699e2f07eca3eaf3421a857dc | 5,311 | pas | Pascal | windows/src/ext/jedi/jvcl/jvcl/run/JvGridPrinter.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 219 | 2017-06-21T03:37:03.000Z | 2022-03-27T12:09:28.000Z | windows/src/ext/jedi/jvcl/jvcl/run/JvGridPrinter.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 4,451 | 2017-05-29T02:52:06.000Z | 2022-03-31T23:53:23.000Z | windows/src/ext/jedi/jvcl/jvcl/run/JvGridPrinter.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 72 | 2017-05-26T04:08:37.000Z | 2022-03-03T10:26:20.000Z | {-----------------------------------------------------------------------------
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: JvGridPrinter.PAS, released on 2002-06-15.
The Initial Developer of the Original Code is Jan Verhoeven [jan1 dott verhoeven att wxs dott nl]
Portions created by Jan Verhoeven are Copyright (C) 2002 Jan Verhoeven.
All Rights Reserved.
Contributor(s): Robert Love [rlove att slcdug dott org].
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 JvGridPrinter;
{$I jvcl.inc}
interface
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
Windows, Controls, Forms, Grids, Printers, SysUtils, Classes;
type
TJvPrintMode = (pmPrint, pmPreview, pmPageCount);
TJvPrintOptions = class(TPersistent)
private
FJobTitle: string;
FPageTitle: string;
FPageTitleMargin: Cardinal;
FCopies: Cardinal;
FPreviewPage: Cardinal;
FBorderStyle: TBorderStyle;
FLeftPadding: Cardinal;
FMarginBottom: Cardinal;
FMarginLeft: Cardinal;
FMarginTop: Cardinal;
FMarginRight: Cardinal;
FPageFooter: string;
FDateFormat: string;
FTimeFormat: string;
FHeaderSize: Cardinal;
FFooterSize: Cardinal;
FOrientation: TPrinterOrientation;
FLogo: string;
published
property Orientation: TPrinterOrientation read FOrientation write FOrientation;
property JobTitle: string read FJobTitle write FJobTitle;
property PageTitle: string read FPageTitle write FPageTitle;
property Logo: string read FLogo write FLogo;
property PageTitleMargin: Cardinal read FPageTitleMargin write FPageTitleMargin;
property PageFooter: string read FPageFooter write FPageFooter;
property HeaderSize: Cardinal read FHeaderSize write FHeaderSize;
property FooterSize: Cardinal read FFooterSize write FFooterSize;
property DateFormat: string read FDateFormat write FDateFormat;
property TimeFormat: string read FTimeFormat write FTimeFormat;
property Copies: Cardinal read FCopies write FCopies default 1;
property PreviewPage: Cardinal read FPreviewPage write FPreviewPage;
property BorderStyle: TBorderStyle read FBorderStyle write FBorderStyle;
property Leftpadding: Cardinal read FLeftPadding write FLeftPadding;
property MarginBottom: Cardinal read FMarginBottom write FMarginBottom;
property MarginLeft: Cardinal read FMarginLeft write FMarginLeft;
property MarginTop: Cardinal read FMarginTop write FMarginTop;
property MarginRight: Cardinal read FMarginRight write FMarginRight;
end;
{$IFDEF RTL230_UP}
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
{$ENDIF RTL230_UP}
TJvGridPrinter = class(TComponent)
private
FPrintOptions: TJvPrintOptions;
FGrid: TStringGrid;
FNumbersAlright: Boolean;
FNumberFormat: string;
FWordWrap: Boolean;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Preview: Boolean;
published
property PrintOptions: TJvPrintOptions read FPrintOptions write FPrintOptions;
property Grid: TStringGrid read FGrid write FGrid;
property WordWrap: Boolean read FWordWrap write FWordWrap default True;
property NumbersAlright: Boolean read FNumbersAlright write FNumbersAlright default True;
property NumberFormat: string read FNumberFormat write FNumberFormat;
end;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL$';
Revision: '$Revision$';
Date: '$Date$';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
implementation
uses
JvGridPreviewForm, JvTypes, JvResources;
constructor TJvGridPrinter.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FPrintOptions := TJvPrintOptions.Create;
FPrintOptions.PageFooter := RsPrintOptionsPageFooter;
FPrintOptions.DateFormat := RsPrintOptionsDateFormat;
FPrintOptions.TimeFormat := RsPrintOptionsTimeFormat;
FPrintOptions.HeaderSize := 14;
FPrintOptions.FooterSize := 8;
FPrintOptions.PreviewPage := 1;
FNumbersAlright := True;
FNumberFormat := '%.2f';
FWordWrap := True;
end;
destructor TJvGridPrinter.Destroy;
begin
FPrintOptions.Free;
inherited Destroy;
end;
function TJvGridPrinter.Preview: Boolean;
var
Preview: TJvGridPreviewForm;
begin
if Assigned(FGrid) then
begin
Preview := TJvGridPreviewForm.Create(Application);
Preview.GridPrinter := Self;
Preview.Grid := Grid;
Preview.ShowModal;
Preview.Free;
Result := True;
end
else
Result := False;
end;
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end. | 32.187879 | 97 | 0.745246 |
fce301d0154b5bcd68cfdde3bcb79b0c9c5db83d | 4,527 | pas | Pascal | uAulaGIL.pas | MaikoGoncalves/DelphiProjetoAula | 9be93f913954082a4e0d500530e46ad6b53ad19f | [
"MIT"
]
| null | null | null | uAulaGIL.pas | MaikoGoncalves/DelphiProjetoAula | 9be93f913954082a4e0d500530e46ad6b53ad19f | [
"MIT"
]
| null | null | null | uAulaGIL.pas | MaikoGoncalves/DelphiProjetoAula | 9be93f913954082a4e0d500530e46ad6b53ad19f | [
"MIT"
]
| null | null | null | unit uAulaGIL;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
Vcl.ComCtrls, Vcl.ToolWin;
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button4: TButton;
Button5: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
Button3: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
procedure Button1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function Somar(A,B: Integer): integer; // paramentros referencia.
function Somar2(var A,B: Integer): integer; // pode trocar o valor do paramentro.
// function Somar3(const A,B: Integer): integer;// não vai mudar o valor do paramentro.
end;
var
Form1: TForm1;
//A:Integer;
implementation
{$R *.dfm}
procedure TForm1.Button10Click(Sender: TObject);
Var
S: String;
L: char;
I: Integer;
begin
S := 'PalaVra';
for L in S do
begin
ShowMessage(L);
end;
for I := 1 to Length(S) do
ShowMessage(S[I]);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
X, Y: Integer;
begin
x:= 15 ;
y:= 10 ;
ShowMessage(IntToStr(Somar(10,5)));
ShowMessage(IntToStr(Somar2(x,y)));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if True then
begin
ShowMessage('Linha 1 Verdade');
ShowMessage('Linha 2 Verdade');
end
else
begin
ShowMessage('Linha 1 Mentira');
ShowMessage('Linha 2 Mentira');
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
Var
x : Integer;
begin
x:= StrToInt(Edit2.Text);
case x of
1: ShowMessage('X é 1');
2: ShowMessage('X é 2');
3: ShowMessage('X é 3');
4..6: begin
ShowMessage('X é 4');
ShowMessage('ou X é 5');
ShowMessage('ou X é 6');
end
else
ShowMessage('Não sei o valor de x');
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
with Edit1, Button4 do
begin
Width := 200;
Left := 50;
Top := 150;
Color := clBlue;
Font.Size := 15;
Default := True;
Caption := 'Clicado';
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if False then
begin
ShowMessage('Linha 1 Verdade');
ShowMessage('Linha 2 Verdade');
end
else
begin
ShowMessage('Linha 1 Mentira');
ShowMessage('Linha 2 Mentira');
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
Var
X: Integer;
begin
x:=0;
repeat
ShowMessage('Contador = ' + IntToStr(X));
Inc (X); // Imprime pelo menos uma vez.
until(X=3); // Em quanto o X não for 3 vai imprimir na tela. Se não estiver na codiçao não para de aparecer
end;
procedure TForm1.Button7Click(Sender: TObject);
Var
Y: Integer;
begin
Y:=0;
while Y < 3 do //Em quanto o Y e < que 3 vai imprimir na tela. Não mprime se não for a condição.
begin
ShowMessage('Contador = ' + IntToStr(Y));
Inc(Y);
end;
end;
procedure TForm1.Button8Click(Sender: TObject);
var
I: Integer;
begin
for I := 0 to 3 do
begin
ShowMessage('Contador = ' + IntToStr(I));
end;
end;
procedure TForm1.Button9Click(Sender: TObject);
var
I : Integer;
begin
for I := 1 to 10 do
begin
ShowMessage(IntToStr(I));
if I mod 2 = 0 then Continue;
ShowMessage('Numero Impar');
if I > 5 then break;
end;
ShowMessage('Final');
end;
function TForm1.Somar(A,B: Integer): integer;
begin
Result := A+b;
end;
function TForm1.Somar2(var A,B: Integer): integer;
begin
Result := A+b;
end;
end.
| 19.597403 | 112 | 0.622046 |
c3583b9af82a5a9b922d5547691a66f036e0a824 | 6,556 | pas | Pascal | tests/altium_crap/Scripts/Delphiscript Scripts/PCB/PadStackInfo.pas | hanun2999/Altium-Schematic-Parser | a9bd5b1a865f92f2e3f749433fb29107af528498 | [
"MIT"
]
| 1 | 2020-06-08T11:17:46.000Z | 2020-06-08T11:17:46.000Z | tests/altium_crap/Scripts/Delphiscript Scripts/PCB/PadStackInfo.pas | hanun2999/Altium-Schematic-Parser | a9bd5b1a865f92f2e3f749433fb29107af528498 | [
"MIT"
]
| null | null | null | tests/altium_crap/Scripts/Delphiscript Scripts/PCB/PadStackInfo.pas | hanun2999/Altium-Schematic-Parser | a9bd5b1a865f92f2e3f749433fb29107af528498 | [
"MIT"
]
| null | null | null | {..............................................................................}
{ Summary Fetch pad stack information for a clicked pad on PCB document }
{ Version 1.1 }
{ }
{ Copyright (c) 2006 by Altium Limited }
{..............................................................................}
{..............................................................................}
Function ShapeToString (AShape : TShape) : TPCBString;
Begin
Case AShape Of
eNoShape : Result := 'NoShape';
eRounded : Result := 'Rounded';
eRectangular : Result := 'Rectangular';
eOctagonal : Result := 'Octagonal';
eCircleShape : Result := 'CircleShape';
eArcShape : Result := 'ArcShape';
eTerminator : Result := 'Terminator';
eRoundRectShape : Result := 'RoundRectShape';
eRotatedRectShape : Result := 'RotatedRectShape';
End;
End;
{..............................................................................}
{..............................................................................}
Procedure ProcessSimplePad(APad : IPCB_Pad; Var AString : TPCBString);
Begin
AString := AString + ' X Size : ' + IntToStr(APad.TopXSize) + #13#10 +
' Y Size : ' + IntToStr(APad.TopYSize) + #13#10 +
' Shape : ' + ShapeToString(APad.TopShape);
End;
{..............................................................................}
{..............................................................................}
Procedure ProcessTopMidBotPad(APad : IPCB_Pad; Var AString : TPCBString);
Begin
AString := AString + 'Top X Size : ' + IntToStr(APad.TopXSize) + #13#10 +
'Top Y Size : ' + IntToStr(APad.TopYSize) + #13#10 +
'Top Shape : ' + ShapeToString(APad.TopShape) + #13#10 +
+ #13#10 +
'Mid X Size : ' + IntToStr(APad.MidXSize) + #13#10 +
'Mid Y Size : ' + IntToStr(APad.MidYSize) + #13#10 +
'Mid Shape : ' + ShapeToString(APad.MidShape) + #13#10 +
+ #13#10 +
'Bot X Size : ' + IntToStr(APad.BotXSize) + #13#10 +
'Bot Y Size : ' + IntToStr(APad.BotYSize) + #13#10 +
'Bot Shape : ' + ShapeToString(APad.BotShape);
End;
{..............................................................................}
{..............................................................................}
Procedure ProcessFullStackPad(APad : IPCB_Pad; Var AString : TPCBString);
Var
Layer : TLayer;
Begin
// checking if layer is part of layer stack up not implemented.
// a full stack pad is technically those layers that are defined in the
// layer stack up.
For Layer := MinLayer to MaxLayer Do
Begin
If (APad.XStackSizeOnLayer[Layer] <> 0) And
(APad.YStackSizeOnLayer[Layer] <> 0)
Then
Begin
AString := AString + Layer2String(Layer) + ' ' +
IntToStr(APad.XStackSizeOnLayer[Layer]) + ' ' +
IntToStr(APad.YStackSizeOnLayer[Layer]) + ' ' +
ShapeToString(APad.StackShapeOnLayer[Layer]) + #13#10;
End;
End;
End;
{..............................................................................}
{..............................................................................}
Procedure ProcessRoundHole (APad : IPCB_Pad; Var AString : TPCBString);
Begin
AString := AString + ' Rounded Hole' + #13#10;
End;
{..............................................................................}
{..............................................................................}
Procedure ProcessSquareHole(APad : IPCB_Pad; Var AString : TPCBString);
Begin
AString := AString + ' Squared Hole' + #13#10;
End;
{..............................................................................}
{..............................................................................}
Procedure ProcessSlotHole (APad : IPCB_Pad; Var AString : TPCBString);
Begin
AString := AString + ' Slotted Hole' + #13#10;
End;
{..............................................................................}
{..............................................................................}
Procedure FetchPadStackInfo;
Var
Board : IPCB_Board;
PadObject : IPCB_Pad;
PadCache : TPadCache;
L : TLayer;
PlanesArray : TPlanesConnectArray;
LS : TPCBString;
Begin
// Board.GetObjectAtCursor puts the PCB Editor into Interactive mode,
// ie a crosshair cursor appears and the 'Choose a pad' message
// on the status bar of DXP.
Board := PCBServer.GetCurrentPCBBoard;
If Board = Nil Then Exit;
PadObject := Board.GetObjectAtCursor(MkSet(ePadObject),
AllLayers,
'Choose a pad');
While PadObject <> 0 Do
Begin
LS := 'Pad Designator/Name: ' + PadObject.Name + #13#10;
// obtain net name only if it exists
If PadObject.Net <> Nil Then
LS := LS + 'Pad Net: ' + PadObject.Net.Name + #13#10;
// work out the pad stack style
If PadObject.Mode = ePadMode_Simple Then ProcessSimplePad (PadObject,LS)
Else If PadObject.Mode = ePadMode_LocalStack Then ProcessTopMidBotPad(PadObject,LS)
Else If PadObject.Mode = ePadMode_ExternalStack Then ProcessFullStackPad(PadObject,LS);
If PadObject.HoleType = eRoundHole Then ProcessRoundHole (PadObject,LS)
Else If PadObject.HoleType = eSquareHole Then ProcessSquareHole(PadObject,LS)
Else If PadObject.HoleType = eSlotHole Then ProcessSlotHole (PadObject,LS);
LS := LS + 'Pad Hole Rotation: ' + IntToStr(PadObject.HoleRotation);
// Display the results
ShowInfo(LS);
// Continue the loop - ie user can click on another pad or via object.
PadObject := Board.GetObjectAtCursor(MkSet(ePadObject), AllLayers, 'Choose a pad');
End;
End;
| 45.846154 | 95 | 0.430293 |
c361f4a95b869e068f4193ebbfeb143aca3276ef | 2,897 | pas | Pascal | Source/Services/Rekognition/Base/Transform/AWS.Rekognition.Transform.DescribeProjectsRequestMarshaller.pas | juliomar/aws-sdk-delphi | 995a0af808c7f66122fc6a04763d68203f8502eb | [
"Apache-2.0"
]
| 67 | 2021-07-28T23:47:09.000Z | 2022-03-15T11:48:35.000Z | Source/Services/Rekognition/Base/Transform/AWS.Rekognition.Transform.DescribeProjectsRequestMarshaller.pas | juliomar/aws-sdk-delphi | 995a0af808c7f66122fc6a04763d68203f8502eb | [
"Apache-2.0"
]
| 5 | 2021-09-01T09:31:16.000Z | 2022-03-16T18:19:21.000Z | Source/Services/Rekognition/Base/Transform/AWS.Rekognition.Transform.DescribeProjectsRequestMarshaller.pas | landgraf-dev/aws-sdk-delphi | 995a0af808c7f66122fc6a04763d68203f8502eb | [
"Apache-2.0"
]
| 13 | 2021-07-29T02:41:16.000Z | 2022-03-16T10:22:38.000Z | unit AWS.Rekognition.Transform.DescribeProjectsRequestMarshaller;
interface
uses
System.Classes,
System.SysUtils,
Bcl.Json.Writer,
AWS.Internal.Request,
AWS.Transform.RequestMarshaller,
AWS.Runtime.Model,
AWS.Rekognition.Model.DescribeProjectsRequest,
AWS.Internal.DefaultRequest,
AWS.SDKUtils;
type
IDescribeProjectsRequestMarshaller = IMarshaller<IRequest, TAmazonWebServiceRequest>;
TDescribeProjectsRequestMarshaller = class(TInterfacedObject, IMarshaller<IRequest, TDescribeProjectsRequest>, IDescribeProjectsRequestMarshaller)
strict private
class var FInstance: IDescribeProjectsRequestMarshaller;
class constructor Create;
public
function Marshall(AInput: TAmazonWebServiceRequest): IRequest; overload;
function Marshall(PublicRequest: TDescribeProjectsRequest): IRequest; overload;
class function Instance: IDescribeProjectsRequestMarshaller; static;
end;
implementation
{ TDescribeProjectsRequestMarshaller }
function TDescribeProjectsRequestMarshaller.Marshall(AInput: TAmazonWebServiceRequest): IRequest;
begin
Result := Marshall(TDescribeProjectsRequest(AInput));
end;
function TDescribeProjectsRequestMarshaller.Marshall(PublicRequest: TDescribeProjectsRequest): IRequest;
var
Request: IRequest;
begin
Request := TDefaultRequest.Create(PublicRequest, 'Amazon.Rekognition');
Request.Headers.Add('X-Amz-Target', 'RekognitionService.DescribeProjects');
Request.Headers.AddOrSetValue('Content-Type', 'application/x-amz-json-1.1');
Request.Headers.AddOrSetValue(THeaderKeys.XAmzApiVersion, '2016-06-27');
Request.HttpMethod := 'POST';
Request.ResourcePath := '/';
var Stream: TStringStream := TStringStream.Create('', TEncoding.UTF8, False);
try
var Writer: TJsonWriter := TJsonWriter.Create(Stream);
try
var Context: TJsonMarshallerContext := TJsonMarshallerContext.Create(Request, Writer);
try
Writer.WriteBeginObject;
if PublicRequest.IsSetMaxResults then
begin
Context.Writer.WriteName('MaxResults');
Context.Writer.WriteInteger(PublicRequest.MaxResults);
end;
if PublicRequest.IsSetNextToken then
begin
Context.Writer.WriteName('NextToken');
Context.Writer.WriteString(PublicRequest.NextToken);
end;
Writer.WriteEndObject;
Writer.Flush;
var Snippet: string := Stream.DataString;
Request.Content := TEncoding.UTF8.GetBytes(Snippet);
finally
Context.Free;
end;
finally
Writer.Free;
end;
finally
Stream.Free;
end;
Result := Request;
end;
class constructor TDescribeProjectsRequestMarshaller.Create;
begin
FInstance := TDescribeProjectsRequestMarshaller.Create;
end;
class function TDescribeProjectsRequestMarshaller.Instance: IDescribeProjectsRequestMarshaller;
begin
Result := FInstance;
end;
end.
| 31.48913 | 148 | 0.757335 |
c39ccefceb1e0c61afae2cdb19763ef2b90511e4 | 5,160 | dfm | Pascal | Chapter13/03_MyParksApache/uwmMyParks.dfm | Maran9/Fearless-Cross-Platform-Development-with-Delphi | 6c7eea60c4c977341c255ffeea80b04b5a0135dd | [
"MIT"
]
| 25 | 2020-06-19T10:50:25.000Z | 2022-03-16T12:46:25.000Z | Chapter13/03_MyParksApache/uwmMyParks.dfm | Maran9/Fearless-Cross-Platform-Development-with-Delphi | 6c7eea60c4c977341c255ffeea80b04b5a0135dd | [
"MIT"
]
| null | null | null | Chapter13/03_MyParksApache/uwmMyParks.dfm | Maran9/Fearless-Cross-Platform-Development-with-Delphi | 6c7eea60c4c977341c255ffeea80b04b5a0135dd | [
"MIT"
]
| 7 | 2020-08-27T02:55:57.000Z | 2022-03-02T21:25:21.000Z | object wmMyParks: TwmMyParks
OldCreateOrder = False
OnCreate = WebModuleCreate
OnDestroy = WebModuleDestroy
Actions = <
item
Default = True
Name = 'waiAbout'
PathInfo = '/about'
Producer = ppAbout
end
item
Name = 'waiGetParkFromQuery'
PathInfo = '/getpark'
Producer = ppGetParkQuery
end
item
Name = 'waiShowParkFromCoords'
PathInfo = '/showpark'
OnAction = wmMyParkswaiShowParkFromCoordsAction
end
item
Name = 'waiParkList'
PathInfo = '/parklist'
Producer = dstpMyParks
end>
Height = 347
Width = 415
object ppAbout: TPageProducer
HTMLDoc.Strings = (
'<#header PageTitle="About">'
''
'<#menu>'
''
' <div class="col-md-12 bg-light shadow p-3 mb-5 bg-body round' +
'ed">'
''
'<p>The <strong><#AppName></strong> app is a simple database of p' +
'arks, pictures of parks, and coordinates.'
'You build this database yourself and use as reference for places' +
' you'#39've visited.</p>'
'<p>Built from the book, <em>Fearless Cross-Platform Development ' +
'with Delphi</em> by Packt Publishing.</p>'
''
' </div>'
''
'<#footer>')
OnHTMLTag = ppStandardHTMLTag
Left = 56
Top = 56
end
object ppGetParkQuery: TPageProducer
HTMLDoc.Strings = (
'<#header PageTitle="Park Query">'
''
'<#menu>'
''
' <div class="col-md-12 bg-light shadow p-3 mb-5 bg-body round' +
'ed">'
''
'<h3>Find a Park by Location</h3>'
'<form action="<#ScriptName>/showpark">'
' <label for="long">Longitude:</label><br>'
' <input type="text" id="long" name="long"><br><br>'
' <label for="lat">Latitude:</label><br>'
' <input type="text" id="lat" name="lat"><br><br>'
' <button type="submit" class="btn btn-primary">Submit</button>'
'</form>'
''
' </div>'
''
'<#footer>')
OnHTMLTag = ppStandardHTMLTag
Left = 56
Top = 120
end
object ppShowParkFromCoords: TPageProducer
HTMLDoc.Strings = (
'<#header PageTitle="Located Park">'
''
'<#menu>'
''
' <div class="col-md-12 shadow p-3 mb-5 bg-body rounded">'
''
'The park at <#longitude>, <#latitude> is: <#ParkName>'
''
' </div>'
''
'<#footer>')
OnHTMLTag = ppShowParkFromCoordsHTMLTag
Left = 72
Top = 168
end
object ppPageHeader: TPageProducer
HTMLDoc.Strings = (
'<html>'
'<head>'
'<title><#AppName> | <#PageTitle></title>'
'<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/cs' +
's/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2' +
'eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crosso' +
'rigin="anonymous">'
'</head>'
'<body>'
''
'<div class="container-fluid px-5">'
' <div class="row">'
' <div class="col-md-12">'
' <h2 class="text-center">'
' <#AppName>'
' </h2>'
' </div>')
OnHTMLTag = ppPageHeaderHTMLTag
Left = 200
Top = 24
end
object ppPageFooter: TPageProducer
HTMLDoc.Strings = (
' </div>'
'</div>'
''
'<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/j' +
's/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNU' +
'aaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anon' +
'ymous"></script>'
'</body>'
'</html>')
OnHTMLTag = ppPageFooterHTMLTag
Left = 200
Top = 80
end
object ppMenu: TPageProducer
HTMLDoc.Strings = (
'<ul class="nav nav-pills px-5 shadow p-3 mb-5 bg-body rounded">'
' <li class="nav-item">'
' <a class="nav-link" href="about">About this site</a>'
' </li>'
' <li class="nav-item">'
' <a class="nav-link" href="getpark">Get Park by Coordinates</' +
'a>'
' </li>'
' <li class="nav-item">'
' <a class="nav-link" href="parklist">Show All Parks</a>'
' </li>'
'</ul>')
Left = 200
Top = 136
end
object ppParkList: TPageProducer
HTMLDoc.Strings = (
'<#header PageTitle="Park List">'
''
'<#menu>'
''
' <div class="col-md-12 shadow p-3 mb-5 bg-body rounded">'
'<#parklist>'
' </div>'
''
'<#footer>')
OnHTMLTag = ppStandardHTMLTag
Left = 56
Top = 224
end
object dstpMyParks: TDataSetTableProducer
Columns = <
item
FieldName = 'PARK_NAME'
end
item
FieldName = 'LONGITUDE'
end
item
FieldName = 'LATITUDE'
end>
MaxRows = 200
DataSet = dmParksDB.qryParkList
TableAttributes.Align = haCenter
TableAttributes.BgColor = 'Lime'
TableAttributes.Border = 1
TableAttributes.CellSpacing = 2
TableAttributes.CellPadding = 10
TableAttributes.Width = -1
Left = 128
Top = 240
end
end
| 26.461538 | 76 | 0.542829 |
479573614d40dd7f79d752366e1eee4df3787da4 | 19,122 | pas | Pascal | Designer/FMain.pas | joerg-github/RibbonFramework | 48f02adca38c5725270309c7512183eca6e15b4b | [
"BSD-3-Clause"
]
| 42 | 2020-06-18T05:41:11.000Z | 2022-03-15T13:26:23.000Z | Designer/FMain.pas | joerg-github/RibbonFramework | 48f02adca38c5725270309c7512183eca6e15b4b | [
"BSD-3-Clause"
]
| 14 | 2018-12-12T10:06:24.000Z | 2020-02-06T16:05:43.000Z | Designer/FMain.pas | joerg-github/RibbonFramework | 48f02adca38c5725270309c7512183eca6e15b4b | [
"BSD-3-Clause"
]
| 16 | 2020-05-29T12:01:06.000Z | 2022-02-13T07:53:17.000Z | unit FMain;
interface
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
ComCtrls,
ToolWin,
StdCtrls,
ActnList,
ExtCtrls,
AppEvnts,
ImgList,
Menus,
Actions,
ShellApi,
RibbonMarkup,
RibbonCompiler,
Settings,
BasicZip,
FCommands,
FViews,
FXmlSource,
FPreview,
FSettings,
FNewFile;
type
TFormMain = class(TForm)
ToolBar: TToolBar;
ButtonOpen: TToolButton;
MemoMessages: TMemo;
ButtonPreview: TToolButton;
ActionList: TActionList;
ActionPreview: TAction;
SplitterLog: TSplitter;
PageControl: TPageControl;
TabSheetCommands: TTabSheet;
ApplicationEvents: TApplicationEvents;
StatusBar: TStatusBar;
ActionOpen: TAction;
ActionNew: TAction;
ActionSave: TAction;
ActionSaveAs: TAction;
ButtonSave: TToolButton;
SaveDialog: TSaveDialog;
OpenDialog: TOpenDialog;
TabSheetViews: TTabSheet;
Images: TImageList;
MainMenu: TMainMenu;
MenuFile: TMenuItem;
MenuNew: TMenuItem;
MenuOpen: TMenuItem;
N1: TMenuItem;
MenuSave: TMenuItem;
SaveAsMenu: TMenuItem;
ActionExit: TAction;
N2: TMenuItem;
MenuExit: TMenuItem;
MenuProject: TMenuItem;
MenuPreview: TMenuItem;
ToolButton1: TToolButton;
ActionSettings: TAction;
N3: TMenuItem;
SettingsMenu: TMenuItem;
TimerRestoreLog: TTimer;
ActionNewBlank: TAction;
TabSheetXmlSource: TTabSheet;
ActionBuild: TAction;
ButtonBuild: TToolButton;
BuildMenu: TMenuItem;
ActionTutorial: TAction;
ActionWebSite: TAction;
ActionMSDN: TAction;
MenuHelp: TMenuItem;
MenuTutorial: TMenuItem;
MenuWebsite: TMenuItem;
N4: TMenuItem;
MenuMSDN: TMenuItem;
ActionSetResourceName: TAction;
Setresourcename1: TMenuItem;
ActionGenerateResourceIDs: TAction;
AutogenerateIDsforallcommands1: TMenuItem;
ActionGenerateCommandIDs: TAction;
AutogenerateIDsforallresources1: TMenuItem;
procedure FormActivate(Sender: TObject);
procedure ActionPreviewExecute(Sender: TObject);
procedure ApplicationEventsException(Sender: TObject; E: Exception);
procedure ApplicationEventsHint(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ActionSaveExecute(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure ActionSaveAsExecute(Sender: TObject);
procedure ActionOpenExecute(Sender: TObject);
procedure PageControlChange(Sender: TObject);
procedure ActionExitExecute(Sender: TObject);
procedure ActionSettingsExecute(Sender: TObject);
procedure TimerRestoreLogTimer(Sender: TObject);
procedure ActionNewExecute(Sender: TObject);
procedure ActionBuildExecute(Sender: TObject);
procedure ActionTutorialExecute(Sender: TObject);
procedure ActionWebSiteExecute(Sender: TObject);
procedure ActionMSDNExecute(Sender: TObject);
procedure ActionSetResourceNameExecute(Sender: TObject);
procedure ActionGenerateResourceIDsExecute(Sender: TObject);
procedure ActionGenerateCommandIDsExecute(Sender: TObject);
private
{ Private declarations }
FInitialized: Boolean;
FDocument: TRibbonDocument;
FCompiler: TRibbonCompiler;
FFrameCommands: TFrameCommands;
FFrameViews: TFrameViews;
FFrameXmlSource: TFrameXmlSource;
FModified: Boolean;
FPreviewForm: TFormPreview;
private
procedure CMShowingChanged(var Msg: TMessage); message CM_SHOWINGCHANGED;
procedure RibbonCompilerMessage(const Compiler: TRibbonCompiler;
const MsgType: TMessageKind; const Msg: String);
procedure ClearLog;
procedure Log(const MsgType: TMessageKind; const Msg: String);
procedure NewFile(const EmptyFile: Boolean);
procedure OpenFile(const Filename: String);
procedure ClearDocument;
procedure ShowDocument;
procedure ShowSettingsDialog;
procedure UpdateCaption;
procedure UpdateControls;
procedure ClearModified;
function CheckSave: Boolean;
procedure BuildAndPreview(const Preview: Boolean);
procedure OpenWebsite(const Url: String);
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Modified;
end;
var
FormMain: TFormMain;
resourcestring
RS_CANNOT_LOAD_DLL = 'Unable to load Ribbon Resource DLL';
RS_MODIFIED = 'Modified';
RS_RIBBON_DESIGNER = 'Ribbon Designer';
RS_UNTITLED = '(untitled document)';
RS_CHANGED_HEADER = 'Document has changed';
RS_CHANGED_MESSAGE = 'The document has changed. Do you want to save the changes?';
RS_DIFFERENT_DIR_HEADER = 'Directory changed';
RS_DIFFERENT_DIR_MESSAGE = 'You are about to save to document to a different directory.' + sLineBreak +
'Any images associated with this document will NOT be copied to this new directory.' + sLineBreak +
'If you want to keep these images, you will need to copy them to the new directory yourself.' + sLineBreak +
'Do you want to continue to save this document?';
implementation
uses
UITypes, System.Win.Registry, UIRibbonUtils, System.Math;
{$R *.dfm}
const // Status Panel
SP_MODIFIED = 0;
SP_HINT = 1;
procedure TFormMain.ActionBuildExecute(Sender: TObject);
begin
BuildAndPreview(False);
end;
procedure TFormMain.ActionExitExecute(Sender: TObject);
begin
Close;
end;
procedure TFormMain.ActionGenerateCommandIDsExecute(Sender: TObject);
var
lCommand: TRibbonCommand;
I: Integer;
begin
for I := 0 to FFrameCommands.ListViewCommands.Items.Count - 1 do
begin
lCommand := FFrameCommands.ListViewCommands.Items[i].Data;
if lCommand.ID = 0 then
// Try to mimic the auto ID generation of the ribbon compiler.
lCommand.ID := FFrameCommands.FindSmallestUnusedID(I + 2)
end;
FFrameCommands.RefreshSelection;
end;
procedure TFormMain.ActionGenerateResourceIDsExecute(Sender: TObject);
var
FAutoID: integer;
Procedure SetID(rs:TRibbonString);
begin
if RS.Content <>'' then begin
RS.Id := FAutoID;
inc(FAutoID);
end;
end;
Procedure setImageID(rl:TRibbonList<TRibbonImage>);
var
i: integer;
begin
for i := 0 to rl.count-1 do begin
rl.Items[i].Id := FAutoId;
inc(FAutoID);
end;
end;
var
command:TRibbonCommand;
i, maxID :integer;
s: string;
begin
{First work out the maximum no of command ids that will be required}
MaxID := FFrameCommands.ListViewCommands.items.count-1;
for I := 0 to FFrameCommands.ListViewCommands.items.count-1 do begin
Command := FFrameCommands.ListViewCommands.Items[i].Data;
with command do begin
if LabelTitle.Content <> '' then
inc(MaxID);
if LabelDescription.Content <> '' then
inc(MaxID);
if TooltipTitle.Content <> '' then
inc(MaxID);
if TooltipDescription.Content <> '' then
inc(MaxID);
if Keytip.Content <> '' then
inc(MaxID);
inc(MaxID, SmallImages.Count+LargeImages.Count
+SmallHighContrastImages.Count+LargeHighContrastImages.Count);
end;
end;
if inputQuery('ID Number', 'Enter the starting ID number between 2 & '+(59999-MaxID).ToString, s) then begin
if not tryStrToInt(s, FAutoID) then begin
raise Exception.Create('Invald integer value');
exit;
end;
end
else
exit;
if (FAutoID < 2) or (FAUtoID + MaxID > 59999) then begin
raise Exception.Create(FAutoID.ToString + 'is an invlid starting ID. '
+'Must be a number between 2 and < '+ (59999 - MaxID).ToString);
exit;
end;
for I := 0 to FFrameCommands.ListViewCommands.items.count-1 do begin
Command := FFrameCommands.ListViewCommands.Items[i].Data;
with command do begin
SetID(LabelTitle);
SetID(LabelDescription);
SetID(TooltipTitle);
SetID(TooltipDescription);
SetID(Keytip);
setImageID(SmallImages);
setImageID(LargeImages);
setImageID(SmallHighContrastImages);
setImageID(LargeHighContrastImages);
end;
end;
FFrameCommands.RefreshSelection;
end;
procedure TFormMain.ActionMSDNExecute(Sender: TObject);
begin
OpenWebsite('http://msdn.microsoft.com/en-us/library/dd371191%28v=VS.85%29.aspx');
end;
procedure TFormMain.ActionNewExecute(Sender: TObject);
begin
NewFile(False);
end;
procedure TFormMain.ActionOpenExecute(Sender: TObject);
begin
if (not CheckSave) then
Exit;
if (OpenDialog.Execute) then
OpenFile(OpenDialog.FileName);
end;
procedure TFormMain.ActionPreviewExecute(Sender: TObject);
begin
BuildAndPreview(True);
end;
procedure TFormMain.ActionSaveAsExecute(Sender: TObject);
var
OrigDir, NewDir: String;
begin
OrigDir := ExtractFilePath(FDocument.Filename);
SaveDialog.FileName := ExtractFilename(FDocument.Filename);
SaveDialog.InitialDir := ExtractFilePath(OrigDir);
if (SaveDialog.Execute) then
begin
NewDir := ExtractFilePath(SaveDialog.FileName);
if (OrigDir <> '') and (not SameText(OrigDir, NewDir)) then
begin
if (TaskMessageDlg(RS_DIFFERENT_DIR_HEADER, RS_DIFFERENT_DIR_MESSAGE,
mtConfirmation, [mbYes, mbNo], 0, mbNo) = mrNo)
then
Exit;
end;
FDocument.SaveToFile(SaveDialog.FileName);
UpdateCaption;
UpdateControls;
ClearModified;
end;
end;
procedure TFormMain.ActionSaveExecute(Sender: TObject);
begin
if (FDocument.Filename = '') then
ActionSaveAs.Execute
else
begin
FDocument.SaveToFile(FDocument.Filename);
ClearModified;
end;
end;
procedure TFormMain.ActionSetResourceNameExecute(Sender: TObject);
var
lUserInput: string;
begin
lUserInput := InputBox('Enter resource name', 'Please enter a resource name that is used for this ribbon markup', FDocument.Application.ResourceName);
if lUserInput <> '' then
FDocument.Application.ResourceName := lUserInput;
end;
procedure TFormMain.ActionSettingsExecute(Sender: TObject);
begin
ShowSettingsDialog;
end;
procedure TFormMain.ActionTutorialExecute(Sender: TObject);
begin
OpenWebsite('http://www.bilsen.com/windowsribbon/tutorial.shtml');
end;
procedure TFormMain.ActionWebSiteExecute(Sender: TObject);
begin
OpenWebsite('http://www.bilsen.com/windowsribbon/index.shtml');
end;
procedure TFormMain.ApplicationEventsException(Sender: TObject; E: Exception);
begin
MemoMessages.Color := clRed;
Log(mkError, E.Message);
TimerRestoreLog.Enabled := True;
end;
procedure TFormMain.ApplicationEventsHint(Sender: TObject);
begin
StatusBar.Panels[SP_HINT].Text := Application.Hint;
end;
procedure TFormMain.BuildAndPreview(const Preview: Boolean);
var
DllInstance: THandle;
Result: TRibbonCompileResult;
begin
ClearLog;
if (FModified) then
ActionSave.Execute;
FreeAndNil(FPreviewForm);
// Create DLL only if a preview is requested
Result := FCompiler.Compile(FDocument, FDocument.Application.ResourceName, Preview);
if (Result = crOk) then
begin
if (Preview) then
begin
DllInstance := LoadLibraryEx(PChar(FCompiler.OutputDllPath), 0, LOAD_LIBRARY_AS_DATAFILE);
if (DllInstance = 0) then
begin
Log(mkError, RS_CANNOT_LOAD_DLL);
Exit;
end;
try
FPreviewForm := TFormPreview.Create(DllInstance, FDocument, FDocument.Application.ResourceName);
FPreviewForm.Show;
except
FreeLibrary(DllInstance);
end;
end;
end
else
begin
MemoMessages.Color := clRed;
// MemoMessages.Update;
TimerRestoreLog.Enabled := True;
// if (Result = crRibbonCompilerError) then
// begin
// FFrameXmlSource.Activate;
// PageControl.ActivePage := TabSheetXmlSource;
// end;
end
end;
function TFormMain.CheckSave: Boolean;
begin
Result := True;
if (FModified) then
begin
case TaskMessageDlg(RS_CHANGED_HEADER, RS_CHANGED_MESSAGE, mtConfirmation,
mbYesNoCancel, 0, mbYes)
of
mrYes:
begin
if (ActionSave.Enabled) then
ActionSave.Execute
else
ActionSaveAs.Execute;
end;
mrNo:
;
mrCancel:
Result := False;
end;
end;
end;
procedure TFormMain.ClearDocument;
begin
FFrameCommands.ClearDocument;
FFrameViews.ClearDocument;
FFrameXmlSource.ClearDocument;
FDocument.Clear;
end;
procedure TFormMain.ClearLog;
begin
MemoMessages.Clear;
end;
procedure TFormMain.ClearModified;
begin
FModified := False;
StatusBar.Panels[SP_MODIFIED].Text := '';
end;
procedure TFormMain.CMShowingChanged(var Msg: TMessage);
begin
inherited;
if Showing and (not FInitialized) then
begin
FInitialized := True;
if (not TSettings.Instance.ToolsAvailable) then
if (TaskMessageDlg(RS_TOOLS_HEADER, RS_TOOLS_MESSAGE + sLineBreak + RS_TOOLS_SETUP, mtWarning,
[mbYes, mbNo], 0, mbYes) = mrYes)
then
ShowSettingsDialog;
end;
end;
constructor TFormMain.Create(AOwner: TComponent);
begin
inherited;
// Write the path to the Ribbon Designer to the registry, so that the designtime package knows where to find it. Issue #22
With TRegistry.Create do
try
OpenKey(cRegistryPath, True);
WriteString(cRegistryKeyDesigner, ParamStr(0));
finally
Free;
end;
FDocument := TRibbonDocument.Create;
FCompiler := TRibbonCompiler.Create;
FCompiler.OnMessage := RibbonCompilerMessage;
FFrameCommands := TFrameCommands.Create(Self);
FFrameCommands.Parent := TabSheetCommands;
FFrameViews := TFrameViews.Create(Self);
FFrameViews.Parent := TabSheetViews;
FFrameXmlSource := TFrameXmlSource.Create(Self);
FFrameXmlSource.Parent := TabSheetXmlSource;
// Handle command line options
if (ParamCount > 0) and FileExists(ParamStr(1)) then begin // File passed at the command line?
OpenFile(ParamStr(1));
if FindCmdLineSwitch('BUILD') then begin
ActionBuild.Execute();
Application.ShowMainForm := False;
Application.Terminate();
end// if /BUILD
else begin
NewFile(True);
end;//else
end // if file passed
end;
destructor TFormMain.Destroy;
begin
FCompiler.Free;
FDocument.Free;
inherited;
end;
procedure TFormMain.FormActivate(Sender: TObject);
begin
MemoMessages.SelLength := 0;
if ParamStr(1) <> '' then
OpenFile(ParamStr(1));
end;
procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Assigned(FPreviewForm) then
FreeAndNil(FPreviewForm);
end;
procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if (not CheckSave) then
CanClose := False;
end;
procedure TFormMain.Log(const MsgType: TMessageKind;
const Msg: String);
const
MSG_TYPES: array [TMessageKind] of String = (
'', 'WARNING: ', 'ERROR: ', '');
begin
MemoMessages.Lines.Add(MSG_TYPES[MsgType] + Msg);
end;
procedure TFormMain.Modified;
begin
if (not FModified) then
begin
FModified := True;
StatusBar.Panels[SP_MODIFIED].Text := RS_MODIFIED;
end;
end;
procedure TFormMain.NewFile(const EmptyFile: Boolean);
var
Template: TRibbonTemplate;
Filename, FilePath: String;
ZipStream: TResourceStream;
ZipReader: TZipReader;
begin
if (not CheckSave) then
Exit;
if (EmptyFile) then
begin
Template := rtNone;
Filename := '';
end
else if (not NewFileDialog(Template, Filename)) then
Exit;
ClearDocument;
if (Template = rtNone) then
begin
if (Filename <> '') then
FDocument.SaveToFile(Filename)
end
else
begin
Screen.Cursor := crHourGlass;
try
FilePath := ExtractFilePath(Filename);
ZipReader := nil;
ZipStream := TResourceStream.Create(HInstance, 'TEMPLATE_WORDPAD', 'ZIP');
try
ZipReader := TZipReader.Create(ZipStream);
ZipReader.Extract(FilePath);
finally
ZipStream.Free;
ZipReader.Free;
end;
RenameFile(FilePath + 'RibbonMarkup.xml', Filename);
FDocument.LoadFromFile(Filename);
finally
Screen.Cursor := crDefault;
end;
end;
PageControl.ActivePage := TabSheetCommands;
ActiveControl := FFrameCommands.ListViewCommands;
ShowDocument;
UpdateCaption;
UpdateControls;
ClearModified;
end;
procedure TFormMain.OpenFile(const Filename: String);
begin
ClearDocument;
FDocument.LoadFromFile(Filename);
PageControl.ActivePage := TabSheetCommands;
ActiveControl := FFrameCommands.ListViewCommands;
ShowDocument;
UpdateCaption;
UpdateControls;
ClearModified;
end;
procedure TFormMain.OpenWebsite(const Url: String);
begin
ShellExecute(Handle, 'open', PWideChar(Url), nil, nil, SW_SHOWNORMAL);
end;
procedure TFormMain.PageControlChange(Sender: TObject);
begin
if (PageControl.ActivePage = TabSheetViews) then
begin
FFrameCommands.Deactivate;
FFrameXmlSource.Deactivate;
FFrameViews.Activate;
end
else if (PageControl.ActivePage = TabSheetCommands) then
begin
FFrameViews.Deactivate;
FFrameXmlSource.Deactivate;
FFrameCommands.Activate
end
else if (PageControl.ActivePage = TabSheetXmlSource) then
begin
if (FModified) then
ActionSave.Execute;
FFrameViews.Deactivate;
FFrameCommands.Deactivate;
FFrameXmlSource.Activate;
end;
end;
procedure TFormMain.RibbonCompilerMessage(const Compiler: TRibbonCompiler;
const MsgType: TMessageKind; const Msg: String);
begin
if (MsgType = mkPipe) then
MemoMessages.Text := MemoMessages.Text + Msg
else
Log(MsgType, Msg);
end;
procedure TFormMain.ShowDocument;
begin
FFrameXmlSource.Deactivate;
FFrameViews.Deactivate;
FFrameCommands.Activate;
FFrameCommands.ShowDocument(FDocument);
FFrameViews.ShowDocument(FDocument);
FFrameXmlSource.ShowDocument(FDocument);
end;
procedure TFormMain.ShowSettingsDialog;
var
Form: TFormSettings;
begin
Form := TFormSettings.Create(TSettings.Instance);
try
Form.ShowModal;
finally
Form.Release;
end;
end;
procedure TFormMain.TimerRestoreLogTimer(Sender: TObject);
begin
TimerRestoreLog.Enabled := False;
MemoMessages.Color := clWindow;
end;
procedure TFormMain.UpdateCaption;
begin
if (FDocument.Filename = '') then
Caption := RS_UNTITLED + ' - ' + RS_RIBBON_DESIGNER
else
Caption := ExtractFilename(FDocument.Filename) + ' - ' + RS_RIBBON_DESIGNER;
end;
procedure TFormMain.UpdateControls;
begin
ActionPreview.Enabled := FileExists(FDocument.Filename);
ActionBuild.Enabled := ActionPreview.Enabled;
end;
end.
| 26.819074 | 153 | 0.696789 |
fc35e327e6009176697732ae3bfdc04f518d8584 | 2,388 | pas | Pascal | Chapter07/Observer/SpringObserverMain.pas | PacktPublishing/Hands-On-Design-Patterns-with-Delphi | 30f6ab51e61d583f822be4918f4b088e2255cd82 | [
"MIT"
]
| 38 | 2019-02-28T06:22:52.000Z | 2022-03-16T12:30:43.000Z | Chapter07/Observer/SpringObserverMain.pas | alefragnani/Hands-On-Design-Patterns-with-Delphi | 3d29e5b2ce9e99e809a6a9a178c3f5e549a8a03d | [
"MIT"
]
| null | null | null | Chapter07/Observer/SpringObserverMain.pas | alefragnani/Hands-On-Design-Patterns-with-Delphi | 3d29e5b2ce9e99e809a6a9a178c3f5e549a8a03d | [
"MIT"
]
| 18 | 2019-03-29T08:36:14.000Z | 2022-03-30T00:31:28.000Z | unit SpringObserverMain;
interface
uses
Winapi.Windows, Winapi.Messages,
System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Samples.Spin,
SpringObservedModel;
type
TfrmSpringObserver = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
inpPrice: TSpinEdit;
inpDiscount: TSpinEdit;
lbLog: TListBox;
inpEndPrice: TEdit;
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure inpDiscountChange(Sender: TObject);
procedure inpPriceChange(Sender: TObject);
private
FModel: TObservableModel;
FEditObserver: IObserver;
FListBoxObserver: IObserver;
public
end;
var
frmSpringObserver: TfrmSpringObserver;
implementation
{$R *.dfm}
type
TModelObserver = class(TInterfacedObject, IObserver)
strict private
FNotifier: TProc<TObservableModel>;
public
constructor Create(notifier: TProc<TObservableModel>);
procedure Update(Subject: TObject);
end;
{ TModelObserver }
constructor TModelObserver.Create(notifier: TProc<TObservableModel>);
begin
inherited Create;
FNotifier := notifier;
end;
procedure TModelObserver.Update(Subject: TObject);
begin
FNotifier(Subject as TObservableModel);
end;
{ TfrmSpringObserver }
procedure TfrmSpringObserver.FormCreate(Sender: TObject);
begin
FModel := TObservableModel.Create;
FModel.BasePrice := inpPrice.Value;
FModel.Discount := inpDiscount.Value;
FEditObserver := TModelObserver.Create(
procedure (model: TObservableModel)
begin
inpEndPrice.Text := Format('%.1f', [model.EndPrice]);
end);
FModel.Attach(FEditObserver);
FListBoxObserver := TModelObserver.Create(
procedure (model: TObservableModel)
begin
lbLog.ItemIndex := lbLog.Items.Add(Format('New price: %.1f (%.1f * %d%%)',
[model.EndPrice, model.BasePrice, 100 - model.Discount]));
end);
FModel.Attach(FListBoxObserver);
end;
procedure TfrmSpringObserver.FormDestroy(Sender: TObject);
begin
FModel.Detach(FEditObserver);
FModel.Detach(FListBoxObserver);
FreeAndNil(FModel);
end;
procedure TfrmSpringObserver.inpDiscountChange(Sender: TObject);
begin
FModel.Discount := inpDiscount.Value;
end;
procedure TfrmSpringObserver.inpPriceChange(Sender: TObject);
begin
FModel.BasePrice := inpPrice.Value;
end;
end.
| 23.411765 | 85 | 0.744556 |
c310a97d50e46e9204d02779a7a21bc1d2eed933 | 653 | pas | Pascal | src/isbn1.pas | EULIR/OI-practicce-code | a7b982d279599d68a2ff51ebd50858f832314971 | [
"Apache-2.0"
]
| 2 | 2019-03-16T15:27:31.000Z | 2019-03-17T06:50:15.000Z | src/isbn1.pas | EULIR/OI-practicce-code | a7b982d279599d68a2ff51ebd50858f832314971 | [
"Apache-2.0"
]
| null | null | null | src/isbn1.pas | EULIR/OI-practicce-code | a7b982d279599d68a2ff51ebd50858f832314971 | [
"Apache-2.0"
]
| null | null | null | var
s:string;
c,i,j:longint;
function try1(s:char):longint;
begin
exit(ord(s)-ord('0'));
end;
begin
readln(s);
// c:=1*try1(s[1])+2*try1(s[3])+3*try1(s[4])+4*try1(s[5])+5*try1(s[7])+6*try1(s[8])+7*try1(s[9])+8*try1(s[10])+9*try1(s[11]);
while j<10 do
begin
inc(i);
if (ord(s[i])>=48)and(ord(s[i])<=57)then begin inc(j); inc(c,j*try1(s[i])); end;
end;
if (c mod 11 )=try1(s[13]) then writeln('Right')
else begin for i:=1 to 12 do
write(s[i]);
write(c mod 11);
end;
end. | 31.095238 | 126 | 0.436447 |
fcb04f0e3938629dea16a87c6d2d14e067e79d30 | 474 | pas | Pascal | Trysil/Data/FireDAC/Trysil.Data.FireDAC.Common.pas | lminuti/Trysil | 773b65746c8574790fe18bceb8eef8003c00f430 | [
"BSD-3-Clause"
]
| 1 | 2022-01-12T06:48:47.000Z | 2022-01-12T06:48:47.000Z | Trysil/Data/FireDAC/Trysil.Data.FireDAC.Common.pas | lminuti/Trysil | 773b65746c8574790fe18bceb8eef8003c00f430 | [
"BSD-3-Clause"
]
| null | null | null | Trysil/Data/FireDAC/Trysil.Data.FireDAC.Common.pas | lminuti/Trysil | 773b65746c8574790fe18bceb8eef8003c00f430 | [
"BSD-3-Clause"
]
| null | null | null | (*
Trysil
Copyright © David Lastrucci
All rights reserved
Trysil - Operation ORM (World War II)
http://codenames.info/operation/orm/
*)
unit Trysil.Data.FireDAC.Common;
interface
uses
System.Classes,
System.SysUtils,
// FireDAC requires
FireDAC.Stan.Def,
FireDAC.Stan.Intf,
FireDAC.Stan.Pool,
FireDAC.DApt,
FireDAC.Stan.Async,
FireDAC.VCLUI.Wait,
FireDAC.ConsoleUI.Wait,
// FireDAC Drivers
FireDAC.Phys.MSSQL;
implementation
end.
| 13.941176 | 39 | 0.71519 |
c3c1e82d4b06092da8297943a3d41a1a0a0930d5 | 33,764 | pas | Pascal | Demo/Source/uSplitView.pas | EtheaDev/VCLThemeSelector | 2590d576fe3090e7ec4c1e4dd0ea9932497d7fc1 | [
"Apache-2.0"
]
| 44 | 2020-04-27T22:42:34.000Z | 2022-03-21T14:01:44.000Z | Demo/Source/uSplitView.pas | EtheaDev/VCLThemeSelector | 2590d576fe3090e7ec4c1e4dd0ea9932497d7fc1 | [
"Apache-2.0"
]
| 1 | 2022-01-28T11:31:55.000Z | 2022-01-28T17:48:09.000Z | Demo/Source/uSplitView.pas | EtheaDev/VCLThemeSelector | 2590d576fe3090e7ec4c1e4dd0ea9932497d7fc1 | [
"Apache-2.0"
]
| 6 | 2020-04-28T20:16:37.000Z | 2021-06-03T15:43:22.000Z | {******************************************************************************}
{ ModernAppDemo by Carlo Barazzetta }
{ A full example of an HighDPI - VCL Themed enabled application }
{ See how to select the application Theme using VCLThemeSelector Form }
{ }
{ Copyright (c) 2020, 2021 (Ethea S.r.l.) }
{ Author: Carlo Barazzetta }
{ https://github.com/EtheaDev/VCLThemeSelector }
{ }
{ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 }
{ }
{ Unless required by applicable law or agreed to in writing, software }
{ distributed under the License is distributed on an "AS IS" BASIS, }
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{ See the License for the specific language governing permissions and }
{ limitations under the License. }
{ }
{******************************************************************************}
//-----------------------------------------------------------------------------
// Original software is Copyright (c) 2015 Embarcadero Technologies, Inc.
// You may only use this software if you are an authorized licensee
// of an Embarcadero developer tools product.
// This software is considered a Redistributable as defined under
// the software license agreement that comes with the Embarcadero Products
// and is subject to that software license agreement.
//-----------------------------------------------------------------------------
unit uSplitView;
{$I ..\..\Source\VCLThemeSelector.inc}
interface
uses
Winapi.Windows
, Winapi.Messages
, System.SysUtils
, System.Variants
, System.Classes
, System.ImageList
, System.Actions
, Vcl.Graphics
, Vcl.Controls
, Vcl.Forms
, Vcl.Dialogs
, Vcl.ExtCtrls
, Vcl.WinXCtrls
, Vcl.StdCtrls
, Vcl.CategoryButtons
, Vcl.Buttons
, Vcl.ImgList
, Vcl.Imaging.PngImage
, Vcl.ComCtrls
, Vcl.ActnList
, Vcl.Menus
, Vcl.Mask
, Data.DB
, Datasnap.DBClient
, Vcl.WinXCalendars
, Vcl.CheckLst
, Vcl.DBCtrls
, Vcl.ColorGrd
, Vcl.Samples.Spin
, Vcl.Grids
, Vcl.DBGrids
, Vcl.ToolWin
, Vcl.GraphUtil
, EditForm
, IconFontsImageList //uses IconFontsImageList - download free at: https://github.com/EtheaDev/IconFontsImageList
, SVGIconImageList //uses SVGIconImageList - download free at: https://github.com/EtheaDev/SVGIconImageList
, IconFontsUtils
, FVCLThemeSelector
, SVGIconImageListBase
, IconFontsImageListBase
, SVGIconVirtualImageList
, IconFontsVirtualImageList
, DImageCollections
, SVGIconImage
, IconFontsImage
{$IFDEF VCLSTYLEUTILS}
//VCLStyles support:
//to compile you need to donwload VCLStyleUtils+DDetours from:
//https://github.com/RRUZ/vcl-styles-utils
//https://github.com/MahdiSafsafi/DDetours
, Vcl.PlatformVclStylesActnCtrls
, Vcl.Styles.ColorTabs
, Vcl.Styles.ControlColor
, Vcl.Styles.DbGrid
, Vcl.Styles.DPIAware
, Vcl.Styles.Fixes
, Vcl.Styles.Ext
, Vcl.Styles.FontAwesome
, Vcl.Styles.FormStyleHooks
, Vcl.Styles.NC
, Vcl.Styles.OwnerDrawFix
, Vcl.Styles.Utils.ScreenTips
, Vcl.Styles.Utils.SysStyleHook
, Vcl.Styles.WebBrowser
, Vcl.Styles.Utils
, Vcl.Styles.Utils.Menus
, Vcl.Styles.Utils.Misc
, Vcl.Styles.Utils.SystemMenu
, Vcl.Styles.Utils.Graphics
, Vcl.Styles.Utils.SysControls
, Vcl.Styles.UxTheme
, Vcl.Styles.Hooks
, Vcl.Styles.Utils.Forms
, Vcl.Styles.Utils.ComCtrls
, Vcl.Styles.Utils.StdCtrls
{$ENDIF}
{$IFDEF D10_2+}
, Vcl.WinXPickers
{$ENDIF}
;
const
COMPANY_NAME = 'Ethea';
type
TFormMain = class(TForm)
panlTop: TPanel;
SV: TSplitView;
catMenuItems: TCategoryButtons;
catSettings: TCategoryButtons;
catMenuSettings: TCategoryButtons;
catPanelSettings: TCategoryButtons;
IconFontsImageList: TIconFontsVirtualImageList;
ActionList: TActionList;
actHome: TAction;
actChangeTheme: TAction;
actShowChildForm: TAction;
actMenu: TAction;
lblTitle: TLabel;
splSplit: TSplitter;
svSettings: TSplitView;
IconFontsImageListColored: TIconFontsVirtualImageList;
splSettings: TSplitter;
actSettings: TAction;
actViewOptions: TAction;
pnlSettings: TPanel;
pcSettings: TPageControl;
tsStyle: TTabSheet;
grpDisplayMode: TRadioGroup;
grpCloseStyle: TRadioGroup;
grpPlacement: TRadioGroup;
tsAnimation: TTabSheet;
tsLog: TTabSheet;
lstLog: TListBox;
actBack: TAction;
actAnimate: TAction;
actLog: TAction;
PageControl: TPageControl;
tsDatabase: TTabSheet;
ClientDataSet: TClientDataSet;
DBNavigator: TDBNavigator;
DbGrid: TDBGrid;
tsWindows10: TTabSheet;
CalendarView: TCalendarView;
CalendarPicker: TCalendarPicker;
tsStandard: TTabSheet;
Edit: TEdit;
HomeButton: TButton;
LogButton: TButton;
CheckListBox: TCheckListBox;
RichEdit: TRichEdit;
SpinEdit: TSpinEdit;
ComboBox: TComboBox;
ListBox: TListBox;
Memo: TMemo;
ColorBox: TColorBox;
MaskEdit: TMaskEdit;
RadioButton: TRadioButton;
RadioGroup: TRadioGroup;
DBRichEdit: TDBRichEdit;
Label1: TLabel;
MenuButtonToolbar: TToolBar;
ToolButton1: TToolButton;
ToolBar: TToolBar;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
DateTimePicker: TDateTimePicker;
ClientDataSetSpeciesNo: TFloatField;
ClientDataSetCategory: TStringField;
ClientDataSetCommon_Name: TStringField;
ClientDataSetSpeciesName: TStringField;
ClientDataSetLengthcm: TFloatField;
ClientDataSetLength_In: TFloatField;
ClientDataSetNotes: TMemoField;
ClientDataSetGraphic: TGraphicField;
DataSource: TDataSource;
tsFont: TTabSheet;
Label2: TLabel;
FontTrackBar: TTrackBar;
acFont: TAction;
FontComboBox: TComboBox;
FontSizeLabel: TLabel;
acApplyFont: TAction;
SaveFontButton: TButton;
tsIconFonts: TTabSheet;
Label3: TLabel;
IconFontsSizeLabel: TLabel;
IconFontsTrackBar: TTrackBar;
acIconFonts: TAction;
paEdit: TPanel;
Label4: TLabel;
DBEdit1: TDBEdit;
Label5: TLabel;
DBEdit2: TDBEdit;
Label6: TLabel;
DBEdit3: TDBEdit;
Label7: TLabel;
DBEdit4: TDBEdit;
Label8: TLabel;
DBEdit5: TDBEdit;
Label9: TLabel;
DBEdit6: TDBEdit;
Label10: TLabel;
DBMemo1: TDBMemo;
Label11: TLabel;
DBImage: TDBImage;
FileOpenDialog: TFileOpenDialog;
ButtonEdit: TSearchBox;
ButtonEditDate: TSearchBox;
acErrorMessage: TAction;
acWarningMessage: TAction;
acInfoMessage: TAction;
acConfirmMessage: TAction;
acAbout: TAction;
SVGIconImageList: TSVGIconVirtualImageList;
IconsToggleSwitch: TToggleSwitch;
tswAnimation: TToggleSwitch;
lblAnimationDelay: TLabel;
trkAnimationDelay: TTrackBar;
lblAnimationStep: TLabel;
trkAnimationStep: TTrackBar;
tsvDisplayMode: TToggleSwitch;
ttsCloseStyle: TToggleSwitch;
ttsCloseSplitView: TToggleSwitch;
acExit: TAction;
SVGIconImage: TSVGIconImage;
IconFontImage: TIconFontImage;
IconFontImageLabel: TLabel;
SVGIconImageLabel: TLabel;
procedure FormCreate(Sender: TObject);
procedure grpDisplayModeClick(Sender: TObject);
procedure grpPlacementClick(Sender: TObject);
procedure grpCloseStyleClick(Sender: TObject);
procedure SVClosed(Sender: TObject);
procedure SVOpened(Sender: TObject);
procedure SVOpening(Sender: TObject);
procedure trkAnimationDelayChange(Sender: TObject);
procedure trkAnimationStepChange(Sender: TObject);
procedure actHomeExecute(Sender: TObject);
procedure actChangeThemeExecute(Sender: TObject);
procedure actShowChildFormExecute(Sender: TObject);
procedure actMenuExecute(Sender: TObject);
procedure CatPreventCollapase(Sender: TObject;
const Category: TButtonCategory);
procedure SVResize(Sender: TObject);
procedure actSettingsExecute(Sender: TObject);
procedure svSettingsClosed(Sender: TObject);
procedure svSettingsOpened(Sender: TObject);
procedure SVClosing(Sender: TObject);
procedure tswAnimationClick(Sender: TObject);
procedure actBackExecute(Sender: TObject);
procedure actViewOptionsExecute(Sender: TObject);
procedure actAnimateExecute(Sender: TObject);
procedure actLogExecute(Sender: TObject);
procedure svSettingsClosing(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure tsvDisplayModeClick(Sender: TObject);
procedure ttsCloseStyleClick(Sender: TObject);
procedure FontTrackBarChange(Sender: TObject);
procedure acFontExecute(Sender: TObject);
procedure FormAfterMonitorDpiChanged(Sender: TObject; OldDPI, NewDPI: Integer);
procedure FontComboBoxSelect(Sender: TObject);
procedure IconFontsTrackBarChange(Sender: TObject);
procedure acIconFontsExecute(Sender: TObject);
procedure acApplyFontExecute(Sender: TObject);
procedure acApplyFontUpdate(Sender: TObject);
procedure DBImageDblClick(Sender: TObject);
procedure ClientDataSetAfterPost(DataSet: TDataSet);
procedure PageControlChange(Sender: TObject);
procedure IconFontsImageListFontMissing(const AFontName: TFontName);
procedure acMessageExecute(Sender: TObject);
procedure acAboutExecute(Sender: TObject);
procedure IconsToggleSwitchClick(Sender: TObject);
procedure ActionListUpdate(Action: TBasicAction; var Handled: Boolean);
procedure acExitExecute(Sender: TObject);
procedure IconImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormBeforeMonitorDpiChanged(Sender: TObject; OldDPI,
NewDPI: Integer);
private
FActiveFont: TFont;
FActiveStyleName: string;
{$IFDEF D10_2+}
TimePicker: TTimePicker;
DatePicker: TDatePicker;
{$ENDIF}
{$IFNDEF D10_3+}
FScaleFactor: Single;
{$ENDIF}
procedure UpdateButtons;
procedure CreateAndFixFontComponents;
procedure Log(const Msg: string);
procedure AfterMenuClick;
procedure ShowSettingPage(TabSheet: TTabSheet; AutoOpen: Boolean = False);
procedure FontTrackBarUpdate;
procedure IconFontsTrackBarUpdate;
procedure SetActiveStyleName(const Value: string);
procedure AdjustCatSettings;
procedure UpdateDefaultAndSystemFonts;
{$IFNDEF D10_4+}
procedure FixSplitViewResize(ASplitView: TSplitView; const OldDPI, NewDPI: Integer);
{$ENDIF}
procedure UpdateIconsByType;
protected
procedure Loaded; override;
{$IFNDEF D10_3+}
procedure ChangeScale(M, D: Integer); override;
{$ENDIF}
public
procedure ScaleForPPI(NewPPI: Integer); override;
destructor Destroy; override;
property ActiveStyleName: string read FActiveStyleName write SetActiveStyleName;
end;
var
FormMain: TFormMain;
implementation
uses
Vcl.Themes
, System.UITypes;
{$R *.dfm}
procedure ApplyStyleElements(ARootControl: TControl;
AStyleElements: TStyleElements);
var
I: Integer;
LControl: TControl;
begin
ARootControl.StyleElements := AStyleElements;
if ARootControl is TWinControl then
For I := 0 to TWinControl(ARootControl).ControlCount -1 do
begin
LControl := TWinControl(ARootControl).Controls[I];
ApplyStyleElements(TWinControl(LControl), AStyleElements);
end;
ARootControl.Invalidate;
end;
{ TFormMain }
procedure TFormMain.IconFontsImageListFontMissing(const AFontName: TFontName);
var
LFontFileName: string;
begin
inherited;
//The "material design web-font is not installed into system: load and install now from disk
LFontFileName := ExtractFilePath(Application.ExeName)+'..\Fonts\Material Design Icons Desktop.ttf';
if FileExists(LFontFileName) then
begin
{$IFNDEF D2010+}
AddFontResource(PChar(LFontFileName));
{$ELSE}
AddFontResource(PWideChar(LFontFileName));
{$ENDIF}
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
end
else
begin
//If the font file is not available
MessageDlg(Format('Warning: "%s" font is not present in your system!'+sLineBreak+
'Please download from https://github.com/Templarian/MaterialDesign-Font and install it, because this demo is based on this font!',
[AFontName]), mtError, [mbOK], 0);
end;
end;
procedure TFormMain.FontTrackBarUpdate;
begin
FontSizeLabel.Caption := IntToStr(FontTrackBar.Position);
end;
procedure TFormMain.FormShow(Sender: TObject);
begin
FontTrackBarUpdate;
IconFontsTrackBarUpdate;
UpdateButtons;
end;
procedure TFormMain.CreateAndFixFontComponents;
begin
CalendarView.ParentFont := True;
CalendarView.HeaderInfo.Font.Assign(Font);
CalendarView.HeaderInfo.Font.Height := Round(CalendarView.HeaderInfo.Font.Height*1.2);
CalendarView.HeaderInfo.DaysOfWeekFont.Assign(Font);
CalendarPicker.ParentFont := True;
{$IFDEF D10_2+}
TimePicker := TTimePicker.Create(Self);
TimePicker.Left := 3;
TimePicker.Top := 367;
TimePicker.Parent := tsWindows10;
TimePicker.Font.Assign(Font);
DatePicker := TDatePicker.Create(Self);
DatePicker.Left := 2;
DatePicker.Top := 423;
DatePicker.Parent := tsWindows10;
DatePicker.Font.Assign(Font);
{$ENDIF}
end;
procedure TFormMain.FontComboBoxSelect(Sender: TObject);
begin
Font.Name := FontComboBox.Text;
UpdateDefaultAndSystemFonts;
end;
procedure TFormMain.FontTrackBarChange(Sender: TObject);
begin
//ScaleFactor is available only from Delphi 10.3, FScaleFactor is calculated
Font.Height := MulDiv(-FontTrackBar.Position,
Round(100*{$IFDEF D10_3+}ScaleFactor{$ELSE}FScaleFactor{$ENDIF}), 100);
FontTrackBarUpdate;
UpdateDefaultAndSystemFonts;
end;
procedure TFormMain.IconFontsTrackBarChange(Sender: TObject);
begin
IconFontsImageList.Size := IconFontsTrackBar.Position;
IconFontsImageListColored.Size := IconFontsTrackBar.Position;
SVGIconImageList.Size := IconFontsTrackBar.Position;
IconFontsTrackBarUpdate;
end;
procedure TFormMain.IconFontsTrackBarUpdate;
var
LContainerSize: Integer;
procedure UpdateCategoryButtonSize(ACatButton: TCategoryButtons);
begin
ACatButton.ButtonHeight := LContainerSize;
ACatButton.ButtonWidth := LContainerSize;
end;
begin
IconFontsTrackBar.Position := IconFontsImageList.Size;
IconFontsSizeLabel.Caption := IntToStr(IconFontsTrackBar.Position);
LContainerSize := IconFontsTrackBar.Position + 10;
panlTop.Height := LContainerSize + 10;
SV.Top := panlTop.Top+panlTop.Height;
svSettings.Top := SV.Top;
ToolBar.ButtonHeight := LContainerSize;
MenuButtonToolbar.ButtonHeight := LContainerSize;
UpdateCategoryButtonSize(catMenuItems);
UpdateCategoryButtonSize(catMenuSettings);
UpdateCategoryButtonSize(catSettings);
UpdateCategoryButtonSize(catPanelSettings);
end;
procedure TFormMain.IconImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
LIndex: Integer;
begin
LIndex := IconFontImage.ImageIndex;
if (Button = mbRight) and (Shift = [ssRight]) then
begin
if IconFontImage.ImageIndex = 0 then
LIndex := IconFontsImageList.Count -1
else
Dec(LIndex);
end
else if (Button = mbLeft) and (Shift = [ssLeft]) then
begin
if IconFontImage.ImageIndex = IconFontsImageList.Count -1 then
LIndex := 0
else
Inc(LIndex);
end;
IconFontImage.ImageIndex := LIndex;
SVGIconImage.ImageIndex := LIndex;
end;
procedure TFormMain.IconsToggleSwitchClick(Sender: TObject);
begin
if IconsToggleSwitch.State = tssOn then
ImageCollectionDataModule.IconsType := itSVGIcons
else
ImageCollectionDataModule.IconsType := itIconFonts;
UpdateIconsByType;
end;
{$IFNDEF D10_4+}
procedure TFormMain.FixSplitViewResize(ASplitView: TSplitView;
const OldDPI, NewDPI: Integer);
begin
ASplitView.CompactWidth := MulDiv(ASplitView.CompactWidth, NewDPI, OldDPI);
ASplitView.OpenedWidth := MulDiv(ASplitView.OpenedWidth, NewDPI, OldDPI);
end;
{$ENDIF}
procedure TFormMain.FormAfterMonitorDpiChanged(Sender: TObject; OldDPI,
NewDPI: Integer);
begin
LockWindowUpdate(0);
{$IFNDEF D10_3}
IconFontsImageList.DPIChanged(Self, OldDPI, NewDPI);
IconFontsImageListColored.DPIChanged(Self, OldDPI, NewDPI);
{$ENDIF}
FontTrackBarUpdate;
IconFontsTrackBarUpdate;
{$IFNDEF D10_4+}
AdjustCatSettings;
//Fix for SplitViews
FixSplitViewResize(SV, OldDPI, NewDPI);
FixSplitViewResize(svSettings, OldDPI, NewDPI);
{$ENDIF}
UpdateDefaultAndSystemFonts;
end;
procedure TFormMain.FormBeforeMonitorDpiChanged(Sender: TObject; OldDPI,
NewDPI: Integer);
begin
LockWindowUpdate(Handle);
end;
procedure TFormMain.FormCreate(Sender: TObject);
var
I: Integer;
begin
Caption := Application.Title;
//Hide Tabs
for I := 0 to pcSettings.PageCount-1 do
pcSettings.Pages[I].TabVisible := False;
{$IFDEF D10_4+}
//Assign Windows10 Style to Settings Menu
svSettings.StyleName := 'Windows10';
{$ELSE}
//Disable any StyleElements of Settings Menu only for Windows10 Style
if FActiveStyleName = 'Windows10' then
ApplyStyleElements(svSettings, [seFont]);
{$ENDIF}
//Assign Fonts to Combobox
FontComboBox.Items.Assign(Screen.Fonts);
FontComboBox.ItemIndex := FontComboBox.Items.IndexOf(Font.Name);
//Title label
lblTitle.Caption := Application.Title;
lblTitle.Font.Color := clHighlightText;
lblTitle.Font.Height := lblTitle.Font.Height - 4;
lblTitle.Font.Style := lblTitle.Font.Style + [fsBold];
//Assign file for ClientDataSet
{$IFDEF D10_2+}
ClientDataSet.FileName := ExtractFilePath(Application.ExeName)+'..\Data\biolife_png.xml';
{$ELSE}
//Delphi 10.1 cannot load png blob field automatically
ClientDataSet.FileName := ExtractFilePath(Application.ExeName)+'..\Data\biolife.xml';
{$ENDIF}
end;
procedure TFormMain.CatPreventCollapase(Sender: TObject;
const Category: TButtonCategory);
begin
// Prevent the catMenuButton Category group from being collapsed
(Sender as TCategoryButtons).Categories[0].Collapsed := False;
end;
{$IFNDEF D10_3+}
procedure TFormMain.ChangeScale(M, D: Integer);
begin
inherited;
FScaleFactor := FScaleFactor * M / D;
IconFontsImageList.DPIChanged(Self, M, D);
IconFontsImageListColored.DPIChanged(Self, M, D);
end;
{$ENDIF}
procedure TFormMain.ScaleForPPI(NewPPI: Integer);
begin
inherited;
{$IFNDEF D10_3+}
FScaleFactor := NewPPI / PixelsPerInch;
IconFontsImageList.DPIChanged(Self, Self.PixelsPerInch, NewPPI);
IconFontsImageListColored.DPIChanged(Self, Self.PixelsPerInch, NewPPI);
{$ENDIF}
{$IFNDEF D10_4+}
FixSplitViewResize(SV, Self.PixelsPerInch, NewPPI);
FixSplitViewResize(svSettings, Self.PixelsPerInch, NewPPI);
{$ENDIF}
end;
procedure TFormMain.ClientDataSetAfterPost(DataSet: TDataSet);
begin
//Save content to File
ClientDataSet.SaveToFile(ClientDataSet.FileName, dfXMLUTF8);
end;
procedure TFormMain.DBImageDblClick(Sender: TObject);
begin
ClientDataSet.Edit;
FileOpenDialog.DefaultFolder := ExtractFilePath(ClientDataSet.FileName);
if FileOpenDialog.Execute then
begin
ClientDataSetGraphic.LoadFromFile(FileOpenDialog.FileName);
end;
end;
destructor TFormMain.Destroy;
begin
inherited;
FActiveFont.Free;
end;
procedure TFormMain.grpDisplayModeClick(Sender: TObject);
begin
SV.DisplayMode := TSplitViewDisplayMode(grpDisplayMode.ItemIndex);
end;
procedure TFormMain.grpCloseStyleClick(Sender: TObject);
begin
SV.CloseStyle := TSplitViewCloseStyle(grpCloseStyle.ItemIndex);
end;
procedure TFormMain.grpPlacementClick(Sender: TObject);
begin
SV.Placement := TSplitViewPlacement(grpPlacement.ItemIndex);
end;
procedure TFormMain.SetActiveStyleName(const Value: string);
var
I: Integer;
LFontColor, LColoredColor: TColor;
LMaskColor: TColor;
begin
if Value <> '' then
begin
try
TStyleManager.SetStyle(Value);
except
WriteAppStyleToReg(COMPANY_NAME, ExtractFileName(Application.ExeName), 'Windows');
end;
WriteAppStyleToReg(COMPANY_NAME, ExtractFileName(Application.ExeName), Value);
FActiveStyleName := Value;
if FActiveStyleName = 'Windows' then
begin
catMenuItems.Color := clHighlight;
catMenuItems.Font.Color := clHighlightText;
for I := 0 to catMenuItems.Categories.Count -1 do
catMenuItems.Categories[I].Color := clNone;
DBImage.Color := clAqua;
//Default non-style "Windows": use White icons over Highlight Color
LFontColor := clWhite;
LColoredColor := clBlack;
LMaskColor := clHighlight;
end
else
begin
if FActiveStyleName = 'Windows10' then
begin
//For "Windows10" style: use "Windows 10 blue" color for the icons
LFontColor := RGB(0, 120, 215);
LColoredColor := LFontColor;
LMaskColor := clBtnFace;
end
else
begin
//Request color from Style
LFontColor := TStyleManager.ActiveStyle.GetStyleFontColor(sfButtonTextNormal);
LMaskColor := TStyleManager.ActiveStyle.GetStyleFontColor(sfButtonTextDisabled);
LColoredColor := clBlack;
end;
catMenuItems.Font.Color := IconFontsImageList.FontColor;
//Color for Bitmap Background
DBImage.Color := TStyleManager.ActiveStyle.GetStyleColor(scGenericBackground);
end;
//Update IconFonts Colors
IconFontsImageList.UpdateIconsAttributes(LFontColor, LMaskColor, True);
IconFontsImageListColored.UpdateIconsAttributes(LColoredColor, LMaskColor, False);
IconFontImage.FontColor := LColoredColor;
IconFontImage.MaskColor := LMaskColor;
catMenuItems.BackgroundGradientDirection := gdVertical;
catMenuItems.RegularButtonColor := clNone;
catMenuItems.SelectedButtonColor := clNone;
end;
end;
procedure TFormMain.UpdateIconsByType;
begin
case ImageCollectionDataModule.IconsType of
itIconFonts:
begin
MenuButtonToolbar.Images := IconFontsImageList;
ToolBar.Images := IconFontsImageList;
catMenuItems.Images := IconFontsImageList;
catSettings.Images := IconFontsImageList;
catMenuSettings.Images := IconFontsImageListColored; //Colored icons
ActionList.Images := IconFontsImageList;
end;
itSVGIcons:
begin
MenuButtonToolbar.Images := SVGIconImageList;
ToolBar.Images := SVGIconImageList;
catMenuItems.Images := SVGIconImageList;
catSettings.Images := SVGIconImageList;
catMenuSettings.Images := SVGIconImageList;
ActionList.Images := SVGIconImageList;
end;
end;
UpdateButtons;
end;
procedure TFormMain.ShowSettingPage(TabSheet: TTabSheet;
AutoOpen: Boolean = False);
begin
if Assigned(TabSheet) then
begin
pcSettings.ActivePage := TabSheet;
pnlSettings.Visible := True;
catMenuSettings.Visible := False;
actBack.Caption := Tabsheet.Caption;
if AutoOpen then
svSettings.Open;
end
else
begin
pnlSettings.Visible := False;
catMenuSettings.Visible := True;
actBack.Caption := 'Back';
end;
end;
procedure TFormMain.SVClosed(Sender: TObject);
begin
// When TSplitView is closed, adjust ButtonOptions and Width
catMenuItems.ButtonOptions := catMenuItems.ButtonOptions - [boShowCaptions];
actMenu.Hint := 'Expand';
splSplit.Visible := False;
end;
procedure TFormMain.SVClosing(Sender: TObject);
begin
SV.OpenedWidth := SV.Width;
end;
procedure TFormMain.SVOpened(Sender: TObject);
begin
// When not animating, change size of catMenuItems when TSplitView is opened
catMenuItems.ButtonOptions := catMenuItems.ButtonOptions + [boShowCaptions];
actMenu.Hint := 'Collapse';
splSplit.Visible := True;
splSplit.Left := SV.Left + SV.Width;
end;
procedure TFormMain.SVOpening(Sender: TObject);
begin
// When animating, change size of catMenuItems at the beginning of open
catMenuItems.ButtonOptions := catMenuItems.ButtonOptions + [boShowCaptions];
end;
procedure TFormMain.AdjustCatSettings;
var
LButtonWidth, LNumButtons, LButtonsFit: Integer;
LCaptionOffset: Integer;
begin
catSettings.Realign;
LButtonWidth := catSettings.ButtonWidth;
LNumButtons := catSettings.Categories[0].Items.Count;
LButtonsFit := (SV.Width) div (LButtonWidth+2);
LCaptionOffset := Round(-Font.Height+14);
if (LButtonsFit <> 0) and (LButtonsFit < LNumButtons) then
catSettings.Height := (((LNumButtons div LButtonsFit)+1) * catSettings.ButtonHeight) + LCaptionOffset
else
begin
catSettings.Height := catSettings.ButtonHeight + LCaptionOffset;
end;
end;
procedure TFormMain.SVResize(Sender: TObject);
begin
AdjustCatSettings;
end;
procedure TFormMain.svSettingsClosed(Sender: TObject);
begin
splSettings.Visible := False;
ShowSettingPage(nil);
end;
procedure TFormMain.svSettingsClosing(Sender: TObject);
begin
if svSettings.Width <> 0 then
svSettings.OpenedWidth := svSettings.Width;
end;
procedure TFormMain.svSettingsOpened(Sender: TObject);
begin
splSettings.Visible := True;
splSettings.Left := svSettings.Left -1;
end;
procedure TFormMain.trkAnimationDelayChange(Sender: TObject);
begin
SV.AnimationDelay := trkAnimationDelay.Position * 5;
lblAnimationDelay.Caption := Format('Animation Delay (%d)', [SV.AnimationDelay]);
end;
procedure TFormMain.trkAnimationStepChange(Sender: TObject);
begin
SV.AnimationStep := trkAnimationStep.Position * 5;
lblAnimationStep.Caption := Format('Animation Step (%d)', [SV.AnimationStep]);
end;
procedure TFormMain.ttsCloseStyleClick(Sender: TObject);
begin
if ttsCloseStyle.State = tssOff then
SV.CloseStyle := svcCompact
else
SV.CloseStyle := svcCollapse;
end;
procedure TFormMain.tsvDisplayModeClick(Sender: TObject);
begin
if tsvDisplayMode.State = tssOff then
SV.DisplayMode := svmDocked
else
SV.DisplayMode := svmOverlay;
end;
procedure TFormMain.tswAnimationClick(Sender: TObject);
begin
SV.UseAnimation := tswAnimation.State = tssOn;
lblAnimationDelay.Enabled := SV.UseAnimation;
trkAnimationDelay.Enabled := SV.UseAnimation;
lblAnimationStep.Enabled := SV.UseAnimation;
trkAnimationStep.Enabled := SV.UseAnimation;
end;
procedure TFormMain.acAboutExecute(Sender: TObject);
begin
TaskMessageDlg('About this Application',
Application.Title, mtInformation, [mbOK], 2000);
end;
procedure TFormMain.acApplyFontExecute(Sender: TObject);
begin
FActiveFont.Name := FontComboBox.Text;
FActiveFont.Height := -FontTrackBar.Position;
WriteAppStyleAndFontToReg(COMPANY_NAME, ExtractFileName(Application.ExeName),
FActiveStyleName, FActiveFont);
//Update Child Forms
if Assigned(FmEdit) then
FmEdit.Font.Assign(Font);
UpdateDefaultAndSystemFonts;
AfterMenuClick;
end;
procedure TFormMain.acApplyFontUpdate(Sender: TObject);
begin
acApplyFont.Enabled := (FActiveFont.Name <> FontComboBox.Text) or
(FActiveFont.Height <> FontTrackBar.Position);
end;
procedure TFormMain.acExitExecute(Sender: TObject);
begin
Close;
end;
procedure TFormMain.acMessageExecute(Sender: TObject);
begin
if Sender = acErrorMessage then
MessageDlg('Error Message...', mtError, [mbOK, mbHelp], 1000)
else if Sender = acWarningMessage then
MessageDlg('Warning Message...', mtWarning, [mbOK, mbHelp], 1000)
else if Sender = acInfoMessage then
MessageDlg('Information Message...', mtInformation, [mbOK, mbHelp], 1000)
else if Sender = acConfirmMessage then
MessageDlg('Do you want to confirm?', mtConfirmation, [mbYes, mbNo, mbHelp], 1000);
Log((Sender as TAction).Caption + ' Clicked');
end;
procedure TFormMain.acFontExecute(Sender: TObject);
begin
ShowSettingPage(tsFont);
end;
procedure TFormMain.acIconFontsExecute(Sender: TObject);
begin
ShowSettingPage(tsIconFonts);
end;
procedure TFormMain.actAnimateExecute(Sender: TObject);
begin
ShowSettingPage(tsAnimation);
end;
procedure TFormMain.actBackExecute(Sender: TObject);
begin
ShowSettingPage(nil);
end;
procedure TFormMain.actHomeExecute(Sender: TObject);
begin
PageControl.ActivePageIndex := 0;
Log(actHome.Caption + ' Clicked');
AfterMenuClick;
end;
procedure TFormMain.ActionListUpdate(Action: TBasicAction;
var Handled: Boolean);
begin
actHome.Enabled := not svSettings.Opened;
end;
procedure TFormMain.actChangeThemeExecute(Sender: TObject);
begin
//Show Theme selector
if ShowVCLThemeSelector(FActiveStyleName,
False, 3, 4) then
ActiveStyleName := FActiveStyleName;
end;
procedure TFormMain.actLogExecute(Sender: TObject);
begin
if not svSettings.Opened then
svSettings.Open;
ShowSettingPage(tsLog);
end;
procedure TFormMain.actMenuExecute(Sender: TObject);
begin
if SV.Opened then
SV.Close
else
SV.Open;
end;
procedure TFormMain.actShowChildFormExecute(Sender: TObject);
begin
if not Assigned(FmEdit) then
FmEdit := TFmEdit.Create(Self);
FmEdit.Show;
Log(actShowChildForm.Caption + ' Clicked');
AfterMenuClick;
end;
procedure TFormMain.actSettingsExecute(Sender: TObject);
begin
if svSettings.Opened then
svSettings.Close
else
svSettings.Open;
end;
procedure TFormMain.actViewOptionsExecute(Sender: TObject);
begin
ShowSettingPage(tsStyle);
end;
procedure TFormMain.AfterMenuClick;
begin
if SV.Opened and (ttsCloseSplitView.State = tssOn) then
SV.Close;
if svSettings.Opened and (ttsCloseSplitView.State = tssOn) then
svSettings.Close;
end;
procedure TFormMain.UpdateButtons;
begin
//Buttons with Actions must be reassigned to refresh Icon
HomeButton.Images := ActionList.Images;
LogButton.Images := ActionList.Images;
SaveFontButton.Images := ActionList.Images;
//HomeButton.Action := actHome;
//LogButton.Action := actLog;
//SaveFontButton.Action := acApplyFont;
end;
procedure TFormMain.UpdateDefaultAndSystemFonts;
var
LHeight: Integer;
begin
//Update Application.DefaultFont for Childforms with ParentFont = True
Application.DefaultFont.Assign(Font);
//Update system fonts as user preferences
LHeight := Muldiv(Font.Height, Screen.PixelsPerInch, Monitor.PixelsPerInch);
Screen.IconFont.Name := Font.Name;
Screen.IconFont.Height := LHeight;
Screen.MenuFont.Name := Font.Name;
Screen.MenuFont.Height := LHeight;
Screen.MessageFont.Name := Font.Name;
Screen.MessageFont.Height := LHeight;
Screen.HintFont.Name := Font.Name;
Screen.HintFont.Height := LHeight;
Screen.CaptionFont.Name := Font.Name;
Screen.CaptionFont.Height := LHeight;
catMenuItems.Font.Assign(Font);
end;
procedure TFormMain.Loaded;
var
LFontHeight: Integer;
begin
{$IFNDEF D10_3+}
FScaleFactor := 1;
{$ENDIF}
FActiveFont := TFont.Create;
//Acquire system font and size (eg. for windows 10 Segoe UI and 14 at 96 DPI)
//but without using Assign!
Font.Name := Screen.IconFont.Name;
//If you want to use system font Height:
Font.Height := Muldiv(Screen.IconFont.Height, 96, Screen.IconFont.PixelsPerInch);
//Check for Font stored into Registry (user preferences)
ReadAppStyleAndFontFromReg(COMPANY_NAME,
ExtractFileName(Application.ExeName), FActiveStyleName, FActiveFont);
LFontHeight := FActiveFont.Height;
Font.Assign(FActiveFont);
//Create and Fix components for ParentFont
CreateAndFixFontComponents;
inherited;
//Update Trackbar position with Width loaded before resize of Font
FontTrackBar.Position := - LFontHeight;
//For ParentFont on Child Forms
UpdateDefaultAndSystemFonts;
//GUI default
ActiveStyleName := FActiveStyleName;
svSettings.Opened := False;
PageControl.ActivePageIndex := 0;
end;
procedure TFormMain.Log(const Msg: string);
var
Idx: Integer;
begin
Idx := lstLog.Items.Add(Msg);
lstLog.TopIndex := Idx;
ShowSettingPage(tsLog, True);
end;
procedure TFormMain.PageControlChange(Sender: TObject);
begin
if (PageControl.ActivePage = tsDatabase) then
begin
if not ClientDataSet.Active then
begin
Screen.Cursor := crHourGlass;
try
ClientDataSet.Open;
ClientDataSet.LogChanges := False;
finally
Screen.Cursor := crDefault;
end;
end;
end;
end;
end.
| 30.891125 | 137 | 0.700124 |
f1ff23438bd80e416fecda2a277c3e2f92950b3a | 1,915 | dfm | Pascal | transformer/FHIR.Transformer.ExecConfig.dfm | 17-years-old/fhirserver | 9575a7358868619311a5d1169edde3ffe261e558 | [
"BSD-3-Clause"
]
| null | null | null | transformer/FHIR.Transformer.ExecConfig.dfm | 17-years-old/fhirserver | 9575a7358868619311a5d1169edde3ffe261e558 | [
"BSD-3-Clause"
]
| null | null | null | transformer/FHIR.Transformer.ExecConfig.dfm | 17-years-old/fhirserver | 9575a7358868619311a5d1169edde3ffe261e558 | [
"BSD-3-Clause"
]
| null | null | null | object TransformerExecConfigForm: TTransformerExecConfigForm
Left = 0
Top = 0
Caption = 'Edit Execution Configuration'
ClientHeight = 347
ClientWidth = 704
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnDestroy = FormDestroy
OnShow = FormShow
DesignSize = (
704
347)
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 16
Top = 24
Width = 53
Height = 13
Caption = 'Javascript:'
end
object Label2: TLabel
Left = 16
Top = 51
Width = 67
Height = 13
Caption = 'Focus Object:'
end
object Panel1: TPanel
Left = 0
Top = 307
Width = 704
Height = 40
Align = alBottom
TabOrder = 0
ExplicitTop = 259
ExplicitWidth = 635
DesignSize = (
704
40)
object btnok: TButton
Left = 540
Top = 8
Width = 75
Height = 25
Anchors = [akTop, akRight]
Caption = 'OK'
Default = True
ModalResult = 1
TabOrder = 0
OnClick = btnokClick
ExplicitLeft = 471
end
object btnCancel: TButton
Left = 621
Top = 8
Width = 75
Height = 25
Anchors = [akTop, akRight]
Cancel = True
Caption = 'Cancel'
ModalResult = 2
TabOrder = 1
ExplicitLeft = 552
end
end
object cbxScripts: TComboBox
Left = 96
Top = 21
Width = 577
Height = 21
Style = csDropDownList
Anchors = [akLeft, akTop, akRight]
TabOrder = 1
ExplicitWidth = 601
end
object cbxFocus: TComboBox
Left = 96
Top = 48
Width = 577
Height = 21
Style = csDropDownList
Anchors = [akLeft, akTop, akRight]
TabOrder = 2
ExplicitWidth = 601
end
end
| 20.37234 | 61 | 0.564491 |
fcc1899b680814bfd1846d0450bb75777ddda8b8 | 117 | pas | Pascal | Test/SimpleScripts/loop_and_half.pas | synapsea/DW-Script | b36c2e57f0285c217f8f0cae8e4e158d21127163 | [
"Condor-1.1"
]
| 1 | 2022-02-18T22:14:44.000Z | 2022-02-18T22:14:44.000Z | Test/SimpleScripts/loop_and_half.pas | synapsea/DW-Script | b36c2e57f0285c217f8f0cae8e4e158d21127163 | [
"Condor-1.1"
]
| null | null | null | Test/SimpleScripts/loop_and_half.pas | synapsea/DW-Script | b36c2e57f0285c217f8f0cae8e4e158d21127163 | [
"Condor-1.1"
]
| null | null | null | var i : Integer;
for i := 1 to 10 do begin
Print(i);
if i < 10 then
Print(', ');
end;
PrintLn(' Done.'); | 14.625 | 25 | 0.521368 |
fcc972cc12d61547222f5424ff2e1f3047a18b77 | 47,472 | pas | Pascal | windows/src/ext/jedi/jcl/jcl/source/windows/JclSvcCtrl.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| 1 | 2021-03-08T09:31:47.000Z | 2021-03-08T09:31:47.000Z | windows/src/ext/jedi/jcl/jcl/source/windows/JclSvcCtrl.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| null | null | null | windows/src/ext/jedi/jcl/jcl/source/windows/JclSvcCtrl.pas | bravogeorge/keyman | c0797e36292de903d7313214d1f765e3d9a2bf4d | [
"MIT"
]
| null | null | null | {**************************************************************************************************}
{ }
{ Project JEDI Code Library (JCL) }
{ }
{ 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 JclSvcCtrl.pas. }
{ }
{ The Initial Developer of the Original Code is Flier Lu (<flier_lu att yahoo dott com dott cn>). }
{ Portions created by Flier Lu are Copyright (C) Flier Lu. All Rights Reserved. }
{ }
{ Contributors: }
{ Flier Lu (flier) }
{ Matthias Thoma (mthoma) }
{ Olivier Sannier (obones) }
{ Petr Vones (pvones) }
{ Rik Barker (rikbarker) }
{ Robert Rossmair (rrossmair) }
{ Warren Postma }
{ Terry Yapt }
{ }
{**************************************************************************************************}
{ }
{ This unit contains routines and classes to control NT service }
{ }
{**************************************************************************************************}
{ }
{ Last modified: $Date:: $ }
{ Revision: $Rev:: $ }
{ Author: $Author:: $ }
{ }
{**************************************************************************************************}
unit JclSvcCtrl;
{$I jcl.inc}
{$I windowsonly.inc}
interface
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
{$IFDEF HAS_UNITSCOPE}
Winapi.Windows, System.Classes, System.SysUtils, System.Contnrs,
{$ELSE ~HAS_UNITSCOPE}
Windows, Classes, SysUtils, Contnrs,
{$ENDIF ~HAS_UNITSCOPE}
{$IFDEF FPC}
JwaWinNT, JwaWinSvc,
{$ELSE ~FPC}
{$IFDEF HAS_UNITSCOPE}
Winapi.WinSvc,
{$ELSE ~HAS_UNITSCOPE}
WinSvc,
{$ENDIF ~HAS_UNITSCOPE}
{$ENDIF ~FPC}
JclBase, JclSysUtils;
// Service Types
type
TJclServiceType =
(stKernelDriver, // SERVICE_KERNEL_DRIVER
stFileSystemDriver, // SERVICE_FILE_SYSTEM_DRIVER
stAdapter, // SERVICE_ADAPTER
stRecognizerDriver, // SERVICE_RECOGNIZER_DRIVER
stWin32OwnProcess, // SERVICE_WIN32_OWN_PROCESS
stWin32ShareProcess, // SERVICE_WIN32_SHARE_PROCESS
stInteractiveProcess); // SERVICE_INTERACTIVE_PROCESS
TJclServiceTypes = set of TJclServiceType;
const
stDriverService = [stKernelDriver, stFileSystemDriver, stRecognizerDriver];
stWin32Service = [stWin32OwnProcess, stWin32ShareProcess];
stAllTypeService = stDriverService + stWin32Service + [stAdapter, stInteractiveProcess];
// Service State
type
TJclServiceState =
(ssUnknown, // Just fill the value 0
ssStopped, // SERVICE_STOPPED
ssStartPending, // SERVICE_START_PENDING
ssStopPending, // SERVICE_STOP_PENDING
ssRunning, // SERVICE_RUNNING
ssContinuePending, // SERVICE_CONTINUE_PENDING
ssPausePending, // SERVICE_PAUSE_PENDING
ssPaused); // SERVICE_PAUSED
TJclServiceStates = set of TJclServiceState;
const
ssPendingStates = [ssStartPending, ssStopPending, ssContinuePending, ssPausePending];
// Start Type
type
TJclServiceStartType =
(sstBoot, // SERVICE_BOOT_START
sstSystem, // SERVICE_SYSTEM_START
sstAuto, // SERVICE_AUTO_START
sstDemand, // SERVICE_DEMAND_START
sstDisabled); // SERVICE_DISABLED
// Error control type
type
TJclServiceErrorControlType =
(ectIgnore, // SSERVICE_ERROR_IGNORE
ectNormal, // SSERVICE_ERROR_NORMAL
ectSevere, // SSERVICE_ERROR_SEVERE
ectCritical); // SERVICE_ERROR_CRITICAL
// Controls Accepted
type
TJclServiceControlAccepted =
(caStop, // SERVICE_ACCEPT_STOP
caPauseContinue, // SERVICE_ACCEPT_PAUSE_CONTINUE
caShutdown); // SERVICE_ACCEPT_SHUTDOWN
TJclServiceControlAccepteds = set of TJclServiceControlAccepted;
// Service sort type
type
TJclServiceSortOrderType =
(sotServiceName,
sotDisplayName,
sotDescription,
sotFileName,
sotServiceState,
sotStartType,
sotErrorControlType,
sotLoadOrderGroup,
sotWin32ExitCode);
const
// Everyone in WinNT/2K or Authenticated users in WinXP
EveryoneSCMDesiredAccess =
SC_MANAGER_CONNECT or
SC_MANAGER_ENUMERATE_SERVICE or
SC_MANAGER_QUERY_LOCK_STATUS or
STANDARD_RIGHTS_READ;
LocalSystemSCMDesiredAccess =
SC_MANAGER_CONNECT or
SC_MANAGER_ENUMERATE_SERVICE or
SC_MANAGER_MODIFY_BOOT_CONFIG or
SC_MANAGER_QUERY_LOCK_STATUS or
STANDARD_RIGHTS_READ;
AdministratorsSCMDesiredAccess = SC_MANAGER_ALL_ACCESS;
DefaultSCMDesiredAccess = EveryoneSCMDesiredAccess;
DefaultSvcDesiredAccess = SERVICE_ALL_ACCESS;
// Service description
const
SERVICE_CONFIG_DESCRIPTION = 1;
{$EXTERNALSYM SERVICE_CONFIG_DESCRIPTION}
SERVICE_CONFIG_FAILURE_ACTIONS = 2;
{$EXTERNALSYM SERVICE_CONFIG_FAILURE_ACTIONS}
{$IFNDEF FPC}
type
LPSERVICE_DESCRIPTIONA = ^SERVICE_DESCRIPTIONA;
{$EXTERNALSYM LPSERVICE_DESCRIPTIONA}
SERVICE_DESCRIPTIONA = record
lpDescription: LPSTR;
end;
{$EXTERNALSYM SERVICE_DESCRIPTIONA}
TServiceDescriptionA = SERVICE_DESCRIPTIONA;
PServiceDescriptionA = LPSERVICE_DESCRIPTIONA;
{$ENDIF ~FPC}
type
TQueryServiceConfig2A = function(hService: SC_HANDLE; dwInfoLevel: DWORD;
lpBuffer: PByte; cbBufSize: DWORD; var pcbBytesNeeded: DWORD): BOOL; stdcall;
// Service related classes
type
TJclServiceGroup = class;
TJclSCManager = class;
TJclNtService = class(TObject)
private
FSCManager: TJclSCManager;
FHandle: SC_HANDLE;
FDesiredAccess: DWORD;
FServiceName: string;
FDisplayName: string;
FDescription: string;
FFileName: TFileName;
FServiceStartName: string;
FPassword: string;
FDependentServices: TList;
FDependentGroups: TList;
FDependentByServices: TList;
FServiceTypes: TJclServiceTypes;
FServiceState: TJclServiceState;
FStartType: TJclServiceStartType;
FErrorControlType: TJclServiceErrorControlType;
FWin32ExitCode: DWORD;
FGroup: TJclServiceGroup;
FControlsAccepted: TJclServiceControlAccepteds;
FCommitNeeded:Boolean;
function GetActive: Boolean;
procedure SetActive(const Value: Boolean);
procedure SetServiceStartName(const Value: string);
procedure SetPassword(const Value: string);
function GetDependentService(const Idx: Integer): TJclNtService;
function GetDependentServiceCount: Integer;
function GetDependentGroup(const Idx: Integer): TJclServiceGroup;
function GetDependentGroupCount: Integer;
function GetDependentByService(const Idx: Integer): TJclNtService;
function GetDependentByServiceCount: Integer;
protected
procedure Open(const ADesiredAccess: DWORD = DefaultSvcDesiredAccess);
procedure Close;
function GetServiceStatus: TServiceStatus;
procedure UpdateDescription;
procedure UpdateDependents;
procedure UpdateStatus(const SvcStatus: TServiceStatus);
procedure UpdateConfig(const SvcConfig: TQueryServiceConfig);
procedure CommitConfig(var SvcConfig: TQueryServiceConfig);
procedure SetStartType(AStartType: TJclServiceStartType);
public
constructor Create(const ASCManager: TJclSCManager; const SvcStatus: TEnumServiceStatus);
destructor Destroy; override;
procedure Refresh;
procedure Commit;
procedure Delete;
function Controls(const ControlType: DWORD; const ADesiredAccess: DWORD = DefaultSvcDesiredAccess): TServiceStatus;
procedure Start(const Args: array of string; const Sync: Boolean = True); overload;
procedure Start(const Sync: Boolean = True); overload;
procedure Stop(const Sync: Boolean = True);
procedure Pause(const Sync: Boolean = True);
procedure Continue(const Sync: Boolean = True);
function WaitFor(const State: TJclServiceState; const TimeOut: DWORD = INFINITE): Boolean;
property SCManager: TJclSCManager read FSCManager;
property Active: Boolean read GetActive write SetActive;
property Handle: SC_HANDLE read FHandle;
property ServiceName: string read FServiceName;
property DisplayName: string read FDisplayName;
property DesiredAccess: DWORD read FDesiredAccess;
property Description: string read FDescription; // Win2K or later
property FileName: TFileName read FFileName;
property ServiceStartName: string read FServiceStartName write SetServiceStartName;
property Password: string read FPassword write SetPassword; // Write-Only!
property DependentServices[const Idx: Integer]: TJclNtService read GetDependentService;
property DependentServiceCount: Integer read GetDependentServiceCount;
property DependentGroups[const Idx: Integer]: TJclServiceGroup read GetDependentGroup;
property DependentGroupCount: Integer read GetDependentGroupCount;
property DependentByServices[const Idx: Integer]: TJclNtService read GetDependentByService;
property DependentByServiceCount: Integer read GetDependentByServiceCount;
property ServiceTypes: TJclServiceTypes read FServiceTypes;
property ServiceState: TJclServiceState read FServiceState;
property StartType: TJclServiceStartType read FStartType write SetStartType;
property ErrorControlType: TJclServiceErrorControlType read FErrorControlType;
property Win32ExitCode: DWORD read FWin32ExitCode;
property Group: TJclServiceGroup read FGroup;
property ControlsAccepted: TJclServiceControlAccepteds read FControlsAccepted;
end;
TJclServiceGroup = class(TObject)
private
FSCManager: TJclSCManager;
FName: string;
FOrder: Integer;
FServices: TList;
function GetService(const Idx: Integer): TJclNtService;
function GetServiceCount: Integer;
protected
function Add(const AService: TJclNtService): Integer;
function Remove(const AService: TJclNtService): Integer;
public
constructor Create(const ASCManager: TJclSCManager; const AName: string; const AOrder: Integer);
destructor Destroy; override;
property SCManager: TJclSCManager read FSCManager;
property Name: string read FName;
property Order: Integer read FOrder;
property Services[const Idx: Integer]: TJclNtService read GetService;
property ServiceCount: Integer read GetServiceCount;
end;
TJclSCManager = class(TObject)
private
FMachineName: string;
FDatabaseName: string;
FDesiredAccess: DWORD;
FHandle: SC_HANDLE;
FLock: SC_LOCK;
FServices: TObjectList;
FGroups: TObjectList;
FAdvApi32Handle: TModuleHandle;
FQueryServiceConfig2A: TQueryServiceConfig2A;
function GetActive: Boolean;
procedure SetActive(const Value: Boolean);
function GetService(const Idx: Integer): TJclNtService;
function GetServiceCount: Integer;
function GetGroup(const Idx: Integer): TJclServiceGroup;
function GetGroupCount: Integer;
procedure SetOrderAsc(const Value: Boolean);
procedure SetOrderType(const Value: TJclServiceSortOrderType);
function GetAdvApi32Handle: TModuleHandle;
function GetQueryServiceConfig2A: TQueryServiceConfig2A;
protected
FOrderType: TJclServiceSortOrderType;
FOrderAsc: Boolean;
procedure Open;
procedure Close;
function AddService(const AService: TJclNtService): Integer;
function AddGroup(const AGroup: TJclServiceGroup): Integer;
function GetServiceLockStatus: PQueryServiceLockStatus;
property AdvApi32Handle: TModuleHandle read GetAdvApi32Handle;
property QueryServiceConfig2A: TQueryServiceConfig2A read GetQueryServiceConfig2A;
public
constructor Create(const AMachineName: string = '';
const ADesiredAccess: DWORD = DefaultSCMDesiredAccess;
const ADatabaseName: string = SERVICES_ACTIVE_DATABASE);
destructor Destroy; override;
procedure Clear;
procedure Refresh(const RefreshAll: Boolean = False);
function Install(const ServiceName, DisplayName, ImageName: string;
const Description: string = '';
ServiceTypes: TJclServiceTypes = [stWin32OwnProcess];
StartType: TJclServiceStartType = sstDemand;
ErrorControlType: TJclServiceErrorControlType = ectNormal;
DesiredAccess: DWORD = DefaultSvcDesiredAccess;
const LoadOrderGroup: TJclServiceGroup = nil; const Dependencies: PChar = nil;
const Account: PChar = nil; const Password: PChar = nil): TJclNtService;
procedure Sort(const AOrderType: TJclServiceSortOrderType; const AOrderAsc: Boolean = True);
function FindService(const SvcName: string; out NtSvc: TJclNtService): Boolean;
function FindGroup(const GrpName: string; out SvcGrp: TJclServiceGroup;
const AutoAdd: Boolean = True): Boolean;
procedure Lock;
procedure Unlock;
function IsLocked: Boolean;
function LockOwner: string;
function LockDuration: DWORD;
class function ServiceType(const SvcType: TJclServiceTypes): DWORD; overload;
class function ServiceType(const SvcType: DWORD): TJclServiceTypes; overload;
class function ControlAccepted(const CtrlAccepted: TJclServiceControlAccepteds): DWORD; overload;
class function ControlAccepted(const CtrlAccepted: DWORD): TJclServiceControlAccepteds; overload;
property MachineName: string read FMachineName;
property DatabaseName: string read FDatabaseName;
property DesiredAccess: DWORD read FDesiredAccess;
property Active: Boolean read GetActive write SetActive;
property Handle: SC_HANDLE read FHandle;
property Services[const Idx: Integer]: TJclNtService read GetService;
property ServiceCount: Integer read GetServiceCount;
property Groups[const Idx: Integer]: TJclServiceGroup read GetGroup;
property GroupCount: Integer read GetGroupCount;
property OrderType: TJclServiceSortOrderType read FOrderType write SetOrderType;
property OrderAsc: Boolean read FOrderAsc write SetOrderAsc;
end;
// helper functions
function GetServiceStatus(ServiceHandle: SC_HANDLE): DWORD;
function GetServiceStatusWaitingIfPending(ServiceHandle: SC_HANDLE): DWORD;
function GetServiceStatusByName(const AServer,AServiceName:string):TJclServiceState;
function StopServiceByName(const AServer, AServiceName: String):Boolean;
function StartServiceByName(const AServer,AServiceName: String):Boolean;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL$';
Revision: '$Revision$';
Date: '$Date$';
LogPath: 'JCL\source\windows';
Extra: '';
Data: nil
);
{$ENDIF UNITVERSIONING}
implementation
uses
{$IFDEF FPC}
JwaRegStr,
{$ELSE ~FPC}
{$IFDEF HAS_UNITSCOPE}
Winapi.RegStr,
System.Types, // inlining of TList.Remove
{$ELSE ~HAS_UNITSCOPE}
RegStr,
{$ENDIF ~HAS_UNITSCOPE}
{$ENDIF ~FPC}
{$IFDEF HAS_UNITSCOPE}
System.Math,
{$ELSE ~HAS_UNITSCOPE}
Math,
{$ENDIF ~HAS_UNITSCOPE}
JclRegistry, JclStrings, JclSysInfo;
const
INVALID_SCM_HANDLE = 0;
ServiceTypeMapping: array [TJclServiceType] of DWORD =
(SERVICE_KERNEL_DRIVER, SERVICE_FILE_SYSTEM_DRIVER, SERVICE_ADAPTER,
SERVICE_RECOGNIZER_DRIVER, SERVICE_WIN32_OWN_PROCESS,
SERVICE_WIN32_SHARE_PROCESS, SERVICE_INTERACTIVE_PROCESS);
ServiceControlAcceptedMapping: array [TJclServiceControlAccepted] of DWORD =
(SERVICE_ACCEPT_STOP, SERVICE_ACCEPT_PAUSE_CONTINUE, SERVICE_ACCEPT_SHUTDOWN);
//=== { TJclNtService } ======================================================
constructor TJclNtService.Create(const ASCManager: TJclSCManager; const SvcStatus: TEnumServiceStatus);
begin
Assert(Assigned(ASCManager));
inherited Create;
FSCManager := ASCManager;
FHandle := INVALID_SCM_HANDLE;
FServiceName := SvcStatus.lpServiceName;
FDisplayName := SvcStatus.lpDisplayName;
FDescription := '';
FGroup := nil;
FDependentServices := TList.Create;
FDependentGroups := TList.Create;
FDependentByServices := nil; // Create on demand
FSCManager.AddService(Self);
end;
destructor TJclNtService.Destroy;
begin
FreeAndNil(FDependentServices);
FreeAndNil(FDependentGroups);
FreeAndNil(FDependentByServices);
inherited Destroy;
end;
procedure TJclNtService.UpdateDescription;
var
Ret: BOOL;
BytesNeeded: DWORD;
PSvcDesc: PServiceDescriptionA;
begin
if Assigned(SCManager.QueryServiceConfig2A) then
try
PSvcDesc := nil;
BytesNeeded := 4096;
repeat
ReallocMem(PSvcDesc, BytesNeeded);
Ret := SCManager.QueryServiceConfig2A(FHandle, SERVICE_CONFIG_DESCRIPTION,
PByte(PSvcDesc), BytesNeeded, BytesNeeded);
until Ret or (GetLastError <> ERROR_INSUFFICIENT_BUFFER);
Win32Check(Ret);
FDescription := string(PSvcDesc.lpDescription);
finally
FreeMem(PSvcDesc);
end;
end;
function TJclNtService.GetActive: Boolean;
begin
Result := FHandle <> INVALID_SCM_HANDLE;
end;
procedure TJclNtService.SetActive(const Value: Boolean);
begin
if Value <> GetActive then
begin
if Value then
Open
else
Close;
Assert(Value = GetActive);
end;
end;
procedure TJclNtService.SetStartType(AStartType: TJclServiceStartType);
begin
if AStartType <> FStartType then
begin
FStartType := AStartType;
FCommitNeeded := True;
end;
end;
procedure TJclNtService.SetServiceStartName(const Value: string);
begin
if Value <> FServiceStartName then
begin
FServiceStartName := Value;
FCommitNeeded := True;
end;
end;
procedure TJclNtService.SetPassword(const Value: string);
begin
if Value <> FPassword then
begin
FPassword := Value;
FCommitNeeded := True;
end;
end;
procedure TJclNtService.UpdateDependents;
var
I: Integer;
Ret: BOOL;
PBuf: Pointer;
PEss: PEnumServiceStatus;
NtSvc: TJclNtService;
BytesNeeded, ServicesReturned: DWORD;
begin
Open(SERVICE_ENUMERATE_DEPENDENTS);
try
if Assigned(FDependentByServices) then
FDependentByServices.Clear
else
FDependentByServices := TList.Create;
try
PBuf := nil;
BytesNeeded := 40960;
repeat
ReallocMem(PBuf, BytesNeeded);
ServicesReturned := 0;
Ret := EnumDependentServices(FHandle, SERVICE_STATE_ALL,
PEnumServiceStatus(PBuf){$IFNDEF FPC}^{$ENDIF}, BytesNeeded, BytesNeeded, ServicesReturned);
until Ret or (GetLastError <> ERROR_INSUFFICIENT_BUFFER);
Win32Check(Ret);
PEss := PBuf;
if ServicesReturned > 0 then
for I := 0 to ServicesReturned - 1 do
begin
if (PEss.lpServiceName[1] <> SC_GROUP_IDENTIFIER) and
(SCManager.FindService(PEss.lpServiceName, NtSvc)) then
FDependentByServices.Add(NtSvc);
Inc(PEss);
end;
finally
FreeMem(PBuf);
end;
finally
Close;
end;
end;
function TJclNtService.GetDependentService(const Idx: Integer): TJclNtService;
begin
Result := TJclNtService(FDependentServices.Items[Idx]);
end;
function TJclNtService.GetDependentServiceCount: Integer;
begin
Result := FDependentServices.Count;
end;
function TJclNtService.GetDependentGroup(const Idx: Integer): TJclServiceGroup;
begin
Result := TJclServiceGroup(FDependentGroups.Items[Idx]);
end;
function TJclNtService.GetDependentGroupCount: Integer;
begin
Result := FDependentGroups.Count;
end;
function TJclNtService.GetDependentByService(const Idx: Integer): TJclNtService;
begin
if not Assigned(FDependentByServices) then
UpdateDependents;
Result := TJclNtService(FDependentByServices.Items[Idx])
end;
function TJclNtService.GetDependentByServiceCount: Integer;
begin
if not Assigned(FDependentByServices) then
UpdateDependents;
Result := FDependentByServices.Count;
end;
function TJclNtService.GetServiceStatus: TServiceStatus;
begin
Assert(Active);
Assert((DesiredAccess and SERVICE_QUERY_STATUS) <> 0);
Win32Check(QueryServiceStatus(FHandle, Result));
end;
procedure TJclNtService.UpdateStatus(const SvcStatus: TServiceStatus);
begin
with SvcStatus do
begin
FServiceTypes := TJclSCManager.ServiceType(dwServiceType);
FServiceState := TJclServiceState(dwCurrentState);
FControlsAccepted := TJclSCManager.ControlAccepted(dwControlsAccepted);
FWin32ExitCode := dwWin32ExitCode;
end;
end;
procedure TJclNtService.UpdateConfig(const SvcConfig: TQueryServiceConfig);
procedure UpdateLoadOrderGroup;
begin
if not Assigned(FGroup) then
SCManager.FindGroup(SvcConfig.lpLoadOrderGroup, FGroup)
else
if CompareText(Group.Name, SvcConfig.lpLoadOrderGroup) = 0 then
begin
FGroup.Remove(Self);
SCManager.FindGroup(SvcConfig.lpLoadOrderGroup, FGroup);
FGroup.Add(Self);
end;
end;
procedure UpdateDependencies;
var
P: PChar;
NtSvc: TJclNtService;
SvcGrp: TJclServiceGroup;
begin
P := SvcConfig.lpDependencies;
FDependentServices.Clear;
FDependentGroups.Clear;
if Assigned(P) then
while P^ <> #0 do
begin
if P^ = SC_GROUP_IDENTIFIER then
begin
SCManager.FindGroup(P + 1, SvcGrp);
FDependentGroups.Add(SvcGrp);
end
else
if SCManager.FindService(P, NtSvc) then
FDependentServices.Add(NtSvc);
Inc(P, StrLen(P) + 1);
end;
end;
begin
with SvcConfig do
begin
FFileName := lpBinaryPathName;
FStartType := TJclServiceStartType(dwStartType);
FServiceStartName := lpServiceStartName;
FPassword := ''; // Write-Only!
FErrorControlType := TJclServiceErrorControlType(dwErrorControl);
UpdateLoadOrderGroup;
UpdateDependencies;
end;
end;
procedure TJclNtService.CommitConfig(var SvcConfig: TQueryServiceConfig);
begin
with SvcConfig do
begin
StrCopy(lpBinaryPathName, PChar(FileName));
dwStartType := Ord(StartType); {TJclServiceStartType}
dwErrorControl := Ord(ErrorControlType); {TJclServiceErrorControlType}
//UpdateLoadOrderGroup;
//UpdateDependencies;
end;
end;
procedure TJclNtService.Open(const ADesiredAccess: DWORD);
begin
Assert((ADesiredAccess and (not SERVICE_ALL_ACCESS)) = 0);
Active := False;
FDesiredAccess := ADesiredAccess;
FHandle := OpenService(SCManager.Handle, PChar(ServiceName), DesiredAccess);
Win32Check(FHandle <> INVALID_SCM_HANDLE);
end;
procedure TJclNtService.Close;
begin
Assert(Active);
Win32Check(CloseServiceHandle(FHandle));
FHandle := INVALID_SCM_HANDLE;
end;
procedure TJclNtService.Refresh;
var
Ret: BOOL;
BytesNeeded: DWORD;
PQrySvcCnfg: {$IFDEF RTL230_UP}LPQUERY_SERVICE_CONFIG{$ELSE}PQueryServiceConfig{$ENDIF RTL230_UP};
begin
Open(SERVICE_QUERY_STATUS or SERVICE_QUERY_CONFIG);
try
UpdateDescription;
UpdateStatus(GetServiceStatus);
try
PQrySvcCnfg := nil;
BytesNeeded := 4096;
repeat
ReallocMem(PQrySvcCnfg, BytesNeeded);
Ret := QueryServiceConfig(FHandle, PQrySvcCnfg, BytesNeeded, BytesNeeded);
until Ret or (GetLastError <> ERROR_INSUFFICIENT_BUFFER);
Win32Check(Ret);
UpdateConfig(PQrySvcCnfg^);
finally
FreeMem(PQrySvcCnfg);
end;
finally
Close;
end;
end;
// Commit is reverse of Refresh.
procedure TJclNtService.Commit;
var
Ret: BOOL;
BytesNeeded: DWORD;
PQrySvcCnfg: {$IFDEF RTL230_UP}LPQUERY_SERVICE_CONFIG{$ELSE}PQueryServiceConfig{$ENDIF RTL230_UP};
ServiceStartNamePtr: PChar;
PasswordPtr: PChar;
begin
if not FCommitNeeded then
Exit;
FCommitNeeded := False;
Open(SERVICE_CHANGE_CONFIG or SERVICE_QUERY_STATUS or SERVICE_QUERY_CONFIG);
try
//UpdateDescription;
//UpdateStatus(GetServiceStatus);
try
PQrySvcCnfg := nil;
BytesNeeded := 4096;
repeat
ReallocMem(PQrySvcCnfg, BytesNeeded);
Ret := QueryServiceConfig(FHandle, PQrySvcCnfg, BytesNeeded, BytesNeeded);
until Ret or (GetLastError <> ERROR_INSUFFICIENT_BUFFER);
Win32Check(Ret);
CommitConfig(PQrySvcCnfg^);
// If the ServiceStartName was set/changed then into ChangeServiceConfig
if (FServiceStartName <> '')
and (FServiceStartName <> PQrySvcCnfg^.lpServiceStartName) then
ServiceStartNamePtr := PChar(FServiceStartName)
else
ServiceStartNamePtr := nil;
// If a Password was set then pass it into ChangeServiceConfig
if (FServiceStartName <> '') and (FPassword <> '') then
PasswordPtr := PChar(FPassword)
else
PasswordPtr := nil;
Win32Check(ChangeServiceConfig(Handle,
PQrySvcCnfg^.dwServiceType,
PQrySvcCnfg^.dwStartType,
PQrySvcCnfg^.dwErrorControl,
nil, {PQrySvcCnfg^.lpBinaryPathName,}
nil, {PQrySvcCnfg^.lpLoadOrderGroup,}
nil, {PQrySvcCnfg^.dwTagId,}
nil, {PQrySvcCnfg^.lpDependencies,}
ServiceStartNamePtr,
PasswordPtr,
PQrySvcCnfg^.lpDisplayName));
finally
FreeMem(PQrySvcCnfg);
end;
finally
Close;
end;
end;
procedure TJclNtService.Delete;
{$IFDEF FPC}
const
_DELETE = $00010000; { Renamed from DELETE }
{$ENDIF FPC}
begin
Open(_DELETE);
try
Win32Check(DeleteService(FHandle));
finally
Close;
end;
end;
procedure TJclNtService.Start(const Args: array of string; const Sync: Boolean);
type
PStrArray = ^TStrArray;
TStrArray = array [0..32767] of PChar;
var
I: Integer;
PServiceArgVectors: PChar;
begin
Open(SERVICE_START);
try
try
if Length(Args) = 0 then
PServiceArgVectors := nil
else
begin
GetMem(PServiceArgVectors, SizeOf(PChar)*Length(Args));
for I := 0 to Length(Args) - 1 do
PStrArray(PServiceArgVectors)^[I] := PChar(Args[I]);
end;
Win32Check(StartService(FHandle, Length(Args), PServiceArgVectors));
finally
FreeMem(PServiceArgVectors);
end;
finally
Close;
end;
if Sync then
WaitFor(ssRunning);
end;
procedure TJclNtService.Start(const Sync: Boolean = True);
begin
Start([], Sync);
end;
function TJclNtService.Controls(const ControlType: DWORD; const ADesiredAccess: DWORD): TServiceStatus;
begin
Open(ADesiredAccess);
try
Win32Check(ControlService(FHandle, ControlType, Result));
finally
Close;
end;
end;
procedure TJclNtService.Stop(const Sync: Boolean);
begin
Controls(SERVICE_CONTROL_STOP, SERVICE_STOP);
if Sync then
WaitFor(ssStopped);
end;
procedure TJclNtService.Pause(const Sync: Boolean);
begin
Controls(SERVICE_CONTROL_PAUSE, SERVICE_PAUSE_CONTINUE);
if Sync then
WaitFor(ssPaused);
end;
procedure TJclNtService.Continue(const Sync: Boolean);
begin
Controls(SERVICE_CONTROL_CONTINUE, SERVICE_PAUSE_CONTINUE);
if Sync then
WaitFor(ssRunning);
end;
function TJclNtService.WaitFor(const State: TJclServiceState; const TimeOut: DWORD): Boolean;
var
SvcStatus: TServiceStatus;
WaitedState, StartTickCount, OldCheckPoint, WaitTime: DWORD;
begin
WaitedState := DWORD(State);
Open(SERVICE_QUERY_STATUS);
try
StartTickCount := GetTickCount;
OldCheckPoint := 0;
while True do
begin
SvcStatus := GetServiceStatus;
if SvcStatus.dwCurrentState = WaitedState then
Break;
if SvcStatus.dwCheckPoint > OldCheckPoint then
begin
StartTickCount := GetTickCount;
OldCheckPoint := SvcStatus.dwCheckPoint;
end
else
begin
if TimeOut <> INFINITE then
{ TODO : Do we need to disable RangeCheck? }
if (GetTickCount - StartTickCount) > Max(SvcStatus.dwWaitHint, TimeOut) then
Break;
end;
WaitTime := SvcStatus.dwWaitHint div 10;
if WaitTime < 1000 then
WaitTime := 1000
else
if WaitTime > 10000 then
WaitTime := 10000;
Sleep(WaitTime);
end;
Result := SvcStatus.dwCurrentState = WaitedState;
finally
Close;
end;
end;
//=== { TJclServiceGroup } ===================================================
constructor TJclServiceGroup.Create(const ASCManager: TJclSCManager;
const AName: string; const AOrder: Integer);
begin
Assert(Assigned(ASCManager));
inherited Create;
FSCManager := ASCManager;
FName := AName;
if FName <> '' then
FOrder := AOrder
else
FOrder := MaxInt;
FServices := TList.Create;
end;
destructor TJclServiceGroup.Destroy;
begin
FreeAndNil(FServices);
inherited Destroy;
end;
function TJclServiceGroup.Add(const AService: TJclNtService): Integer;
begin
Result := FServices.Add(AService);
end;
function TJclServiceGroup.Remove(const AService: TJclNtService): Integer;
begin
Result := FServices.Remove(AService);
end;
function TJclServiceGroup.GetService(const Idx: Integer): TJclNtService;
begin
Result := TJclNtService(FServices.Items[Idx]);
end;
function TJclServiceGroup.GetServiceCount: Integer;
begin
Result := FServices.Count;
end;
//=== { TJclSCManager } ======================================================
constructor TJclSCManager.Create(const AMachineName: string;
const ADesiredAccess: DWORD; const ADatabaseName: string);
begin
Assert((ADesiredAccess and (not SC_MANAGER_ALL_ACCESS)) = 0);
inherited Create;
FMachineName := AMachineName;
FDatabaseName := ADatabaseName;
FDesiredAccess := ADesiredAccess;
FHandle := INVALID_SCM_HANDLE;
FServices := TObjectList.Create;
FGroups := TObjectList.Create;
FOrderType := sotServiceName;
FOrderAsc := True;
FAdvApi32Handle := INVALID_MODULEHANDLE_VALUE;
FQueryServiceConfig2A := nil;
end;
destructor TJclSCManager.Destroy;
begin
FreeAndNil(FGroups);
FreeAndNil(FServices);
Close;
UnloadModule(FAdvApi32Handle);
inherited Destroy;
end;
function TJclSCManager.AddService(const AService: TJclNtService): Integer;
begin
Result := FServices.Add(AService);
end;
function TJclSCManager.GetService(const Idx: Integer): TJclNtService;
begin
Result := TJclNtService(FServices.Items[Idx]);
end;
function TJclSCManager.GetServiceCount: Integer;
begin
Result := FServices.Count;
end;
function TJclSCManager.AddGroup(const AGroup: TJclServiceGroup): Integer;
begin
Result := FGroups.Add(AGroup);
end;
function TJclSCManager.GetGroup(const Idx: Integer): TJclServiceGroup;
begin
Result := TJclServiceGroup(FGroups.Items[Idx]);
end;
function TJclSCManager.GetGroupCount: Integer;
begin
Result := FGroups.Count;
end;
procedure TJclSCManager.SetOrderAsc(const Value: Boolean);
begin
if FOrderAsc <> Value then
Sort(OrderType, Value);
end;
procedure TJclSCManager.SetOrderType(const Value: TJclServiceSortOrderType);
begin
if FOrderType <> Value then
Sort(Value, FOrderAsc);
end;
function TJclSCManager.GetActive: Boolean;
begin
Result := FHandle <> INVALID_SCM_HANDLE;
end;
procedure TJclSCManager.SetActive(const Value: Boolean);
begin
if Value <> GetActive then
begin
if Value then
Open
else
Close;
Assert(Value = GetActive);
end;
end;
procedure TJclSCManager.Open;
begin
if not Active then
begin
FHandle := OpenSCManager(Pointer(FMachineName), Pointer(FDatabaseName), FDesiredAccess);
Win32Check(FHandle <> INVALID_SCM_HANDLE);
end;
end;
procedure TJclSCManager.Close;
begin
if Active then
Win32Check(CloseServiceHandle(FHandle));
FHandle := INVALID_SCM_HANDLE;
end;
procedure TJclSCManager.Lock;
begin
Assert((DesiredAccess and SC_MANAGER_LOCK) <> 0);
Active := True;
FLock := LockServiceDatabase(FHandle);
Win32Check(FLock <> nil);
end;
procedure TJclSCManager.Unlock;
begin
Assert(Active);
Assert((DesiredAccess and SC_MANAGER_LOCK) <> 0);
Assert(FLock <> nil);
Win32Check(UnlockServiceDatabase(FLock));
end;
procedure TJclSCManager.Clear;
begin
FServices.Clear;
FGroups.Clear;
end;
procedure TJclSCManager.Refresh(const RefreshAll: Boolean);
procedure EnumServices;
var
I: Integer;
Ret: BOOL;
PBuf: Pointer;
PEss: PEnumServiceStatus;
NtSvc: TJclNtService;
BytesNeeded, ServicesReturned, ResumeHandle: DWORD;
LastError: Cardinal;
begin
Assert((DesiredAccess and SC_MANAGER_ENUMERATE_SERVICE) <> 0);
// Enum the services
ResumeHandle := 0; // Must set this value to zero !!!
try
PBuf := nil;
BytesNeeded := 0;
//from MSDN:
//The maximum size of this array is 256K bytes. To determine the required
//size, specify NULL for this parameter and 0 for the cbBufSize parameter.
//The function will fail and GetLastError will return
//ERROR_INSUFFICIENT_BUFFER. The pcbBytesNeeded parameter will receive the
//required size.
//(it doesn't actually return ERROR_INSUFFICIENT_BUFFER apparently)
repeat
ReallocMem(PBuf, BytesNeeded);
ServicesReturned := 0;
Ret := EnumServicesStatus(FHandle, SERVICE_TYPE_ALL, SERVICE_STATE_ALL,
PEnumServiceStatus(PBuf){$IFNDEF FPC}^{$ENDIF},
BytesNeeded, BytesNeeded, ServicesReturned, ResumeHandle);
LastError := GetLastError;
if (ServicesReturned > 0) and (Ret or (LastError = ERROR_MORE_DATA)) then
begin
PEss := PBuf;
for I := 0 to ServicesReturned - 1 do
begin
NtSvc := TJclNtService.Create(Self, PEss^);
try
NtSvc.Refresh;
except
// trap invalid services
end;
Inc(PEss);
end;
end;
until Ret or (LastError <> ERROR_MORE_DATA);
Win32Check(Ret);
finally
FreeMem(PBuf);
end;
end;
{ TODO : Delete after Test }
{procedure EnumServiceGroups;
const
cKeyServiceGroupOrder = 'SYSTEM\CurrentControlSet\Control\ServiceGroupOrder';
cValList = 'List';
var
Buf: array of Char;
P: PChar;
DataSize: DWORD;
begin
// Get the service groups
DataSize := RegReadBinary(HKEY_LOCAL_MACHINE, cKeyServiceGroupOrder, cValList, PChar(nil)^, 0);
SetLength(Buf, DataSize);
if DataSize > 0 then
begin
DataSize := RegReadBinary(HKEY_LOCAL_MACHINE, cKeyServiceGroupOrder, cValList, Buf[0], DataSize);
P := @Buf[0];
while P^ <> #0 do
begin
AddGroup(TJclServiceGroup.Create(Self, P, GetGroupCount));
Inc(P, StrLen(P) + 1);
end;
end;
end;}
{ TODO -cTest : Test, if OK delete function above }
{ TODO -cHelp : }
procedure EnumServiceGroups;
const
cKeyServiceGroupOrder = 'SYSTEM\CurrentControlSet\Control\ServiceGroupOrder';
cValList = 'List';
var
List: TStringList;
I: Integer;
begin
// Get the service groups
List := TStringList.Create;
try
RegReadMultiSz(HKEY_LOCAL_MACHINE, cKeyServiceGroupOrder, cValList, List);
for I := 0 to List.Count - 1 do
AddGroup(TJclServiceGroup.Create(Self, List[I], GetGroupCount));
finally
List.Free;
end;
end;
procedure RefreshAllServices;
var
I: Integer;
begin
for I := 0 to GetServiceCount - 1 do
try
GetService(I).Refresh;
except
// trap invalid services
end;
end;
begin
Active := True;
if RefreshAll then
begin
Clear;
EnumServiceGroups;
EnumServices;
end;
RefreshAllServices;
end;
function ServiceSortFunc(Item1, Item2: Pointer): Integer;
var
Svc1, Svc2: TJclNtService;
begin
Svc1 := Item1;
Svc2 := Item2;
case Svc1.SCManager.FOrderType of
sotServiceName:
Result := AnsiCompareStr(Svc1.ServiceName, Svc2.ServiceName);
sotDisplayName:
Result := AnsiCompareStr(Svc1.DisplayName, Svc2.DisplayName);
sotDescription:
Result := AnsiCompareStr(Svc1.Description, Svc2.Description);
sotFileName:
Result := AnsiCompareStr(Svc1.FileName, Svc2.FileName);
sotServiceState:
Result := Integer(Svc1.ServiceState) - Integer(Svc2.ServiceState);
sotStartType:
Result := Integer(Svc1.StartType) - Integer(Svc2.StartType);
sotErrorControlType:
Result := Integer(Svc1.ErrorControlType) - Integer(Svc2.ErrorControlType);
sotLoadOrderGroup:
Result := Svc1.Group.Order - Svc2.Group.Order;
sotWin32ExitCode:
Result := Svc1.Win32ExitCode - Svc2.Win32ExitCode;
else
Result := 0;
end;
if not Svc1.SCManager.FOrderAsc then
Result := -Result;
end;
procedure TJclSCManager.Sort(const AOrderType: TJclServiceSortOrderType; const AOrderAsc: Boolean);
begin
FOrderType := AOrderType;
FOrderAsc := AOrderAsc;
FServices.Sort(ServiceSortFunc);
end;
function TJclSCManager.FindService(const SvcName: string; out NtSvc: TJclNtService): Boolean;
var
I: Integer;
begin
Result := False;
for I := 0 to GetServiceCount - 1 do
begin
NtSvc := GetService(I);
if CompareText(NtSvc.ServiceName, SvcName) = 0 then
begin
Result := True;
Exit;
end;
end;
NtSvc := nil;
end;
function TJclSCManager.FindGroup(const GrpName: string; out SvcGrp: TJclServiceGroup;
const AutoAdd: Boolean): Boolean;
var
I: Integer;
begin
Result := False;
for I := 0 to GetGroupCount - 1 do
begin
if CompareText(GetGroup(I).Name, GrpName) = 0 then
begin
SvcGrp := GetGroup(I);
Result := True;
Exit;
end;
end;
if AutoAdd then
begin
SvcGrp := TJclServiceGroup.Create(Self, GrpName, GetGroupCount);
AddGroup(SvcGrp);
end
else
SvcGrp := nil;
end;
function TJclSCManager.GetServiceLockStatus: PQueryServiceLockStatus;
var
Ret: BOOL;
BytesNeeded: DWORD;
begin
Assert((DesiredAccess and SC_MANAGER_QUERY_LOCK_STATUS) <> 0);
Active := True;
try
Result := nil;
BytesNeeded := 10240;
repeat
ReallocMem(Result, BytesNeeded);
Ret := QueryServiceLockStatus(FHandle, Result{$IFNDEF FPC}^{$ENDIF FPC}, BytesNeeded, BytesNeeded);
until Ret or (GetLastError <> ERROR_INSUFFICIENT_BUFFER);
Win32Check(Ret);
except
FreeMem(Result);
raise;
end;
end;
function TJclSCManager.IsLocked: Boolean;
var
PQsls: PQueryServiceLockStatus;
begin
PQsls := GetServiceLockStatus;
Result := Assigned(PQsls) and (PQsls.fIsLocked <> 0);
FreeMem(PQsls);
end;
function TJclSCManager.LockOwner: string;
var
PQsls: PQueryServiceLockStatus;
begin
PQsls := GetServiceLockStatus;
if Assigned(PQsls) then
Result := PQsls.lpLockOwner
else
Result := '';
FreeMem(PQsls);
end;
function TJclSCManager.LockDuration: DWORD;
var
PQsls: PQueryServiceLockStatus;
begin
PQsls := GetServiceLockStatus;
if Assigned(PQsls) then
Result := PQsls.dwLockDuration
else
Result := INFINITE;
FreeMem(PQsls);
end;
function TJclSCManager.GetAdvApi32Handle: TModuleHandle;
const
cAdvApi32 = 'advapi32.dll'; // don't localize
begin
if FAdvApi32Handle = INVALID_MODULEHANDLE_VALUE then
LoadModule(FAdvApi32Handle, cAdvApi32);
Result := FAdvApi32Handle;
end;
{ TODO : Standard Rtdl }
function TJclSCManager.GetQueryServiceConfig2A: TQueryServiceConfig2A;
const
cQueryServiceConfig2 = 'QueryServiceConfig2A'; // don't localize
begin
// Win2K or later
if (Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion >= 5) then
FQueryServiceConfig2A := GetModuleSymbol(AdvApi32Handle, cQueryServiceConfig2);
Result := FQueryServiceConfig2A;
end;
function TJclSCManager.Install(const ServiceName, DisplayName, ImageName, Description: string;
ServiceTypes: TJclServiceTypes; StartType: TJclServiceStartType;
ErrorControlType: TJclServiceErrorControlType; DesiredAccess: DWORD;
const LoadOrderGroup: TJclServiceGroup;
const Dependencies, Account, Password: PChar): TJclNtService;
var
LoadOrderGroupName: string;
LoadOrderGroupNamePtr: PChar;
EnumServiceStatus: TEnumServiceStatus;
Svc: THandle;
begin
if Assigned(LoadOrderGroup) then
begin
LoadOrderGroupName := LoadOrderGroup.Name;
LoadOrderGroupNamePtr := PChar(LoadOrderGroupName);
end
else
begin
LoadOrderGroupName := '';
LoadOrderGroupNamePtr := nil;
end;
Svc := CreateService(FHandle, PChar(ServiceName), PChar(DisplayName),
DesiredAccess, TJclSCManager.ServiceType(ServiceTypes), DWORD(StartType),
DWORD(ErrorControlType), PChar(ImageName), LoadOrderGroupNamePtr, nil,
Dependencies, Account, Password);
if Svc = 0 then
RaiseLastOsError;
CloseServiceHandle(Svc);
if (Description <> '') and JclCheckWinVersion(5, 0) then // Win2k or newer
RegWriteString(HKEY_LOCAL_MACHINE, '\' + REGSTR_PATH_SERVICES + '\' + ServiceName,
'Description', Description);
EnumServiceStatus.lpServiceName := PChar(ServiceName);
EnumServiceStatus.lpDisplayName := PChar(DisplayName);
Result := TJclNtService.Create(Self, EnumServiceStatus);
Result.Refresh;
end;
class function TJclSCManager.ServiceType(const SvcType: TJclServiceTypes): DWORD;
var
AType: TJclServiceType;
begin
Result := 0;
for AType := Low(TJclServiceType) to High(TJclServiceType) do
if AType in SvcType then
Result := Result or ServiceTypeMapping[AType];
end;
class function TJclSCManager.ServiceType(const SvcType: DWORD): TJclServiceTypes;
var
AType: TJclServiceType;
begin
Result := [];
for AType := Low(TJclServiceType) to High(TJclServiceType) do
if (SvcType and ServiceTypeMapping[AType]) <> 0 then
Include(Result, AType);
end;
class function TJclSCManager.ControlAccepted(const CtrlAccepted: TJclServiceControlAccepteds): DWORD;
var
ACtrl: TJclServiceControlAccepted;
begin
Result := 0;
for ACtrl := Low(TJclServiceControlAccepted) to High(TJclServiceControlAccepted) do
if ACtrl in CtrlAccepted then
Result := Result or ServiceControlAcceptedMapping[ACtrl];
end;
class function TJclSCManager.ControlAccepted(const CtrlAccepted: DWORD): TJclServiceControlAccepteds;
var
ACtrl: TJclServiceControlAccepted;
begin
Result := [];
for ACtrl := Low(TJclServiceControlAccepted) to High(TJclServiceControlAccepted) do
if (CtrlAccepted and ServiceControlAcceptedMapping[ACtrl]) <> 0 then
Include(Result, ACtrl);
end;
function GetServiceStatusByName(const AServer,AServiceName:string):TJclServiceState;
var
ServiceHandle,
SCMHandle: DWORD;
SCMAccess,Access:DWORD;
ServiceStatus: TServiceStatus;
begin
Result:=ssUnknown;
SCMAccess:=SC_MANAGER_CONNECT or SC_MANAGER_ENUMERATE_SERVICE or SC_MANAGER_QUERY_LOCK_STATUS;
Access:=SERVICE_INTERROGATE or GENERIC_READ;
SCMHandle:= OpenSCManager(PChar(AServer), Nil, SCMAccess);
if SCMHandle <> 0 then
try
ServiceHandle:=OpenService(SCMHandle,PChar(AServiceName),Access);
if ServiceHandle <> 0 then
try
ResetMemory(ServiceStatus, SizeOf(ServiceStatus));
if QueryServiceStatus(ServiceHandle,ServiceStatus) then
Result:=TJclServiceState(ServiceStatus.dwCurrentState);
finally
CloseServiceHandle(ServiceHandle);
end;
finally
CloseServiceHandle(SCMHandle);
end;
end;
function StartServiceByName(const AServer,AServiceName: String):Boolean;
var
ServiceHandle,
SCMHandle: DWORD;
p: PChar;
begin
p:=nil;
Result:=False;
SCMHandle:= OpenSCManager(PChar(AServer), nil, SC_MANAGER_ALL_ACCESS);
if SCMHandle <> 0 then
try
ServiceHandle:=OpenService(SCMHandle,PChar(AServiceName),SERVICE_ALL_ACCESS);
if ServiceHandle <> 0 then
Result:=StartService(ServiceHandle,0,p);
CloseServiceHandle(ServiceHandle);
finally
CloseServiceHandle(SCMHandle);
end;
end;
function StopServiceByName(const AServer, AServiceName: String):Boolean;
var
ServiceHandle,
SCMHandle: DWORD;
SS: _Service_Status;
begin
Result := False;
SCMHandle := OpenSCManager(PChar(AServer), nil, SC_MANAGER_ALL_ACCESS);
if SCMHandle <> 0 then
try
ServiceHandle := OpenService(SCMHandle, PChar(AServiceName), SERVICE_ALL_ACCESS);
if ServiceHandle <> 0 then
begin
ResetMemory(SS, SizeOf(SS));
Result := ControlService(ServiceHandle, SERVICE_CONTROL_STOP, SS);
end;
CloseServiceHandle(ServiceHandle);
finally
CloseServiceHandle(SCMHandle);
end;
end;
function GetServiceStatus(ServiceHandle: SC_HANDLE): DWORD;
var
ServiceStatus: TServiceStatus;
begin
ResetMemory(ServiceStatus, SizeOf(ServiceStatus));
if not QueryServiceStatus(ServiceHandle, ServiceStatus) then
RaiseLastOSError;
Result := ServiceStatus.dwCurrentState;
end;
function GetServiceStatusWaitingIfPending(ServiceHandle: SC_HANDLE): DWORD;
var
ServiceStatus: TServiceStatus;
WaitDuration: DWORD;
LastCheckPoint: DWORD;
begin
ResetMemory(ServiceStatus, SizeOf(ServiceStatus));
if not QueryServiceStatus(ServiceHandle, ServiceStatus) then
RaiseLastOSError;
Result := ServiceStatus.dwCurrentState;
while TJclServiceState(Result) in ssPendingStates do
begin
LastCheckPoint := ServiceStatus.dwCheckPoint;
// Multiple operations might alter the expected wait duration, so check inside the loop
WaitDuration := ServiceStatus.dwWaitHint;
if WaitDuration < 1000 then
WaitDuration := 1000
else
if WaitDuration > 10000 then
WaitDuration := 10000;
Sleep(WaitDuration);
// Get the new status
if not QueryServiceStatus(ServiceHandle, ServiceStatus) then
RaiseLastOSError;
Result := ServiceStatus.dwCurrentState;
if ServiceStatus.dwCheckPoint = LastCheckPoint then // No progress made
Break;
end;
end;
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end.
| 30.528617 | 119 | 0.690344 |
c3bb302cb81cd07b95ab1ccccf5b4d0a3c246ff6 | 2,589 | dpr | Pascal | tsmbios-master/Samples/Table 6 Memory Module Information/MemoryModuleInfo.dpr | Organization-reBatch/reBatch | 1de155cafcd344d633551d4dbe04b304a7878467 | [
"Apache-2.0"
]
| 1 | 2021-03-31T14:25:39.000Z | 2021-03-31T14:25:39.000Z | tsmbios-master/Samples/Table 6 Memory Module Information/MemoryModuleInfo.dpr | rick-49/reBatch | 1de155cafcd344d633551d4dbe04b304a7878467 | [
"Apache-2.0"
]
| null | null | null | tsmbios-master/Samples/Table 6 Memory Module Information/MemoryModuleInfo.dpr | rick-49/reBatch | 1de155cafcd344d633551d4dbe04b304a7878467 | [
"Apache-2.0"
]
| null | null | null | program MemoryModuleInfo;
{$APPTYPE CONSOLE}
uses
Classes,
SysUtils,
uSMBIOS in '..\..\Common\uSMBIOS.pas';
function ByteToBinStr(AValue: Byte): string;
const
Bits: array [1 .. 8] of Byte = (128, 64, 32, 16, 8, 4, 2, 1);
var
i: integer;
begin
Result := '00000000';
if (AValue <> 0)
then
for i := 1 to 8 do
if (AValue and Bits[i]) <> 0
then
Result[i] := '1';
end;
function WordToBinStr(AValue: Word): string;
const
Bits: array [1 .. 16] of Word = (32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1);
var
i: integer;
begin
Result := '0000000000000000';
if (AValue <> 0)
then
for i := 1 to 16 do
if (AValue and Bits[i]) <> 0
then
Result[i] := '1';
end;
procedure GetMemoryModuleInfo;
Var
SMBios: TSMBios;
LMemoryModule: TMemoryModuleInformation;
begin
SMBios := TSMBios.Create;
try
// SMBios.FindAndLoadFromFile('C:\Users\Foo\Desktop\RAD Studio Projects\google-code\SMBIOS Delphi\Docs\DELL_system_dumps\PE8450\SMBIOS.dat');
WriteLn('Memory Module Information');
WriteLn('-----------------------------');
if SMBios.HasMemoryModuleInfo
then
for LMemoryModule in SMBios.MemoryModuleInfo do
begin
WriteLn(Format('Socket Designation %s', [LMemoryModule.GetSocketDesignationDescr]));
WriteLn(Format('Bank Connections %s',
[ByteToBinStr(LMemoryModule.RAWMemoryModuleInformation.BankConnections)]));
WriteLn(Format('CurrentSpeed %d ns', [LMemoryModule.RAWMemoryModuleInformation.CurrentSpeed]));
// If the speed is unknown, the field is set to 0.
WriteLn(Format('Current Memory Type %s',
[WordToBinStr(LMemoryModule.RAWMemoryModuleInformation.CurrentMemoryType)]));
WriteLn(Format('Installed Size %s',
[ByteToBinStr(LMemoryModule.RAWMemoryModuleInformation.InstalledSize)]));
WriteLn(Format('Enabled Size %s',
[ByteToBinStr(LMemoryModule.RAWMemoryModuleInformation.EnabledSize)]));
WriteLn(Format('Error Status %s',
[ByteToBinStr(LMemoryModule.RAWMemoryModuleInformation.ErrorStatus)]));
WriteLn;
end
else
WriteLn('No Memory Module Information was found');
finally
SMBios.Free;
end;
end;
begin
try
GetMemoryModuleInfo;
except
on E: Exception do
WriteLn(E.Classname, ':', E.Message);
end;
WriteLn('Press Enter to exit');
Readln;
end.
| 29.758621 | 147 | 0.617999 |
c3cae1d9be292d17643cb962afb7fb873208715e | 75,878 | pas | Pascal | lazarus/lcl/interfaces/cocoa/cocoawscomctrls.pas | rarnu/golcl-liblcl | 6f238af742857921062365656a1b13b44b2330ce | [
"Apache-2.0"
]
| null | null | null | lazarus/lcl/interfaces/cocoa/cocoawscomctrls.pas | rarnu/golcl-liblcl | 6f238af742857921062365656a1b13b44b2330ce | [
"Apache-2.0"
]
| null | null | null | lazarus/lcl/interfaces/cocoa/cocoawscomctrls.pas | rarnu/golcl-liblcl | 6f238af742857921062365656a1b13b44b2330ce | [
"Apache-2.0"
]
| null | null | null | unit CocoaWSComCtrls;
interface
{$mode delphi}
{$modeswitch objectivec1}
{$include cocoadefines.inc}
{.$DEFINE COCOA_DEBUG_TABCONTROL}
{.$DEFINE COCOA_DEBUG_LISTVIEW}
uses
// RTL, FCL, LCL
MacOSAll, CocoaAll,
Classes, LCLType, SysUtils, Contnrs, LCLMessageGlue, LMessages,
Controls, ComCtrls, Types, StdCtrls, LCLProc, Graphics, ImgList,
Math,
// WS
WSComCtrls,
// Cocoa WS
CocoaPrivate, CocoaScrollers, CocoaTabControls, CocoaUtils,
CocoaWSCommon, CocoaTables, cocoa_extra, CocoaWSStdCtrls, CocoaGDIObjects, CocoaButtons;
type
{ TCocoaWSStatusBar }
{ TStatusBarCallback }
TStatusBarCallback = class(TLCLCommonCallback, IStatusBarCallback, ICommonCallback)
function GetBarsCount: Integer;
function GetBarItem(idx: Integer; var txt: String; var width: Integer; var align: TAlignment): Boolean;
procedure DrawPanel(idx: Integer; const r: TRect);
end;
TCocoaWSStatusBar = class(TWSStatusBar)
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure PanelUpdate(const AStatusBar: TStatusBar; PanelIndex: integer); override;
class procedure SetPanelText(const AStatusBar: TStatusBar; PanelIndex: integer); override;
class procedure Update(const AStatusBar: TStatusBar); override;
//
class procedure GetPreferredSize(const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
end;
{ TCocoaWSTabSheet }
TCocoaWSTabSheet = class(TWSTabSheet)
published
end;
{ TLCLTabControlCallback }
TLCLTabControlCallback = class(TLCLCommonCallback, ITabControlCallback)
procedure willSelectTabViewItem(aTabIndex: Integer);
procedure didSelectTabViewItem(aTabIndex: Integer);
end;
{ TCocoaWSCustomPage }
TCocoaWSCustomPage = class(TWSCustomPage)
public
class function GetCocoaTabPageFromHandle(AHandle: HWND): TCocoaTabPage;
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure UpdateProperties(const ACustomPage: TCustomPage); override;
class procedure SetProperties(const ACustomPage: TCustomPage; ACocoaControl: NSTabViewItem);
//
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
end;
{ TCocoaWSCustomTabControl }
TCocoaWSCustomTabControl = class(TWSCustomTabControl)
private
class function LCLTabPosToNSTabStyle(AShowTabs: Boolean; ABorderWidth: Integer; ATabPos: TTabPosition): NSTabViewType;
public
class function GetCocoaTabControlHandle(ATabControl: TCustomTabControl): TCocoaTabControl;
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure AddPage(const ATabControl: TCustomTabControl; const AChild: TCustomPage; const AIndex: integer); override;
class procedure MovePage(const ATabControl: TCustomTabControl; const AChild: TCustomPage; const NewIndex: integer); override;
class procedure RemovePage(const ATabControl: TCustomTabControl; const AIndex: integer); override;
//class function GetNotebookMinTabHeight(const AWinControl: TWinControl): integer; override;
//class function GetNotebookMinTabWidth(const AWinControl: TWinControl): integer; override;
//class function GetPageRealIndex(const ATabControl: TCustomTabControl; AIndex: Integer): Integer; override;
class function GetTabIndexAtPos(const ATabControl: TCustomTabControl; const AClientPos: TPoint): integer; override;
class function GetTabRect(const ATabControl: TCustomTabControl; const AIndex: Integer): TRect; override;
class procedure SetPageIndex(const ATabControl: TCustomTabControl; const AIndex: integer); override;
class procedure SetTabPosition(const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition); override;
class procedure ShowTabs(const ATabControl: TCustomTabControl; AShowTabs: boolean); override;
end;
{ TCocoaWSPageControl }
TCocoaWSPageControl = class(TWSPageControl)
published
end;
{ TCocoaWSCustomListView }
TCocoaListView = TCocoaScrollView;
{ TLCLListViewCallback }
TLCLListViewCallback = class(TLCLCommonCallback, IListViewCallback)
public
listView: TCustomListView;
tempItemsCountDelta : Integer;
isSetTextFromWS: Integer; // allows to suppress the notifation about text change
// when initiated by Cocoa itself.
checkedIdx : NSMutableIndexSet;
ownerData : Boolean;
constructor Create(AOwner: NSObject; ATarget: TWinControl; AHandleView: NSView); override;
destructor Destroy; override;
function ItemsCount: Integer;
function GetItemTextAt(ARow, ACol: Integer; var Text: String): Boolean;
function GetItemCheckedAt(ARow, ACol: Integer; var IsChecked: Integer): Boolean;
function GetItemImageAt(ARow, ACol: Integer; var imgIdx: Integer): Boolean;
function GetImageFromIndex(imgIdx: Integer): NSImage;
procedure SetItemTextAt(ARow, ACol: Integer; const Text: String);
procedure SetItemCheckedAt(ARow, ACol: Integer; IsChecked: Integer);
procedure tableSelectionChange(NewSel: Integer; Added, Removed: NSIndexSet);
procedure ColumnClicked(ACol: Integer);
procedure DrawRow(rowidx: Integer; ctx: TCocoaContext; const r: TRect;
state: TOwnerDrawState);
procedure GetRowHeight(rowidx: Integer; var h: Integer);
end;
TLCLListViewCallBackClass = class of TLCLListViewCallback;
TCocoaWSCustomListView = class(TWSCustomListView)
private
class function CheckParams(out AScroll: TCocoaListView; out ATableControl: TCocoaTableListView; const ALV: TCustomListView): Boolean;
class function CheckParamsCb(out AScroll: TCocoaListView; out ATableControl: TCocoaTableListView; out Cb: TLCLListViewCallback; const ALV: TCustomListView): Boolean;
class function CheckColumnParams(out ATableControl: TCocoaTableListView;
out ANSColumn: NSTableColumn; const ALV: TCustomListView; const AIndex: Integer; ASecondIndex: Integer = -1): Boolean;
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
// Column
class procedure ColumnDelete(const ALV: TCustomListView; const AIndex: Integer); override;
class function ColumnGetWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn): Integer; override;
class procedure ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn); override;
class procedure ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn); override;
class procedure ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AAlignment: TAlignment); override;
class procedure ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AAutoSize: Boolean); override;
class procedure ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const ACaption: String); override;
class procedure ColumnSetImage(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AImageIndex: Integer); override;
class procedure ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AMaxWidth: Integer); override;
class procedure ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AMinWidth: integer); override;
class procedure ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AWidth: Integer); override;
class procedure ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AVisible: Boolean); override;
class procedure ColumnSetSortIndicator(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const ASortIndicator: TSortIndicator); override;
// Item
class procedure ItemDelete(const ALV: TCustomListView; const AIndex: Integer); override;
class function ItemDisplayRect(const ALV: TCustomListView; const AIndex, ASubItem: Integer; ACode: TDisplayCode): TRect; override;
class function ItemGetChecked(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem): Boolean; override;
class function ItemGetPosition(const ALV: TCustomListView; const AIndex: Integer): TPoint; override;
class function ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; override; // returns True if supported
class procedure ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem); override;
class procedure ItemSetChecked(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const AChecked: Boolean); override;
class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}ASubIndex, {%H-}AImageIndex: Integer); override;
//carbon//class function ItemSetPosition(const ALV: TCustomListView; const AIndex: Integer; const ANewPosition: TPoint): Boolean; override;*)
class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override;
class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}ASubIndex: Integer; const {%H-}AText: String); override;
class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const PartialOK: Boolean); override;
// LV
//available in 10.7 only//class procedure BeginUpdate(const ALV: TCustomListView); override;
//available in 10.7 only//class procedure EndUpdate(const ALV: TCustomListView); override;
//class function GetBoundingRect(const ALV: TCustomListView): TRect; override;
//carbon//class function GetDropTarget(const ALV: TCustomListView): Integer; override;
class function GetFocused(const ALV: TCustomListView): Integer; override;
//carbon//class function GetHoverTime(const ALV: TCustomListView): Integer; override;
class function GetItemAt(const ALV: TCustomListView; x,y: integer): Integer; override;
class function GetSelCount(const ALV: TCustomListView): Integer; override;
class function GetSelection(const ALV: TCustomListView): Integer; override;
class function GetTopItem(const ALV: TCustomListView): Integer; override;
//class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; override;
class procedure SelectAll(const ALV: TCustomListView; const AIsSet: Boolean); override;
//carbon//class procedure SetAllocBy(const ALV: TCustomListView; const AValue: Integer); override;
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const AValue: Integer); override;
//carbon//class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); override;
//carbon//class procedure SetHoverTime(const ALV: TCustomListView; const AValue: Integer); override;
class procedure SetImageList(const ALV: TCustomListView; const {%H-}AList: TListViewImageList; const {%H-}AValue: TCustomImageListResolution); override;
class procedure SetItemsCount(const ALV: TCustomListView; const Avalue: Integer); override;
class procedure SetOwnerData(const ALV: TCustomListView; const {%H-}AValue: Boolean); override;
class procedure SetProperty(const ALV: TCustomListView; const AProp: TListViewProperty; const AIsSet: Boolean); override;
class procedure SetProperties(const ALV: TCustomListView; const AProps: TListViewProperties); override;
class procedure SetScrollBars(const ALV: TCustomListView; const AValue: TScrollStyle); override;
class procedure SetSort(const ALV: TCustomListView; const {%H-}AType: TSortType; const {%H-}AColumn: Integer;
const {%H-}ASortDirection: TSortDirection); override;
(*class procedure SetViewOrigin(const ALV: TCustomListView; const AValue: TPoint); override;
class procedure SetViewStyle(const ALV: TCustomListView; const AValue: TViewStyle); override;*)
end;
{ TCocoaWSProgressBar }
TCocoaWSProgressBar = class(TWSProgressBar)
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure ApplyChanges(const AProgressBar: TCustomProgressBar); override;
class procedure SetPosition(const AProgressBar: TCustomProgressBar; const NewPosition: integer); override;
class procedure SetStyle(const AProgressBar: TCustomProgressBar; const NewStyle: TProgressBarStyle); override;
end;
{ TCocoaWSCustomUpDown }
TCocoaWSCustomUpDown = class(TWSCustomUpDown)
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure SetIncrement(const AUpDown: TCustomUpDown; AValue: Double); override;
class procedure SetMaxPosition(const AUpDown: TCustomUpDown; AValue: Double); override;
class procedure SetMinPosition(const AUpDown: TCustomUpDown; AValue: Double); override;
class procedure SetPosition(const AUpDown: TCustomUpDown; AValue: Double); override;
class procedure SetWrap(const AUpDown: TCustomUpDown; ADoWrap: Boolean); override;
end;
{ TCarbonWSUpDown }
TCarbonWSUpDown = class(TWSUpDown)
published
end;
{ TCocoaWSToolButton }
TCocoaWSToolButton = class(TWSToolButton)
published
end;
{ TCarbonWSToolBar }
TCarbonWSToolBar = class(TWSToolBar)
published
//class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
end;
{ TCocoaWSTrackBar }
TCocoaWSTrackBar = class(TWSTrackBar)
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure ApplyChanges(const ATrackBar: TCustomTrackBar); override;
class function GetPosition(const ATrackBar: TCustomTrackBar): integer; override;
class procedure SetPosition(const ATrackBar: TCustomTrackBar; const {%H-}NewPosition: integer); override;
class procedure SetOrientation(const ATrackBar: TCustomTrackBar; const AOrientation: TTrackBarOrientation); override;
class procedure SetTick(const ATrackBar: TCustomTrackBar; const ATick: integer); override;
class procedure GetPreferredSize(const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
end;
{ TCocoaWSCustomTreeView }
TCocoaWSCustomTreeView = class(TWSCustomTreeView)
published
end;
{ TCocoaWSTreeView }
TCocoaWSTreeView = class(TWSTreeView)
published
end;
implementation
type
{ TUpdownCommonCallback }
TUpdownCommonCallback = class(TLCLCommonCallback, IStepperCallback)
procedure BeforeChange(var Allowed: Boolean);
procedure Change(NewValue: Double; isUpPressed: Boolean; var Allowed: Boolean);
procedure UpdownClick(isUpPressed: Boolean);
end;
type
TAccessUpDown = class(TCustomUpDown);
{ TUpdownCommonCallback }
procedure TUpdownCommonCallback.BeforeChange(var Allowed: Boolean);
begin
if Assigned( TAccessUpDown(Target).OnChanging ) then
TAccessUpDown(Target).OnChanging(Target, Allowed);
end;
procedure TUpdownCommonCallback.Change(NewValue: Double; isUpPressed: Boolean;
var Allowed: Boolean);
const
UpDownDir : array [Boolean] of TUpDownDirection = (updUp, updDown);
begin
if Assigned( TAccessUpDown(Target).OnChangingEx ) then
TAccessUpDown(Target).OnChangingEx(Target, Allowed,
Round(NewValue), UpDownDir[isUpPressed]);
end;
procedure TUpdownCommonCallback.UpdownClick(isUpPressed: Boolean);
const
UpDownBtn : array [Boolean] of TUDBtnType = (btPrev, btNext);
begin
TAccessUpDown(Target).Position := NSStepper(Owner).intValue;
if Assigned( TAccessUpDown(Target).OnClick ) then
TAccessUpDown(Target).OnClick( Target, UpDownBtn[isUpPressed]);
end;
{ TCocoaWSCustomUpDown }
class function TCocoaWSCustomUpDown.CreateHandle(
const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
var
lResult: TCocoaStepper;
begin
lResult := TCocoaStepper.alloc.lclInitWithCreateParams(AParams);
if Assigned(lResult) then
begin
lResult.callback := TUpdownCommonCallback.Create(lResult, AWinControl);
//small constrol size looks like carbon
//lResult.setControlSize(NSSmallControlSize);
lResult.setTarget(lResult);
lResult.setAction(objcselector('stepperAction:'));
end;
Result := TLCLIntfHandle(lResult);
end;
class procedure TCocoaWSCustomUpDown.SetMinPosition(
const AUpDown: TCustomUpDown; AValue: Double);
begin
if not Assigned(AUpDown) or not AUpDown.HandleAllocated then Exit;
TCocoaStepper(AUpDown.Handle).setMinValue(AValue);
end;
class procedure TCocoaWSCustomUpDown.SetMaxPosition(
const AUpDown: TCustomUpDown; AValue: Double);
begin
if not Assigned(AUpDown) or not AUpDown.HandleAllocated then Exit;
TCocoaStepper(AUpDown.Handle).setMaxValue(AValue);
end;
class procedure TCocoaWSCustomUpDown.SetPosition(const AUpDown: TCustomUpDown;
AValue: Double);
begin
if not Assigned(AUpDown) or not AUpDown.HandleAllocated then Exit;
TCocoaStepper(AUpDown.Handle).lastValue := AValue;
TCocoaStepper(AUpDown.Handle).setDoubleValue(AValue);
end;
class procedure TCocoaWSCustomUpDown.SetIncrement(const AUpDown: TCustomUpDown;
AValue: Double);
begin
if not Assigned(AUpDown) or not AUpDown.HandleAllocated then Exit;
TCocoaStepper(AUpDown.Handle).setIncrement(AValue);
end;
class procedure TCocoaWSCustomUpDown.SetWrap(const AUpDown: TCustomUpDown;
ADoWrap: Boolean);
begin
if not Assigned(AUpDown) or not AUpDown.HandleAllocated then Exit;
TCocoaStepper(AUpDown.Handle).setValueWraps(ADoWrap);
end;
{ TStatusBarCallback }
function TStatusBarCallback.GetBarsCount: Integer;
begin
if TStatusBar(Target).SimplePanel
then Result := 1
else Result := TStatusBar(Target).Panels.Count;
end;
function TStatusBarCallback.GetBarItem(idx: Integer; var txt: String;
var width: Integer; var align: TAlignment): Boolean;
var
sb : TStatusBar;
begin
sb := TStatusBar(Target);
if sb.SimplePanel then begin
Result := idx = 0;
if not Result then Exit;
txt := sb.SimpleText;
width := sb.Width;
align := taLeftJustify; // todo: RTL?
end else begin
Result := (idx >= 0) and (idx < sb.Panels.Count);
if not Result then Exit;
if sb.Panels[idx].Style = psOwnerDraw
then txt := ''
else txt := sb.Panels[idx].Text;
width := sb.Panels[idx].Width;
align := sb.Panels[idx].Alignment;
end;
end;
procedure TStatusBarCallback.DrawPanel(idx: Integer; const r: TRect);
var
sb : TStatusBar;
msg : TLMDrawItems;
ctx : TCocoaContext;
dr : TDrawItemStruct;
fr : TRect;
sv : Integer;
begin
sb := TStatusBar(Target);
if sb.SimplePanel then Exit;
if (idx<0) or (idx >= sb.Panels.Count) then Exit;
if sb.Panels[idx].Style <> psOwnerDraw then Exit;
ctx := TCocoaContext.Create(NSGraphicsContext.currentContext);
sv := ctx.SaveDC;
try
FillChar(msg, sizeof(msg), 0);
FillChar(dr, sizeof(dr), 0);
msg.Ctl := Target.Handle;
msg.Msg := LM_DRAWITEM;
msg.DrawItemStruct := @dr;
dr.itemID := idx;
dr._hDC := HDC(ctx);
dr.rcItem := r;
fr := NSView(Owner).lclFrame;
ctx.InitDraw(fr.Right-fr.Left, fr.Bottom-fr.Top);
LCLMessageGlue.DeliverMessage(Target, msg);
finally
ctx.RestoreDC(sv);
ctx.Free;
end;
end;
{ TLCLTabControlCallback }
procedure TLCLTabControlCallback.willSelectTabViewItem(aTabIndex: Integer);
var
Msg: TLMNotify;
Hdr: TNmHdr;
begin
if aTabIndex<0 then exit;
FillChar(Msg, SizeOf(Msg), 0);
Msg.Msg := LM_NOTIFY;
FillChar(Hdr, SizeOf(Hdr), 0);
Hdr.hwndFrom := FTarget.Handle;
Hdr.Code := TCN_SELCHANGING;
Hdr.idFrom := TTabControl(Target).TabToPageIndex(ATabIndex);
Msg.NMHdr := @Hdr;
Msg.Result := 0;
LCLMessageGlue.DeliverMessage(Target, Msg);
end;
procedure TLCLTabControlCallback.didSelectTabViewItem(aTabIndex: Integer);
var
Msg: TLMNotify;
Hdr: TNmHdr;
begin
if aTabIndex<0 then exit;
FillChar(Msg, SizeOf(Msg), 0);
Msg.Msg := LM_NOTIFY;
FillChar(Hdr, SizeOf(Hdr), 0);
Hdr.hwndFrom := FTarget.Handle;
Hdr.Code := TCN_SELCHANGE;
Hdr.idFrom := TTabControl(Target).TabToPageIndex(ATabIndex);
Msg.NMHdr := @Hdr;
Msg.Result := 0;
LCLMessageGlue.DeliverMessage(Target, Msg);
end;
{ TCocoaWSStatusBar }
class function TCocoaWSStatusBar.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle;
var
lResult: TCocoaStatusBar;
cell : NSButtonCell;
cb : TStatusBarCallback;
begin
Result := 0;
lResult := TCocoaStatusBar.alloc.lclInitWithCreateParams(AParams);
if not Assigned(lResult) then Exit;
Result := TLCLIntfHandle(lResult);
cb := TStatusBarCallback.Create(lResult, AWinControl);
lResult.callback := cb;
lResult.barcallback := cb;
cb.BlockCocoaUpDown := true;
//lResult.StatusBar := TStatusBar(AWinControl);
//todo: get rid of Cells and replace them with views!
cell:=NSButtonCell(NSButtonCell.alloc).initTextCell(nil);
// NSSmallSquareBezelStyle aka "Gradient button", is the best looking
// candidate for the status bar panel. Could be changed to any NSCell class
// since CocoaStatusBar doesn't suspect any specific cell type.
cell.setBezelStyle(NSSmallSquareBezelStyle);
cell.setFont( NSFont.systemFontOfSize( NSFont.smallSystemFontSize ));
cell.setLineBreakMode(NSLineBreakByClipping);
//cell.setLineBreakMode(NSLineBreakByTruncatingTail);
lResult.panelCell := cell;
end;
class procedure TCocoaWSStatusBar.PanelUpdate(const AStatusBar: TStatusBar;
PanelIndex: integer);
begin
// todo: can make more effecient
Update(AStatusBar);
end;
class procedure TCocoaWSStatusBar.SetPanelText(const AStatusBar: TStatusBar;
PanelIndex: integer);
begin
Update(AStatusBar);
end;
class procedure TCocoaWSStatusBar.Update(const AStatusBar: TStatusBar);
begin
if not Assigned(AStatusBar) or not (AStatusBar.HandleAllocated) then Exit;
{$ifdef BOOLFIX}
TCocoaStatusBar(AStatusBar.Handle).setNeedsDisplay__(Ord(true));
{$else}
TCocoaStatusBar(AStatusBar.Handle).setNeedsDisplay_(true);
{$endif}
end;
class procedure TCocoaWSStatusBar.GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean);
begin
PreferredWidth := 0;
PreferredHeight := STATUSBAR_DEFAULT_HEIGHT;
end;
{ TCocoaWSCustomPage }
class function TCocoaWSCustomPage.GetCocoaTabPageFromHandle(AHandle: HWND): TCocoaTabPage;
var
lHandle: TCocoaTabPageView;
begin
lHandle := TCocoaTabPageView(AHandle);
Result := lHandle.tabPage;
end;
class function TCocoaWSCustomPage.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
var
lControl: TCocoaTabPage;
tv: TCocoaTabPageView;
tabview: TCocoaTabControl;
begin
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn('[TCocoaWSCustomPage.CreateHandle]');
{$ENDIF}
lControl := TCocoaTabPage.alloc().init();
Result := TLCLIntfHandle(lControl);
if Result <> 0 then
begin
//lControl.callback := TLCLCommonCallback.Create(lControl, AWinControl);
SetProperties(TCustomPage(AWinControl), lControl);
// Set a special view for the page
// based on http://stackoverflow.com/questions/14892218/adding-a-nstextview-subview-to-nstabviewitem
tabview := TCocoaTabControl(AWinControl.Parent.Handle);
tabview.setAllowsTruncatedLabels(false);
tv := TCocoaTabPageView.alloc.initWithFrame(NSZeroRect);
tv.setAutoresizingMask(NSViewWidthSizable or NSViewHeightSizable);
{tv.setHasVerticalScroller(True);
tv.setHasHorizontalScroller(True);
tv.setAutohidesScrollers(True);
tv.setBorderType(NSNoBorder);}
tv.tabView := tabview;
tv.tabPage := lControl;
tv.callback := TLCLCommonCallback.Create(tv, AWinControl);
TLCLCommonCallback(tv.callback.GetCallbackObject).BlockCocoaUpDown := true;
lControl.callback := tv.callback;
lControl.setView(tv);
Result := TLCLIntfHandle(tv);
end;
end;
class procedure TCocoaWSCustomPage.DestroyHandle(const AWinControl: TWinControl);
var
tv: TCocoaTabPageView;
ndx: NSInteger;
begin
tv := TCocoaTabPageView(AWinControl.Handle);
ndx := tv.tabView.exttabIndexOfTabViewItem(tv.tabPage);
if (ndx >= 0) and (ndx < tv.tabView.fulltabs.count) then
tv.tabview.exttabRemoveTabViewItem(tv.tabPage);
TCocoaWSWinControl.DestroyHandle(AWinControl);
end;
class procedure TCocoaWSCustomPage.UpdateProperties(const ACustomPage: TCustomPage);
var
lTabPage: TCocoaTabPage;
begin
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn('[TCocoaWSCustomTabControl.UpdateProperties] ACustomPage='+IntToStr(PtrInt(ACustomPage)));
{$ENDIF}
if not Assigned(ACustomPage) or not ACustomPage.HandleAllocated then Exit;
lTabPage := GetCocoaTabPageFromHandle(ACustomPage.Handle);
if Assigned(lTabPage) then SetProperties(ACustomPage, lTabPage);
end;
class procedure TCocoaWSCustomPage.SetProperties(
const ACustomPage: TCustomPage; ACocoaControl: NSTabViewItem);
var
lHintStr: string;
begin
// title
ACocoaControl.setLabel(ControlTitleToNSStr(ACustomPage.Caption));
// hint
if ACustomPage.ShowHint then lHintStr := ACustomPage.Hint
else lHintStr := '';
ACocoaControl.setToolTip(NSStringUTF8(lHintStr));
end;
class procedure TCocoaWSCustomPage.SetBounds(const AWinControl: TWinControl;
const ALeft, ATop, AWidth, AHeight: Integer);
begin
// Pages should be fixed into their PageControl owner,
// allowing the TCocoaWSWinControl.SetBounds function to operate here
// was causing bug 28489
end;
class procedure TCocoaWSCustomPage.SetText(const AWinControl: TWinControl;
const AText: String);
var
lTitle: String;
page : TCocoaTabPage;
begin
if not Assigned(AWinControl) or not AWinControl.HandleAllocated then Exit;
page := GetCocoaTabPageFromHandle(AWinControl.Handle);
if not Assigned(page) then Exit;
page.setLabel(ControlTitleToNSStr(AText));
if (AWinControl.Parent <> nil)
and (AWinControl.Parent is TCustomTabControl)
and (AWinControl.HandleAllocated)
then
UpdateTabAndArrowVisibility( TCocoaTabControl(AWinControl.Parent.Handle) );
end;
class function TCocoaWSCustomPage.GetText(const AWinControl: TWinControl;
var AText: String): Boolean;
var
page : TCocoaTabPage;
begin
if not Assigned(AWinControl) or not AWinControl.HandleAllocated then
begin
Result := false;
Exit;
end;
page := GetCocoaTabPageFromHandle(AWinControl.Handle);
AText := NSStringToString( page.label_ );
Result := true;
end;
{ TCocoaWSCustomTabControl }
class function TCocoaWSCustomTabControl.LCLTabPosToNSTabStyle(AShowTabs: Boolean; ABorderWidth: Integer; ATabPos: TTabPosition): NSTabViewType;
begin
Result := NSTopTabsBezelBorder;
if AShowTabs then
begin
case ATabPos of
tpTop: Result := NSTopTabsBezelBorder;
tpBottom: Result := NSBottomTabsBezelBorder;
tpLeft: Result := NSLeftTabsBezelBorder;
tpRight: Result := NSRightTabsBezelBorder;
end;
end
else
begin
if ABorderWidth = 0 then
Result := NSNoTabsNoBorder
else if ABorderWidth = 1 then
Result := NSNoTabsLineBorder
else
Result := NSNoTabsBezelBorder;
end;
end;
class function TCocoaWSCustomTabControl.GetCocoaTabControlHandle(ATabControl: TCustomTabControl): TCocoaTabControl;
begin
Result := nil;
if ATabControl = nil then Exit;
if not ATabControl.HandleAllocated then Exit;
Result := TCocoaTabControl(ATabControl.Handle);
end;
class function TCocoaWSCustomTabControl.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
var
lControl: TCocoaTabControl;
lTabControl: TCustomTabControl = nil;
lTabStyle: NSTabViewType = NSTopTabsBezelBorder;
begin
lTabControl := TCustomTabControl(AWinControl);
lControl := TCocoaTabControl.alloc.lclInitWithCreateParams(AParams);
lTabStyle := LCLTabPosToNSTabStyle(lTabControl.ShowTabs, lTabControl.BorderWidth, lTabControl.TabPosition);
lControl.setTabViewType(lTabStyle);
lControl.lclEnabled := AWinControl.Enabled;
Result := TLCLIntfHandle(lControl);
if Result <> 0 then
begin
lControl.callback := TLCLTabControlCallback.Create(lControl, AWinControl);
lControl.setDelegate(lControl);
end;
end;
class procedure TCocoaWSCustomTabControl.AddPage(const ATabControl: TCustomTabControl; const AChild: TCustomPage; const AIndex: integer);
var
lTabControl: TCocoaTabControl;
lTabPage: TCocoaTabPage;
begin
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn('[TCocoaWSCustomTabControl.AddPage] AChild='+IntToStr(PtrInt(AChild)));
{$ENDIF}
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
AChild.HandleNeeded();
if not Assigned(AChild) or not AChild.HandleAllocated then Exit;
lTabPage := TCocoaWSCustomPage.GetCocoaTabPageFromHandle(AChild.Handle);
lTabControl.exttabInsertTabViewItem_atIndex(lTabPage, AIndex);
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn('[TCocoaWSCustomTabControl.AddPage] END');
{$ENDIF}
end;
class procedure TCocoaWSCustomTabControl.MovePage(const ATabControl: TCustomTabControl; const AChild: TCustomPage; const NewIndex: integer);
var
lTabControl: TCocoaTabControl;
lTabPage: TCocoaTabPage;
begin
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
AChild.HandleNeeded();
if not Assigned(AChild) or not AChild.HandleAllocated then Exit;
lTabPage := TCocoaWSCustomPage.GetCocoaTabPageFromHandle(AChild.Handle);
lTabControl.exttabremoveTabViewItem(lTabPage);
lTabControl.exttabinsertTabViewItem_atIndex(lTabPage, NewIndex);
end;
class procedure TCocoaWSCustomTabControl.RemovePage(const ATabControl: TCustomTabControl; const AIndex: integer);
var
lTabControl: TCocoaTabControl;
lTabPage: NSTabViewItem;
begin
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
lTabPage := NSTabViewItem(lTabControl.fulltabs.objectAtIndex(AIndex));
lTabControl.exttabremoveTabViewItem(lTabPage);
end;
class function TCocoaWSCustomTabControl.GetTabIndexAtPos(const ATabControl: TCustomTabControl; const AClientPos: TPoint): integer;
var
lTabControl: TCocoaTabControl;
lTabPage: NSTabViewItem;
lClientPos: NSPoint;
pt : TPoint;
begin
Result := -1;
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
pt.x := Round(AClientPos.x + lTabControl.contentRect.origin.x);
pt.y := Round(AClientPos.y + lTabControl.contentRect.origin.y);
if lTabControl.isFlipped then
begin
lClientPos.x := pt.X;
lClientPos.y := pt.Y;
end
else
lClientPos := LCLToNSPoint(pt, lTabControl.frame.size.height);
lTabPage := lTabControl.tabViewItemAtPoint(lClientPos);
if not Assigned(lTabPage) then
Exit;
Result := lTabControl.exttabIndexOfTabViewItem(lTabPage);
end;
class function TCocoaWSCustomTabControl.GetTabRect(
const ATabControl: TCustomTabControl; const AIndex: Integer): TRect;
var
lTabControl: TCocoaTabControl;
lTabPage: NSTabViewItem;
tb : TCocoaTabPageView;
i : integer;
idx : integer;
tr : TRect;
w : array of Double;
mw : Double;
ofs : Double; // aprx offset between label and the text (from both sides)
x : Double;
vt : NSTabViewType;
begin
Result:=inherited GetTabRect(ATabControl, AIndex);
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
// unable to determine the rectangle view
if (AIndex<0) or (AIndex>=ATabControl.PageCount) then Exit;
tb := TCocoaTabPageView(ATabControl.Page[AIndex].Handle);
if not Assigned(tb) then Exit;
idx := lTabControl.tabViewItems.indexOfObject( tb.tabPage );
if (idx = Integer(NSNotFound)) then Exit;
if not GetTabsRect(lTabControl, tr) then Exit;
SetLength(w, lTabControl.tabViewItems.count);
if (length(w) = 0) then Exit; // no tabs!
vt := lTabControl.tabViewType;
if (vt = NSTopTabsBezelBorder) or (vt = NSBottomTabsBezelBorder) then
begin
mw := 0;
for i := 0 to Integer(lTabControl.tabViewItems.count)-1 do
begin
lTabPage := lTabControl.tabViewItemAtIndex(i);
w[i] := lTabPage.sizeOfLabel(false).width;
mw := mw + w[i];
end;
if (mw = 0) then Exit; // 0 for the total tabs width?
ofs := (tr.Right - tr.Left - mw) / length(w);
x := tr.Left;
for i := 0 to idx-1 do
x := x+ofs+w[i];
Result.Left := Round(x);
Result.Right := Round(Result.Left + w[idx]);
Result.Top := tr.Top;
Result.Bottom := tr.Bottom;
end
else
begin
mw := 0;
for i := 0 to Integer(lTabControl.tabViewItems.count)-1 do
begin
lTabPage := lTabControl.tabViewItemAtIndex(i);
w[i] := lTabPage.sizeOfLabel(false).height;
mw := mw + w[i];
end;
if (mw = 0) then Exit; // 0 for the total tabs width?
ofs := (tr.Bottom - tr.Top - mw) / length(w);
x := tr.Top;
for i := 0 to idx-1 do
x := x+ofs+w[i];
Result.Left := tr.Left;
Result.Right := tr.Right;
Result.Top := Round(x);
Result.Bottom := Round(Result.Top + w[idx]);
end;
end;
class procedure TCocoaWSCustomTabControl.SetPageIndex(const ATabControl: TCustomTabControl; const AIndex: integer);
var
i : NSInteger;
tb : TCocoaTabPageView;
begin
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn('[TCocoaWSCustomTabControl.SetPageIndex]');
{$ENDIF}
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
if (AIndex<0) or (AIndex>=ATabControl.PageCount) then Exit;
tb := TCocoaTabPageView(ATabControl.Page[AIndex].Handle);
if not Assigned(tb) then Exit;
i := TCocoaTabControl(ATabControl.Handle).fulltabs.indexOfObject( tb.tabPage );
if (i = NSNotFound) then Exit;
TCocoaTabControl(ATabControl.Handle).ignoreChange := True;
TCocoaTabControl(ATabControl.Handle).extselectTabViewItemAtIndex(NSInteger(i));
TCocoaTabControl(ATabControl.Handle).ignoreChange := False;
end;
class procedure TCocoaWSCustomTabControl.SetTabPosition(const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition);
var
lTabControl: TCocoaTabControl = nil;
lOldTabStyle, lTabStyle: NSTabViewType;
begin
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
lOldTabStyle := lTabControl.tabViewType();
lTabStyle := LCLTabPosToNSTabStyle(ATabControl.ShowTabs, ATabControl.BorderWidth, ATabPosition);
lTabControl.setTabViewType(lTabStyle);
end;
class procedure TCocoaWSCustomTabControl.ShowTabs(const ATabControl: TCustomTabControl; AShowTabs: boolean);
var
lTabControl: TCocoaTabControl = nil;
lOldTabStyle, lTabStyle: NSTabViewType;
var
pr : TRect;
ar : TRect;
fr : NSRect;
dx, dy : double;
cb: ICommonCallback;
begin
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
lOldTabStyle := lTabControl.tabViewType();
lTabStyle := LCLTabPosToNSTabStyle(AShowTabs, ATabControl.BorderWidth, ATabControl.TabPosition);
pr := lTabControl.lclGetFrameToLayoutDelta;
lTabControl.setTabViewType(lTabStyle);
ar := lTabControl.lclGetFrameToLayoutDelta;
// switching ShowTabs actually changes layout to frame
// this needs to be compenstated
if (ar.Top<>pr.Top) or (pr.Left<>ar.Top) then
begin
fr := lTabControl.frame;
dx := pr.Left - ar.left;
dy := pr.Top - ar.Top;
fr.origin.x := fr.origin.x + dx;
fr.origin.y := fr.origin.y + dy;
fr.size.width := fr.size.width - dx - (ar.Right - pr.Right);
fr.size.height := fr.size.height - dy - (ar.Bottom - pr.Bottom);
lTabControl.setFrame(fr);
cb := lTabControl.lclGetCallback;
if Assigned(cb) then cb.frameDidChange(lTabControl);
end;
end;
{ TCocoaWSCustomListView }
class function TCocoaWSCustomListView.CheckParams(
out AScroll: TCocoaListView;
out ATableControl: TCocoaTableListView; const ALV: TCustomListView): Boolean;
begin
Result := False;
AScroll := nil;
ATableControl := nil;
if not Assigned(ALV) or not ALV.HandleAllocated then Exit;
AScroll := TCocoaListView(ALV.Handle);
// ToDo: Implement for other styles
if Assigned(AScroll.documentView) and (AScroll.documentView.isKindOfClass(TCocoaTableListView)) then
begin
ATableControl := TCocoaTableListView(AScroll.documentView);
Result := True;
end;
end;
class function TCocoaWSCustomListView.CheckParamsCb(out AScroll: TCocoaListView; out ATableControl: TCocoaTableListView; out Cb: TLCLListViewCallback; const ALV: TCustomListView): Boolean;
begin
Result := CheckParams(AScroll, ATableControl, ALV);
if Result then
Cb := TLCLListViewCallback(ATableControl.lclGetCallback.GetCallbackObject)
else
Cb := nil;
end;
class function TCocoaWSCustomListView.CheckColumnParams(
out ATableControl: TCocoaTableListView; out ANSColumn: NSTableColumn;
const ALV: TCustomListView; const AIndex: Integer; ASecondIndex: Integer
): Boolean;
var
lv : TCocoaListView;
begin
Result := False;
ANSColumn := nil;
if not CheckParams(lv, ATableControl, ALV) then Exit;
if (AIndex < 0) or (AIndex >= ATableControl.tableColumns.count()) then Exit;
ANSColumn := NSTableColumn(ATableControl.tableColumns.objectAtIndex(AIndex));
Result := Assigned(ANSColumn);
if ASecondIndex >= 0 then
begin
if (ASecondIndex < 0) or (ASecondIndex >= ATableControl.tableColumns.count()) then Exit;
end;
end;
class function TCocoaWSCustomListView.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
ns: NSRect;
lclcb: TLCLListViewCallback;
sz: NSSize;
begin
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn('[TCocoaWSCustomListView.CreateHandle] AWinControl='+IntToStr(PtrInt(AWinControl)));
{$ENDIF}
lCocoaLV := TCocoaListView.alloc.lclInitWithCreateParams(AParams);
Result := TLCLIntfHandle(lCocoaLV);
if Result <> 0 then
begin
ns := GetNSRect(0, 0, AParams.Width, AParams.Height);
lTableLV := AllocCocoaTableListView.initWithFrame(ns);
if lTableLV = nil then
begin
lCocoaLV.dealloc;
Result := 0;
exit;
end;
// Unintuitive things about NSTableView which caused a lot of headaches:
// 1-> The column header appears only if the NSTableView is inside a NSScrollView
// 2-> To get proper scrolling use NSScrollView.setDocumentView instead of addSubview
// Source: http://stackoverflow.com/questions/13872642/nstableview-scrolling-does-not-work
//lCocoaLV.TableListView := lTableLV;
lCocoaLV.setDocumentView(lTableLV);
lCocoaLV.setHasVerticalScroller(True);
lclcb := TLCLListViewCallback.Create(lTableLV, AWinControl, lCocoaLV);
lclcb.listView := TCustomListView(AWinControl);
lTableLV.callback := lclcb;
lTableLV.setDataSource(lTableLV);
lTableLV.setDelegate(lTableLV);
lTableLV.setAllowsColumnReordering(False);
lTableLV.setAllowsColumnSelection(False);
lCocoaLV.callback := lclcb;
ScrollViewSetBorderStyle(lCocoaLV, TCustomListView(AWinControl).BorderStyle);
UpdateFocusRing(lTableLV, TCustomListView(AWinControl).BorderStyle);
sz := lTableLV.intercellSpacing;
// Windows compatibility. on Windows there's no extra space between columns
sz.width := 0;
lTableLV.setIntercellSpacing(sz);;
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.CreateHandle] headerView=%d', [PtrInt(lTableLV.headerView)]));
{$ENDIF}
end;
end;
class procedure TCocoaWSCustomListView.SetBorderStyle(
const AWinControl: TWinControl; const ABorderStyle: TBorderStyle);
begin
if not Assigned(AWinControl) or not AWinControl.HandleAllocated then Exit;
ScrollViewSetBorderStyle(NSScrollView(AWinControl.Handle), ABorderStyle);
UpdateFocusRing(NSView(NSScrollView(AWinControl.Handle).documentView), ABorderStyle);
end;
class procedure TCocoaWSCustomListView.ColumnDelete(const ALV: TCustomListView;
const AIndex: Integer);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
begin
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.ColumnDelete] AIndex=%d', [AIndex]));
{$ENDIF}
if not CheckColumnParams(lTableLV, lNSColumn, ALV, AIndex) then Exit;
if lNSColumn = nil then Exit;
lTableLV.removeTableColumn(lNSColumn);
lNSColumn.release;
end;
class function TCocoaWSCustomListView.ColumnGetWidth(
const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn
): Integer;
var
lTableLV: TCocoaTableListView;
lColumn: NSTableColumn;
sc: TCocoaListView;
begin
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.ColumnGetWidth] AIndex=%d', [AIndex]));
{$ENDIF}
Result:=0;
if not CheckParams(sc, lTableLV, ALV) then Exit;
//if not Assigned(ALV) or not ALV.HandleAllocated then Exit;
//lTableLV := TCocoaTableListView(TCocoaListView(ALV.Handle).documentView);
if (AIndex < 0) or (AIndex >= lTableLV.tableColumns.count()) then Exit;
lColumn := lTableLV.tableColumns.objectAtIndex(AIndex);
Result := Round(lColumn.width());
end;
class procedure TCocoaWSCustomListView.ColumnInsert(const ALV: TCustomListView;
const AIndex: Integer; const AColumn: TListColumn);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
lTitle: NSString;
sc: TCocoaListView;
begin
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.ColumnInsert] ALV=%x AIndex=%d', [PtrInt(ALV), AIndex]));
{$ENDIF}
ALV.HandleNeeded();
//if not Assigned(ALV) or not ALV.HandleAllocated then Exit;
//lTableLV := TCocoaTableListView(TCocoaListView(ALV.Handle).documentView);
if not CheckParams(sc, lTableLV, ALV) then Exit;
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.ColumnInsert]=> tableColumns.count=%d', [lTableLV.tableColumns.count()]));
{$ENDIF}
if (AIndex < 0) or (AIndex >= lTableLV.tableColumns.count()+1) then Exit;
lTitle := NSStringUTF8(AColumn.Caption);
lNSColumn := NSTableColumn.alloc.initWithIdentifier(lTitle);
lNSColumn.headerCell.setStringValue(lTitle);
lNSColumn.setResizingMask(NSTableColumnUserResizingMask);
lTableLV.addTableColumn(lNSColumn);
lTitle.release;
end;
class procedure TCocoaWSCustomListView.ColumnMove(const ALV: TCustomListView;
const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
begin
if not CheckColumnParams(lTableLV, lNSColumn, ALV, AOldINdex, ANewIndex) then Exit;
lTableLV.moveColumn_toColumn(AOldIndex, ANewIndex);
end;
class procedure TCocoaWSCustomListView.ColumnSetAlignment(
const ALV: TCustomListView; const AIndex: Integer;
const AColumn: TListColumn; const AAlignment: TAlignment);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
const
txtAlign : array[TAlignment] of NSTextAlignment = (
NSLeftTextAlignment, NSRightTextAlignment, NSCenterTextAlignment
);
begin
if not CheckColumnParams(lTableLV, lNSColumn, ALV, AIndex) then Exit;
lTableLV.lclSetColumnAlign(lNSColumn, txtAlign[AAlignment]);
lTableLV.setNeedsDisplayInRect(lTableLV.rectOfColumn(AIndex));
lTableLV.headerView.setNeedsDisplayInRect( lTableLV.headerView.headerRectOfColumn(AIndex) );
end;
class procedure TCocoaWSCustomListView.ColumnSetAutoSize(
const ALV: TCustomListView; const AIndex: Integer;
const AColumn: TListColumn; const AAutoSize: Boolean);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
lResizeMask: NSUInteger;
begin
if not CheckColumnParams(lTableLV, lNSColumn, ALV, AIndex) then Exit;
if AAutoSize then lResizeMask := NSTableColumnAutoresizingMask or NSTableColumnUserResizingMask
else lResizeMask := NSTableColumnUserResizingMask;
lNSColumn.setResizingMask(lResizeMask);
end;
class procedure TCocoaWSCustomListView.ColumnSetCaption(
const ALV: TCustomListView; const AIndex: Integer;
const AColumn: TListColumn; const ACaption: String);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
lNSCaption: NSString;
begin
if not CheckColumnParams(lTableLV, lNSColumn, ALV, AIndex) then Exit;
lNSCaption := NSStringUtf8(ACaption);
if lNSColumn.respondsToSelector(ObjCSelector('setTitle:')) then
lNSColumn.setTitle(lNSCaption)
else
lNSColumn.headerCell.setStringValue(lNSCaption);
{$ifdef BOOLFIX}
lTableLV.headerView.setNeedsDisplay__(Ord(true)); // forces the newly set Value (even for setTitle!)
{$else}
lTableLV.headerView.setNeedsDisplay_(true); // forces the newly set Value (even for setTitle!)
{$endif}
lNSCaption.release;
end;
class procedure TCocoaWSCustomListView.ColumnSetImage(
const ALV: TCustomListView; const AIndex: Integer;
const AColumn: TListColumn; const AImageIndex: Integer);
begin
inherited ColumnSetImage(ALV, AIndex, AColumn, AImageIndex);
end;
class procedure TCocoaWSCustomListView.ColumnSetMaxWidth(
const ALV: TCustomListView; const AIndex: Integer;
const AColumn: TListColumn; const AMaxWidth: Integer);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
begin
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.ColumnSetMaxWidth] AMaxWidth=%d', [AMaxWidth]));
{$ENDIF}
if not CheckColumnParams(lTableLV, lNSColumn, ALV, AIndex) then Exit;
if AMaxWidth <= 0 then lNSColumn.setMaxWidth($FFFFFFFF)
else lNSColumn.setMaxWidth(AMaxWidth);
end;
class procedure TCocoaWSCustomListView.ColumnSetMinWidth(
const ALV: TCustomListView; const AIndex: Integer;
const AColumn: TListColumn; const AMinWidth: integer);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
begin
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.ColumnSetMinWidth] AMinWidth=%d', [AMinWidth]));
{$ENDIF}
if not CheckColumnParams(lTableLV, lNSColumn, ALV, AIndex) then Exit;
lNSColumn.setMinWidth(AMinWidth);
end;
class procedure TCocoaWSCustomListView.ColumnSetWidth(
const ALV: TCustomListView; const AIndex: Integer;
const AColumn: TListColumn; const AWidth: Integer);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
begin
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.ColumnSetWidth] AWidth=%d', [AWidth]));
{$ENDIF}
if not CheckColumnParams(lTableLV, lNSColumn, ALV, AIndex) then Exit;
lNSColumn.setWidth(AWidth);
end;
class procedure TCocoaWSCustomListView.ColumnSetVisible(
const ALV: TCustomListView; const AIndex: Integer;
const AColumn: TListColumn; const AVisible: Boolean);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
begin
if not CheckColumnParams(lTableLV, lNSColumn, ALV, AIndex) then Exit;
{$ifdef BOOLFIX}
lNSColumn.setHidden_(Ord(not AVisible));
{$else}
lNSColumn.setHidden(not AVisible);
{$endif}
end;
class procedure TCocoaWSCustomListView.ColumnSetSortIndicator(
const ALV: TCustomListView; const AIndex: Integer;
const AColumn: TListColumn; const ASortIndicator: TSortIndicator);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
begin
if not CheckColumnParams(lTableLV, lNSColumn, ALV, AIndex) then Exit;
case ASortIndicator of
siNone:
lTableLV.setIndicatorImage_inTableColumn(nil, lNSColumn);
siAscending:
lTableLV.setIndicatorImage_inTableColumn(
NSImage.imageNamed(NSSTR('NSAscendingSortIndicator')),
lNSColumn);
siDescending:
lTableLV.setIndicatorImage_inTableColumn(
NSImage.imageNamed(NSSTR('NSDescendingSortIndicator')),
lNSColumn);
end;
end;
class procedure TCocoaWSCustomListView.ItemDelete(const ALV: TCustomListView;
const AIndex: Integer);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
lclcb : TLCLListViewCallback;
begin
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn(Format('[TCocoaWSCustomListView.ItemDelete] AIndex=%d', [AIndex]));
{$ENDIF}
if not CheckParamsCb(lCocoaLV, lTableLV, lclcb, ALV) then Exit;
lclcb.tempItemsCountDelta := -1;
lclcb.checkedIdx.shiftIndexesStartingAtIndex_by(AIndex, -1);
lTableLV.lclInsDelRow(AIndex, false);
lclcb.tempItemsCountDelta := 0;
end;
class function TCocoaWSCustomListView.ItemDisplayRect(
const ALV: TCustomListView; const AIndex, ASubItem: Integer;
ACode: TDisplayCode): TRect;
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
Result:=Bounds(0,0,0,0);
if not CheckParams(lCocoaLV, lTableLV, ALV) then Exit;
LCLGetItemRect(lTableLV, AIndex, ASubItem, Result);
case ACode of
drLabel: Result := lTableLV.lclGetLabelRect(AIndex, ASubItem, Result);
drIcon: Result := lTableLV.lclGetIconRect(AIndex, ASubItem, Result);
end;
end;
class function TCocoaWSCustomListView.ItemGetChecked(
const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem
): Boolean;
var
lclcb : TLCLListViewCallback;
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParamsCb(lCocoaLV, lTableLV, lclcb, ALV) then begin
Result := false;
Exit;
end;
Result := lclcb.checkedIdx.containsIndex(AIndex);
end;
class function TCocoaWSCustomListView.ItemGetPosition(
const ALV: TCustomListView; const AIndex: Integer): TPoint;
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
lNSRect: NSRect;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then
begin
Result:=Point(0,0);
Exit;
end;
lNSRect := lTableLV.rectOfRow(AIndex);
Result.X := Round(lNSRect.origin.X);
Result.Y := Round(lCocoaLV.frame.size.height - lNSRect.origin.Y);
end;
class function TCocoaWSCustomListView.ItemGetState(const ALV: TCustomListView;
const AIndex: Integer; const AItem: TListItem; const AState: TListItemState;
out AIsSet: Boolean): Boolean;
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
lclcb: TLCLListViewCallback;
begin
case AState of
lisSelected: begin
Result := false;
if not CheckParamsCb(lCocoaLV, lTableLV, lclcb, ALV) then Exit;
Result := (AIndex>=0) and (AIndex <= lTableLV.numberOfRows);
AIsSet := lTableLV.isRowSelected(AIndex);
end;
else
Result := inherited ItemGetState(ALV, AIndex, AItem, AState, AIsSet);
end;
end;
class procedure TCocoaWSCustomListView.ItemInsert(const ALV: TCustomListView;
const AIndex: Integer; const AItem: TListItem);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
lclcb: TLCLListViewCallback;
begin
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn(Format('[TCocoaWSCustomListView.ItemInsert] AIndex=%d', [AIndex]));
{$ENDIF}
if not CheckParamsCb(lCocoaLV, lTableLV, lclcb, ALV) then Exit;
lclcb.checkedIdx.shiftIndexesStartingAtIndex_by(AIndex, 1);
lTableLV.lclInsDelRow(AIndex, true);
lTableLV.sizeToFit();
end;
class procedure TCocoaWSCustomListView.ItemSetChecked(
const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem;
const AChecked: Boolean);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
cb : TLCLListViewCallback;
begin
if not CheckParamsCb(lCocoaLV, lTableLV, cb, ALV) then Exit;
// todo: make a specific row/column reload data!
if AChecked and not cb.checkedIdx.containsIndex(AIndex) then
begin
cb.checkedIdx.addIndex(AIndex);
lTableLV.reloadDataForRow_column(AIndex, 0);
end
else
if not AChecked and cb.checkedIdx.containsIndex(AIndex) then
begin
cb.checkedIdx.removeIndex(AIndex);
lTableLV.reloadDataForRow_column(AIndex, 0);
end;
end;
class procedure TCocoaWSCustomListView.ItemSetImage(const ALV: TCustomListView;
const AIndex: Integer; const AItem: TListItem; const ASubIndex,
AImageIndex: Integer);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then Exit;
lTableLV.reloadDataForRow_column(AIndex, ASubIndex);
end;
class procedure TCocoaWSCustomListView.ItemSetState(const ALV: TCustomListView;
const AIndex: Integer; const AItem: TListItem; const AState: TListItemState;
const AIsSet: Boolean);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
row : Integer;
isSel : Boolean;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) or not Assigned(AItem) then Exit;
row := AItem.Index;
if (row < 0) or (row >= lTableLV.numberOfRows) then Exit;
case AState of
lisSelected:
begin
isSel := lTableLV.selectedRowIndexes.containsIndex(row);
if AIsSet and not isSel then
lTableLV.selectRowIndexes_byExtendingSelection(NSIndexSet.indexSetWithIndex(row),false)
else if not AIsSet and isSel then
lTableLV.deselectRow(row);
end;
else
inherited ItemSetState(ALV, AIndex, AItem, AState, AIsSet);
end;
end;
class procedure TCocoaWSCustomListView.ItemSetText(const ALV: TCustomListView;
const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer;
const AText: String);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then Exit;
lTableLV.reloadDataForRow_column(AIndex, ASubIndex);
end;
class procedure TCocoaWSCustomListView.ItemShow(const ALV: TCustomListView;
const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
//inherited ItemShow(ALV, AIndex, AItem, PartialOK);
if not CheckParams(lCocoaLV, lTableLV, ALV) then
Exit;
lTableLV.scrollRowToVisible(AItem.Index);
end;
class function TCocoaWSCustomListView.GetFocused(const ALV: TCustomListView): Integer;
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then
begin
Result:=-1;
Exit;
end;
Result := lTableLV.selectedRow;
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn(Format('[TCocoaWSCustomListView.GetFocused] Result=%d', [Result]));
{$ENDIF}
end;
class function TCocoaWSCustomListView.GetItemAt(const ALV: TCustomListView; x,
y: integer): Integer;
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then
begin
Result:=-1;
Exit;
end;
Result := LCLCoordToRow(lTableLV, x,y);
end;
class function TCocoaWSCustomListView.GetSelCount(const ALV: TCustomListView): Integer;
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then
begin
Result:=0;
Exit;
end;
Result := lTableLV.selectedRowIndexes().count();
end;
class function TCocoaWSCustomListView.GetSelection(const ALV: TCustomListView): Integer;
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then
begin
Result:=-1;
Exit;
end;
Result := lTableLV.selectedRow;
{$IFDEF COCOA_DEBUG_TABCONTROL}
WriteLn(Format('[TCocoaWSCustomListView.GetSelection] Result=%d', [Result]));
{$ENDIF}
end;
class function TCocoaWSCustomListView.GetTopItem(const ALV: TCustomListView): Integer;
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then
begin
Result:=-1;
Exit;
end;
Result := LCLGetTopRow(lTableLV);
end;
class function TCocoaWSCustomListView.GetVisibleRowCount(
const ALV: TCustomListView): Integer;
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
lVisibleRows: NSRange;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then
begin
Result := 0;
Exit;
end;
lVisibleRows := lTableLV.rowsInRect(lTableLV.visibleRect());
Result := lVisibleRows.length;
end;
class procedure TCocoaWSCustomListView.SelectAll(const ALV: TCustomListView;
const AIsSet: Boolean);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then Exit;
if AIsSet then
lTableLV.selectAll(lTableLV)
else
lTableLV.deselectAll(lTableLV);
end;
class procedure TCocoaWSCustomListView.SetDefaultItemHeight(
const ALV: TCustomListView; const AValue: Integer);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then Exit;
if AValue > 0 then
lTableLV.setRowHeight(AValue);
// setRowSizeStyle could be used here but is available only in 10.7+
end;
class procedure TCocoaWSCustomListView.SetImageList(const ALV: TCustomListView;
const AList: TListViewImageList; const AValue: TCustomImageListResolution);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then Exit;
lTableLV.lclSetImagesInCell(Assigned(AValue));
end;
class procedure TCocoaWSCustomListView.SetItemsCount(
const ALV: TCustomListView; const Avalue: Integer);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then Exit;
lTableLV.noteNumberOfRowsChanged();
end;
class procedure TCocoaWSCustomListView.SetOwnerData(const ALV: TCustomListView;
const AValue: Boolean);
var
lCocoaLV : TCocoaListView;
lTableLV : TCocoaTableListView;
cb : TLCLListViewCallback;
begin
if not CheckParamsCb(lCocoaLV, lTableLV, cb, ALV) then Exit;
cb.ownerData := AValue;
if cb.ownerData then cb.checkedIdx.removeAllIndexes; // releasing memory
end;
class procedure TCocoaWSCustomListView.SetProperty(const ALV: TCustomListView;
const AProp: TListViewProperty; const AIsSet: Boolean);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
const
GridStyle : array [boolean] of NSUInteger = (
NSTableViewGridNone,
NSTableViewSolidHorizontalGridLineMask or NSTableViewSolidVerticalGridLineMask
);
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then Exit;
case AProp of
{lvpAutoArrange,}
lvpCheckboxes: lTableLV.lclSetFirstColumCheckboxes(AIsSet);
// lvpColumnClick: lTableLV.setAllowsColumnSelection(AIsSet);
{ lvpFlatScrollBars,
lvpFullDrag,}
lvpGridLines: lTableLV.setGridStyleMask(GridStyle[AIsSet]);
{lvpHideSelection,
lvpHotTrack,}
lvpMultiSelect: lTableLV.setAllowsMultipleSelection(AIsSet);
{lvpOwnerDraw,}
lvpReadOnly: lTableLv.readOnly := AIsSet;
{ lvpRowSelect,}
lvpShowColumnHeaders:
if (AIsSet <> Assigned(lTableLV.headerView)) then
begin
if AIsSet then lTableLv.setHeaderView ( NSTableHeaderView.alloc.init )
else lTableLv.setHeaderView(nil);
end;
{ lvpShowWorkAreas,
lvpWrapText,
lvpToolTips}
end;
end;
class procedure TCocoaWSCustomListView.SetProperties(
const ALV: TCustomListView; const AProps: TListViewProperties);
begin
inherited SetProperties(ALV, AProps);
end;
class procedure TCocoaWSCustomListView.SetScrollBars(
const ALV: TCustomListView; const AValue: TScrollStyle);
var
lTableLV: TCocoaTableListView;
lCocoaLV: TCocoaListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then Exit;
ScrollViewSetScrollStyles(lCocoaLV, AValue);
{$ifdef BOOLFIX}
lCocoaLV.setNeedsDisplay__(Ord(true));
{$else}
lCocoaLV.setNeedsDisplay_(true);
{$endif}
{$ifdef BOOLFIX}
lCocoaLV.documentView.setNeedsDisplay__(Ord(true));
{$else}
lCocoaLV.documentView.setNeedsDisplay_(true);
{$endif}
end;
class procedure TCocoaWSCustomListView.SetSort(const ALV: TCustomListView;
const AType: TSortType; const AColumn: Integer;
const ASortDirection: TSortDirection);
var
lTableLV: TCocoaTableListView;
lNSColumn: NSTableColumn;
begin
if not CheckColumnParams(lTableLV, lNSColumn, ALV, AColumn) then Exit;
lTableLV.reloadData();
{ //todo:
lNSColumn.setSortDescriptorPrototype(
NSSortDescriptor.sortDescriptorWithKey_ascending_selector(
NSSTR('none'),
ASortDirection=sdAscending,
objcselector('none:')
)
);}
end;
{ TCocoaWSProgressBar }
class function TCocoaWSProgressBar.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle;
var
lResult: TCocoaProgressIndicator;
begin
lResult := TCocoaProgressIndicator.alloc.lclInitWithCreateParams(AParams);
if Assigned(lResult) then
begin
lResult.callback := TLCLCommonCallback.Create(lResult, AWinControl);
lResult.startAnimation(nil);
//small constrol size looks like carbon
//lResult.setControlSize(NSSmallControlSize);
end;
Result := TLCLIntfHandle(lResult);
end;
class procedure TCocoaWSProgressBar.ApplyChanges(
const AProgressBar: TCustomProgressBar);
var
ind : NSProgressIndicator;
begin
if not Assigned(AProgressBar) or not AProgressBar.HandleAllocated then Exit;
ind:=NSProgressIndicator(AProgressBAr.Handle);
ind.setMaxValue(AProgressBar.Max);
ind.setMinValue(AProgressBar.Min);
ind.setDoubleValue(AProgressBar.Position);
SetStyle(AProgressBar, AProgressBar.Style);
end;
class procedure TCocoaWSProgressBar.SetPosition(
const AProgressBar: TCustomProgressBar; const NewPosition: integer);
begin
if AProgressBar.HandleAllocated then
NSProgressIndicator(AProgressBar.Handle).setDoubleValue(NewPosition);
end;
class procedure TCocoaWSProgressBar.SetStyle(
const AProgressBar: TCustomProgressBar; const NewStyle: TProgressBarStyle);
begin
if AProgressBar.HandleAllocated then
begin
NSProgressIndicator(AProgressBar.Handle).setIndeterminate(NewStyle = pbstMarquee);
NSProgressIndicator(AProgressBar.Handle).startAnimation(nil);
end;
end;
{ TCocoaTabPage }
(*function TCocoaTabPage.lclGetCallback: ICommonCallback;
begin
Result:=callback;
end;
procedure TCocoaTabPage.lclClearCallback;
begin
callback:=nil;
end;
{ TCocoaTabControl }
function TCocoaTabControl.lclGetCallback: ICommonCallback;
begin
Result:=callback;
end;
procedure TCocoaTabControl.lclClearCallback;
begin
callback:=nil;
end; *)
{ TLCLListViewCallback }
type
TProtCustomListView = class(TCustomListView);
constructor TLCLListViewCallback.Create(AOwner: NSObject; ATarget: TWinControl; AHandleView: NSView);
begin
inherited Create(AOwner, ATarget, AHandleView);
checkedIdx := NSMutableIndexSet.alloc.init;
end;
destructor TLCLListViewCallback.Destroy;
begin
if Assigned(checkedIdx) then checkedIdx.release;
inherited Destroy;
end;
function TLCLListViewCallback.ItemsCount: Integer;
begin
Result:=listView.Items.Count + tempItemsCountDelta;
end;
function TLCLListViewCallback.GetItemTextAt(ARow, ACol: Integer;
var Text: String): Boolean;
begin
Result := (ACol>=0) and (ACol<listView.ColumnCount)
and (ARow >= 0) and (ARow < listView.Items.Count);
if not Result then Exit;
if ACol = 0 then
Text := listView.Items[ARow].Caption
else
begin
Text := '';
dec(ACol);
if (ACol >=0) and (ACol < listView.Items[ARow].SubItems.Count) then
Text := listView.Items[ARow].SubItems[ACol];
end;
end;
function TLCLListViewCallback.GetItemCheckedAt(ARow, ACol: Integer;
var IsChecked: Integer): Boolean;
var
BoolState : array [Boolean] of Integer = (NSOffState, NSOnState);
begin
if ownerData and Assigned(listView) and (ARow>=0) and (ARow < listView.Items.Count) then
IsChecked := BoolState[listView.Items[ARow].Checked]
else
IsChecked := BoolState[checkedIdx.containsIndex(ARow)];
Result := true;
end;
function TLCLListViewCallback.GetItemImageAt(ARow, ACol: Integer;
var imgIdx: Integer): Boolean;
begin
Result := (ACol >= 0) and (ACol < listView.ColumnCount)
and (ARow >= 0) and (ARow < listView.Items.Count);
if not Result then Exit;
if ACol = 0 then
imgIdx := listView.Items[ARow].ImageIndex
else
begin
dec(ACol);
if (ACol >=0) and (ACol < listView.Items[ARow].SubItems.Count) then
imgIdx := listView.Items[ARow].SubItemImages[ACol];
end;
end;
type
TSmallImagesAccess = class(TCustomListView);
function TLCLListViewCallback.GetImageFromIndex(imgIdx: Integer): NSImage;
var
bmp : TBitmap;
lst : TCustomImageList;
x,y : integer;
img : NSImage;
rep : NSBitmapImageRep;
cb : TCocoaBitmap;
begin
lst := TSmallImagesAccess(listView).SmallImages;
bmp := TBitmap.Create;
try
lst.GetBitmap(imgIdx, bmp);
if bmp.Handle = 0 then begin
Result := nil;
Exit;
end;
// Bitmap Handle should be nothing but TCocoaBitmap
cb := TCocoaBitmap(bmp.Handle);
// There's NSBitmapImageRep in TCocoaBitmap, but it depends on the availability
// of memory buffer stored with TCocoaBitmap. As soon as TCocoaBitmap is freed
// pixels are not available. For this reason, we're making a copy of the bitmapdata
// allowing Cocoa to allocate its own buffer (by passing nil for planes parameter)
rep := NSBitmapImageRep(NSBitmapImageRep.alloc).initWithBitmapDataPlanes_pixelsWide_pixelsHigh__colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel(
nil, // planes, BitmapDataPlanes
Round(cb.ImageRep.size.Width), // width, pixelsWide
Round(cb.ImageRep.size.Height),// height, PixelsHigh
cb.ImageRep.bitsPerSample,// bitsPerSample, bps
cb.ImageRep.samplesPerPixel, // samplesPerPixel, spp
cb.ImageRep.hasAlpha, // hasAlpha
False, // isPlanar
cb.ImageRep.colorSpaceName, // colorSpaceName
cb.ImageRep.bitmapFormat, // bitmapFormat
cb.ImageRep.bytesPerRow, // bytesPerRow
cb.ImageRep.BitsPerPixel //bitsPerPixel
);
System.Move( cb.ImageRep.bitmapData^, rep.bitmapData^, cb.ImageRep.bytesPerRow * Round(cb.ImageRep.size.height));
img := NSImage(NSImage.alloc).initWithSize( rep.size );
img.addRepresentation(rep);
Result := img;
finally
bmp.Free;
end;
end;
procedure TLCLListViewCallback.SetItemTextAt(ARow, ACol: Integer;
const Text: String);
begin
// there's no notifcaiton to be sent to the TCustomListView;
if (ACol<>0) then Exit;
inc(isSetTextFromWS);
try
if (ACol=0) then
if (ARow>=0) and (ARow<listView.Items.Count) then
TProtCustomListView(listView).DoEndEdit(listView.Items[ARow], Text);
finally
dec(isSetTextFromWS);
end;
end;
procedure TLCLListViewCallback.SetItemCheckedAt(ARow, ACol: Integer;
IsChecked: Integer);
var
Msg: TLMNotify;
NMLV: TNMListView;
begin
if IsChecked = NSOnState
then checkedIdx.addIndex(ARow)
else checkedIdx.removeIndex(ARow);
FillChar(Msg{%H-}, SizeOf(Msg), #0);
FillChar(NMLV{%H-}, SizeOf(NMLV), #0);
Msg.Msg := CN_NOTIFY;
NMLV.hdr.hwndfrom := ListView.Handle;
NMLV.hdr.code := LVN_ITEMCHANGED;
NMLV.iItem := ARow;
NMLV.iSubItem := 0;
NMLV.uChanged := LVIF_STATE;
Msg.NMHdr := @NMLV.hdr;
LCLMessageGlue.DeliverMessage(ListView, Msg);
end;
procedure TLCLListViewCallback.tableSelectionChange(NewSel: Integer; Added, Removed: NSIndexSet);
var
Msg: TLMNotify;
NMLV: TNMListView;
procedure RunIndex(idx: NSIndexSet);
var
buf : array [0..256-1] of NSUInteger;
rng : NSRange;
cnt : Integer;
i : Integer;
itm : NSUInteger;
begin
rng.location := idx.firstIndex;
repeat
rng.length := idx.lastIndex - rng.location + 1;
cnt := idx.getIndexes_maxCount_inIndexRange(@buf[0], length(buf), @rng);
for i := 0 to cnt - 1 do begin
NMLV.iItem := buf[i];
LCLMessageGlue.DeliverMessage(ListView, Msg);
end;
if cnt < length(buf) then cnt := 0
else rng.location := buf[cnt-1]+1;
until cnt = 0;
end;
begin
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TLCLListViewCallback.SelectionChanged] NewSel=%d', [NewSel]));
{$ENDIF}
FillChar(Msg{%H-}, SizeOf(Msg), #0);
FillChar(NMLV{%H-}, SizeOf(NMLV), #0);
Msg.Msg := CN_NOTIFY;
NMLV.hdr.hwndfrom := ListView.Handle;
NMLV.hdr.code := LVN_ITEMCHANGED;
NMLV.iSubItem := 0;
NMLV.uChanged := LVIF_STATE;
Msg.NMHdr := @NMLV.hdr;
if Removed.count>0 then
begin
NMLV.uNewState := 0;
NMLV.uOldState := LVIS_SELECTED;
RunIndex( Removed );
end;
if Added.count > 0 then begin
NMLV.uNewState := LVIS_SELECTED;
NMLV.uOldState := 0;
RunIndex( Added );
end;
{if NewSel >= 0 then
begin
NMLV.iItem := NewSel;
NMLV.uNewState := LVIS_SELECTED;
end
else
begin
NMLV.iItem := 0;
NMLV.uNewState := 0;
NMLV.uOldState := LVIS_SELECTED;
end;
LCLMessageGlue.DeliverMessage(ListView, Msg);}
end;
procedure TLCLListViewCallback.ColumnClicked(ACol: Integer);
var
Msg: TLMNotify;
NMLV: TNMListView;
begin
FillChar(Msg{%H-}, SizeOf(Msg), #0);
FillChar(NMLV{%H-}, SizeOf(NMLV), #0);
Msg.Msg := CN_NOTIFY;
NMLV.hdr.hwndfrom := ListView.Handle;
NMLV.hdr.code := LVN_COLUMNCLICK;
NMLV.iSubItem := ACol;
NMLV.uChanged := 0;
Msg.NMHdr := @NMLV.hdr;
LCLMessageGlue.DeliverMessage(ListView, Msg);
end;
procedure TLCLListViewCallback.DrawRow(rowidx: Integer; ctx: TCocoaContext;
const r: TRect; state: TOwnerDrawState);
begin
// todo: check for custom draw listviews event
end;
procedure TLCLListViewCallback.GetRowHeight(rowidx: Integer; var h: Integer);
begin
end;
{ TCocoaWSTrackBar }
{------------------------------------------------------------------------------
Method: TCocoaWSTrackBar.CreateHandle
Params: AWinControl - LCL control
AParams - Creation parameters
Returns: Handle to the control in Carbon interface
Creates new track bar with the specified parameters
------------------------------------------------------------------------------}
class function TCocoaWSTrackBar.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle;
var
lResult: TCocoaSlider;
begin
lResult := TCocoaSlider.alloc.lclInitWithCreateParams(AParams);
if Assigned(lResult) then
begin
lResult.callback := TLCLCommonCallback.Create(lResult, AWinControl);
lResult.setTarget(lResult);
lResult.setAction(objcselector('sliderAction:'));
end;
Result := TLCLIntfHandle(lResult);
end;
{------------------------------------------------------------------------------
Method: TCocoaWSTrackBar.ApplyChanges
Params: ATrackBar - LCL custom track bar
Sets the parameters (Min, Max, Position, Ticks) of slider
------------------------------------------------------------------------------}
class procedure TCocoaWSTrackBar.ApplyChanges(const ATrackBar: TCustomTrackBar);
var
lSlider: TCocoaSlider;
lTickCount, lTrackBarLength: Integer;
begin
if not Assigned(ATrackBar) or not ATrackBar.HandleAllocated then Exit;
lSlider := TCocoaSlider(ATrackBar.Handle);
lSlider.setMaxValue(ATrackBar.Max);
lSlider.setMinValue(ATrackBar.Min);
lSlider.setIntValue(ATrackBar.Position);
lSlider.intval := ATrackBar.Position;
lSlider.setContinuous(true);
lSlider.setAltIncrementValue(1); // forcing the slider to switch by 1 by the keyboard
// Ticks
if ATrackBar.TickStyle = tsAuto then
begin
// this should only apply to Auto
// and for Manual it should drawn manually
if ATrackBar.Frequency <> 0 then
lTickCount := (ATrackBar.Max-ATrackBar.Min) div ATrackBar.Frequency + 1
else
lTickCount := (ATrackBar.Max-ATrackBar.Min);
// Protection from too frequent ticks.
// 1024 is a number of "too much" ticks, based on a common
// screen resolution 1024 x 768
// Protects ticks from "disappearing" when trackbar is resized
// and is temporary too narrow to fit the trackbar
if TickCount > 1024 then
begin
if ATrackBar.Orientation = trHorizontal then
lTrackBarLength := ATrackBar.Width
else
lTrackBarLength := ATrackBar.Height;
lTickCount := Min(lTickCount, lTrackBarLength);
end;
end else if ATrackBar.TickStyle = tsManual then
begin
lTickCount := 2;
end else
lTickCount := 0;
lSlider.lclSetManTickDraw(ATrackBar.TickStyle = tsManual);
lSlider.setNumberOfTickMarks(lTickCount);
if ATrackBar.TickMarks = tmTopLeft then
lSlider.setTickMarkPosition(NSTickMarkAbove)
else
lSlider.setTickMarkPosition(NSTickMarkBelow);
lSlider.setNeedsDisplay_(true);
end;
{------------------------------------------------------------------------------
Method: TCocoaWSTrackBar.GetPosition
Params: ATrackBar - LCL custom track bar
Returns: Position of slider
------------------------------------------------------------------------------}
class function TCocoaWSTrackBar.GetPosition(const ATrackBar: TCustomTrackBar
): integer;
var
lSlider: TCocoaSlider;
begin
if not Assigned(ATrackBar) or not ATrackBar.HandleAllocated then
begin
Result := 0;
Exit;
end;
lSlider := TCocoaSlider(ATrackBar.Handle);
Result := lSlider.intValue();
end;
{------------------------------------------------------------------------------
Method: TCocoaWSTrackBar.SetPosition
Params: ATrackBar - LCL custom track bar
NewPosition - New position
Sets the position of slider
------------------------------------------------------------------------------}
class procedure TCocoaWSTrackBar.SetPosition(const ATrackBar: TCustomTrackBar;
const NewPosition: integer);
var
lSlider: TCocoaSlider;
begin
if not Assigned(ATrackBar) or not ATrackBar.HandleAllocated then Exit;
lSlider := TCocoaSlider(ATrackBar.Handle);
lSlider.setIntValue(ATrackBar.Position);
end;
// Cocoa auto-detects the orientation based on width/height and there seams
// to be no way to force it
class procedure TCocoaWSTrackBar.SetOrientation(const ATrackBar: TCustomTrackBar;
const AOrientation: TTrackBarOrientation);
begin
if not Assigned(ATrackBar) or not ATrackBar.HandleAllocated then Exit;
if (AOrientation = trHorizontal) and (ATrackBar.Height >= ATrackBar.Width) then
ATrackBar.Width := ATrackBar.Height + 1
else if (AOrientation = trVertical) and (ATrackBar.Width >= ATrackBar.Height) then
ATrackBar.Height := ATrackBar.Width + 1;
end;
class procedure TCocoaWSTrackBar.SetTick(const ATrackBar: TCustomTrackBar; const ATick: integer);
var
lSlider: TCocoaSlider;
begin
if not Assigned(ATrackBar) or not ATrackBar.HandleAllocated then Exit;
lSlider := TCocoaSlider(ATrackBar.Handle);
lSlider.lclAddManTick(ATick);
end;
class procedure TCocoaWSTrackBar.GetPreferredSize(
const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer;
WithThemeSpace: Boolean);
var
lSlider : TCocoaSlider;
trk : TCustomTrackBar;
frm : NSRect;
begin
if not Assigned(AWinControl) or not AWinControl.HandleAllocated then Exit;
trk := TCustomTrackBar(AWinControl);
lSlider := TCocoaSlider(AWinControl.Handle);
frm := lSlider.frame;
try
if trk.Orientation = trVertical then
lSlider.setFrame(NSMakeRect(0,0,5,10))
else
lSlider.setFrame(NSMakeRect(0,0,10,5));
TCocoaWSWinControl.GetPreferredSize(AWinControl,PreferredWidth, PreferredHeight, WithThemeSpace);
if trk.Orientation = trVertical then
PreferredHeight := 0
else
PreferredWidth := 0;
finally
lSlider.setFrame(frm);
end;
end;
end.
| 34.349479 | 212 | 0.752669 |
c330c9ba0ee0be5d6aa03548c4b56c8ce061c9ff | 4,463 | pas | Pascal | Source/Components/ksInspectorFileListForm.pas | khongten001/MonkeyBuilder | d7c168e1c2840404fb6cf8a8bd2cd49afe98050f | [
"MIT"
]
| 25 | 2020-04-16T09:42:28.000Z | 2022-02-14T13:52:54.000Z | Source/Components/ksInspectorFileListForm.pas | khongten001/MonkeyBuilder | d7c168e1c2840404fb6cf8a8bd2cd49afe98050f | [
"MIT"
]
| 4 | 2020-11-14T09:11:14.000Z | 2022-01-04T15:32:24.000Z | Source/Components/ksInspectorFileListForm.pas | khongten001/MonkeyBuilder | d7c168e1c2840404fb6cf8a8bd2cd49afe98050f | [
"MIT"
]
| 4 | 2020-11-24T03:00:49.000Z | 2022-01-16T18:32:28.000Z | unit ksInspectorFileListForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, ksInspector, Vcl.ExtCtrls, System.ImageList, Vcl.ImgList,
System.Actions, Vcl.ActnList, JvImageList, JvExStdCtrls, JvButton, JvCtrls;
type
TfrmKsInspectorFileList = class(TForm)
Panel1: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Button3: TButton;
Button4: TButton;
Panel5: TPanel;
lbFiles: TListBox;
Panel6: TPanel;
Bevel2: TBevel;
Panel7: TPanel;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Bevel1: TBevel;
Panel2: TPanel;
Edit1: TEdit;
Bevel3: TBevel;
Bevel4: TBevel;
JvImgBtn1: TJvImgBtn;
ActionList1: TActionList;
actReplace: TAction;
actAdd: TAction;
actDelete: TAction;
actDeleteInvalidPaths: TAction;
Panel8: TPanel;
JvImgBtn2: TJvImgBtn;
JvImgBtn3: TJvImgBtn;
actMoveUp: TAction;
actMoveDown: TAction;
FileOpenDialog1: TFileOpenDialog;
procedure lbFilesClick(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure actReplaceExecute(Sender: TObject);
procedure actAddExecute(Sender: TObject);
procedure actDeleteExecute(Sender: TObject);
procedure actMoveUpExecute(Sender: TObject);
procedure actMoveDownExecute(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure JvImgBtn1Click(Sender: TObject);
private
FFileList: string;
FTitle: string;
procedure UpdateActionStates;
{ Private declarations }
protected
procedure DoShow; override;
public
property FileList: string read FFileList write FFileList;
property Title: string read FTitle write FTitle;
{ Public declarations }
end;
implementation
uses JclStrings;
{$R *.dfm}
{ TfrmKsInspectorFileList }
procedure TfrmKsInspectorFileList.actAddExecute(Sender: TObject);
begin
lbFiles.Items.Add(Edit1.Text);
Edit1.Text := '';
end;
procedure TfrmKsInspectorFileList.actDeleteExecute(Sender: TObject);
begin
lbFiles.DeleteSelected;
end;
procedure TfrmKsInspectorFileList.actMoveDownExecute(Sender: TObject);
var
i: Integer;
begin
i := lbFiles.ItemIndex + 1;
if i < lbFiles.Items.Count then
lbFiles.Items.Exchange(i, i - 1);
lbFiles.SetFocus;
end;
procedure TfrmKsInspectorFileList.actMoveUpExecute(Sender: TObject);
var
i: integer;
begin
i := lbFiles.ItemIndex;
if i > 0 then
lbFiles.Items.Exchange(i, i - 1);
lbFiles.SetFocus;
end;
procedure TfrmKsInspectorFileList.actReplaceExecute(Sender: TObject);
begin
lbFiles.Items[lbFiles.ItemIndex] := Trim(Edit1.Text);
end;
procedure TfrmKsInspectorFileList.Button3Click(Sender: TObject);
var
AStr: string;
begin
FFileList := '';
for AStr in lbFiles.Items do
FFileList := FFileList + AStr+';';
FFileList := StrEnsureNoSuffix(';', FFileList);
end;
procedure TfrmKsInspectorFileList.Button9Click(Sender: TObject);
begin
lbFiles.DeleteSelected;
end;
procedure TfrmKsInspectorFileList.DoShow;
var
AStrings: TStrings;
ICount: integer;
begin
inherited;
Caption := FTitle;
AStrings := TStringList.Create;
try
AStrings.Text := StringReplace(FFileList, ';', #13, [rfReplaceAll]);
for ICount := 0 to AStrings.Count-1 do
begin
AStrings[ICount] := StrEnsureNoPrefix('"', AStrings[ICount]);
AStrings[ICount] := StrEnsureNoSuffix('"', AStrings[ICount]);
end;
lbFiles.Items.Assign(AStrings);
finally
AStrings.Free;
end;
end;
procedure TfrmKsInspectorFileList.Edit1Change(Sender: TObject);
begin
UpdateActionStates;
end;
procedure TfrmKsInspectorFileList.JvImgBtn1Click(Sender: TObject);
begin
if FileOpenDialog1.Execute then
Edit1.Text := FileOpenDialog1.Filename;
end;
procedure TfrmKsInspectorFileList.lbFilesClick(Sender: TObject);
begin
Edit1.Text := '';
if lbFiles.ItemIndex > -1 then
Edit1.Text := lbFiles.Items[lbFiles.ItemIndex];
UpdateActionStates;
end;
procedure TfrmKsInspectorFileList.UpdateActionStates;
begin
actAdd.Enabled := (lbFiles.Items.IndexOf(Trim(Edit1.Text)) = -1) and (Trim(Edit1.Text) <> '');
actReplace.Enabled := (Trim(Edit1.Text) <> '') and (lbFiles.SelCount = 1);
actDelete.Enabled := lbFiles.SelCount > 0;
actMoveUp.Enabled := lbFiles.SelCount > 0;
actMoveDown.Enabled := lbFiles.SelCount > 0;
end;
end.
| 24.932961 | 111 | 0.729554 |
fceaea4015021ee2d3526e37e549838503f8f10d | 18,081 | pas | Pascal | disk/midas/src/midas/midasdll.pas | visualizersdotnl/chipchop2-486 | 3f17d63ce852f3162b9bea5924ac59d0ea924701 | [
"MIT"
]
| null | null | null | disk/midas/src/midas/midasdll.pas | visualizersdotnl/chipchop2-486 | 3f17d63ce852f3162b9bea5924ac59d0ea924701 | [
"MIT"
]
| 4 | 2015-02-26T10:26:29.000Z | 2015-09-14T16:30:44.000Z | disk/midas/src/midas/midasdll.pas | visualizersdotnl/chipchop2-486 | 3f17d63ce852f3162b9bea5924ac59d0ea924701 | [
"MIT"
]
| null | null | null | {* midasdll.pas
*
* MIDAS DLL programming interface Delphi interface unit
*
* $Id: midasdll.pas,v 1.5 1997/07/31 14:30:58 pekangas Exp $
*
* Copyright 1996,1997 Housemarque Inc
*
* This file is part of MIDAS Digital Audio System, and may only be
* used, modified and distributed under the terms of the MIDAS
* Digital Audio System license, "license.txt". By continuing to use,
* modify or distribute this file you indicate that you have
* read the license and understand and accept it fully.
*}
unit midasdll;
interface
uses wintypes;
const
{ enum MIDASoptions }
MIDAS_OPTION_NONE = 0;
MIDAS_OPTION_MIXRATE = 1;
MIDAS_OPTION_OUTPUTMODE = 2;
MIDAS_OPTION_MIXBUFLEN = 3;
MIDAS_OPTION_MIXBUFBLOCKS = 4;
MIDAS_OPTION_DSOUND_MODE = 5;
MIDAS_OPTION_DSOUND_HWND = 6;
MIDAS_OPTION_DSOUND_OBJECT = 7;
MIDAS_OPTION_DSOUND_BUFLEN = 8;
MIDAS_OPTION_16BIT_ULAW_AUTOCONVERT = 9;
MIDAS_OPTION_FILTER_MODE = 10;
MIDAS_OPTION_MIXING_MODE = 11;
MIDAS_OPTION_DEFAULT_STEREO_SEPARATION = 12;
MIDAS_OPTION_FORCE_NO_SOUND = 13;
{ enum MIDASmodes }
MIDAS_MODE_NONE = 0;
MIDAS_MODE_MONO = 1;
MIDAS_MODE_STEREO = 2;
MIDAS_MODE_8BIT = 4;
MIDAS_MODE_16BIT = 8;
MIDAS_MODE_8BIT_MONO = MIDAS_MODE_8BIT or MIDAS_MODE_MONO;
MIDAS_MODE_8BIT_STEREO = MIDAS_MODE_8BIT or MIDAS_MODE_STEREO;
MIDAS_MODE_16BIT_MONO = MIDAS_MODE_16BIT or MIDAS_MODE_MONO;
MIDAS_MODE_16BIT_STEREO = MIDAS_MODE_16BIT or MIDAS_MODE_STEREO;
{ enum MIDASsampleTypes }
MIDAS_SAMPLE_NONE = 0;
MIDAS_SAMPLE_8BIT_MONO = 1;
MIDAS_SAMPLE_16BIT_MONO = 2;
MIDAS_SAMPLE_8BIT_STEREO = 3;
MIDAS_SAMPLE_16BIT_STEREO = 4;
MIDAS_SAMPLE_ADPCM_MONO = 5;
MIDAS_SAMPLE_ADPCM_STEREO = 6;
MIDAS_SAMPLE_ULAW_MONO = 7;
MIDAS_SAMPLE_ULAW_STEREO = 8;
{ enum MIDASloop }
MIDAS_LOOP_NO = 0;
MIDAS_LOOP_YES = 1;
{ enum MIDASpanning }
MIDAS_PAN_LEFT = -64;
MIDAS_PAN_MIDDLE = 0;
MIDAS_PAN_RIGHT = 64;
MIDAS_PAN_SURROUND = $80;
{ enum MIDASchannels }
MIDAS_CHANNEL_AUTO = $FFFF;
MIDAS_ILLEGAL_CHANNEL = $FFFF;
{ enum MIDASdsoundModes }
MIDAS_DSOUND_DISABLED = 0;
MIDAS_DSOUND_STREAM = 1;
MIDAS_DSOUND_PRIMARY = 2;
MIDAS_DSOUND_FORCE_STREAM = 3;
{ enum MIDASpositions }
MIDAS_POSITION_DEFAULT = $FFFFFFFF;
{ enum MIDASfilterModes }
MIDAS_FILTER_NONE = 0;
MIDAS_FILTER_LESS = 1;
MIDAS_FILTER_MORE = 2;
MIDAS_FILTER_AUTO = 3;
{ enum MIDASechoFilterTypes }
MIDAS_ECHO_FILTER_NONE = 0;
MIDAS_ECHO_FILTER_LOWPASS = 1;
MIDAS_ECHO_FILTER_HIGHPASS = 2;
{ enum MIDASmixingModes }
MIDAS_MIX_NORMAL_QUALITY = 0;
MIDAS_MIX_HIGH_QUALITY = 1;
{ enum MIDASsamplePlayStatus }
MIDAS_SAMPLE_STOPPED = 0;
MIDAS_SAMPLE_PLAYING = 1;
type MIDASmoduleInfo =
record
songName : array[0..31] of char;
songLength : integer;
numPatterns : integer;
numInstruments : integer;
numChannels : integer;
end;
PMIDASmoduleInfo = ^MIDASmoduleInfo;
type MIDASinstrumentInfo =
record
instName : array[0..31] of char;
end;
PMIDASinstrumentInfo = ^MIDASinstrumentInfo;
type MIDASplayStatus =
record
position : dword;
pattern : dword;
row : dword;
syncInfo : integer;
songLoopCount : dword
end;
PMIDASplayStatus = ^MIDASplayStatus;
type MIDASecho =
record
delay : dword;
gain : integer;
reverseChannels : integer;
filterType : dword;
end;
PMIDASecho = ^MIDASecho;
type MIDASechoSet =
record
feedback : integer;
gain : integer;
numEchoes : integer;
echoes : PMIDASecho;
end;
PMIDASechoSet = ^MIDASechoSet;
MIDASmodule = pointer;
MIDASmodulePlayHandle = DWORD;
MIDASsample = DWORD;
MIDASsamplePlayHandle = DWORD;
MIDASstreamHandle = pointer;
Pbyte = ^byte;
MIDASechoHandle = pointer;
function MIDASgetLastError : integer; stdcall;
function MIDASgetErrorMessage(errorCode : integer) : PChar; stdcall;
function MIDASstartup : boolean; stdcall;
function MIDASconfig : boolean; stdcall;
function MIDASloadConfig(fileName : PChar) : boolean; stdcall;
function MIDASsaveConfig(fileName : PChar) : boolean; stdcall;
function MIDASreadConfigRegistry(key : dword; subKey : PChar) : boolean; stdcall;
function MIDASwriteConfigRegistry(key : dword; subKey : PChar) : boolean; stdcall;
function MIDASinit : boolean; stdcall;
function MIDASsetOption(option : integer; value : dword) : boolean; stdcall;
function MIDASgetOption(option : integer) : dword; stdcall;
function MIDASclose : boolean; stdcall;
function MIDASsuspend : boolean; stdcall;
function MIDASresume : boolean; stdcall;
function MIDASopenChannels(numChannels : integer) : boolean; stdcall;
function MIDAScloseChannels : boolean; stdcall;
function MIDASsetAmplification(amplification : dword) : boolean; stdcall;
function MIDASstartBackgroundPlay(pollRate : dword) : boolean; stdcall;
function MIDASstopBackgroundPlay : boolean; stdcall;
function MIDASpoll : boolean; stdcall;
function MIDASlock : boolean; stdcall;
function MIDASunlock : boolean; stdcall;
function MIDASgetVersionString : PChar; stdcall;
function MIDASallocateChannel : dword; stdcall;
function MIDASfreeChannel(channel : dword) : boolean; stdcall;
function MIDASloadModule(fileName : PChar) : MIDASmodule; stdcall;
function MIDASplayModule(module : MIDASmodule; loopSong : boolean) :
MIDASmodulePlayHandle; stdcall;
function MIDASplayModuleSection(module : MIDASmodule; startPos, endPos,
restartPos : dword; loopSong : boolean) : MIDASmodulePlayHandle; stdcall;
function MIDASstopModule(playHandle : MIDASmodulePlayHandle) : boolean;
stdcall;
function MIDASfreeModule(module : MIDASmodule) : boolean; stdcall;
function MIDASgetPlayStatus(playHandle : MIDASmodulePlayHandle;
status : PMIDASplayStatus) : boolean; stdcall;
function MIDASsetPosition(playHandle : MIDASmodulePlayHandle;
newPosition : integer) : boolean; stdcall;
function MIDASsetMusicVolume(playHandle : MIDASmodulePlayHandle;
volume : dword) : boolean; stdcall;
function MIDASgetModuleInfo(module : MIDASmodule; info : PMIDASmoduleInfo) :
boolean; stdcall;
function MIDASgetInstrumentInfo(module : MIDASmodule; instNum : integer;
info : PMIDASinstrumentInfo) : boolean; stdcall;
function MIDASfadeMusicChannel(playHandle : MIDASmodulePlayHandle; channel,
fade : dword) : boolean; stdcall;
function MIDASloadRawSample(fileName : PChar; sampleType,
loopSample : integer) : MIDASsample; stdcall;
function MIDASloadWaveSample(fileName : PChar; loopSample : integer) :
MIDASsample; stdcall;
function MIDASfreeSample(sample : MIDASsample) : boolean; stdcall;
function MIDASallocAutoEffectChannels(numChannels : dword) : boolean; stdcall;
function MIDASfreeAutoEffectChannels : boolean; stdcall;
function MIDASplaySample(sample : MIDASsample; channel : dword;
priority : integer; rate, volume : dword; panning : integer) :
MIDASsamplePlayHandle;
stdcall;
function MIDASstopSample(sample : MIDASsamplePlayHandle) : boolean; stdcall;
function MIDASsetSampleRate(sample : MIDASsamplePlayHandle; rate : dword) :
boolean; stdcall;
function MIDASsetSampleVolume(sample : MIDASsamplePlayHandle; volume : dword)
: boolean; stdcall;
function MIDASsetSamplePanning(sample : MIDASsamplePlayHandle;
panning : integer) : boolean; stdcall;
function MIDASsetSamplePriority(sample : MIDASsamplePlayHandle;
priority : integer) : boolean; stdcall;
function MIDASgetSamplePlayStatus(sample : MIDASsamplePlayHandle) : dword;
stdcall;
function MIDASplayStreamFile(fileName : PChar;
sampleType : dword; sampleRate : dword; bufferLength : dword;
loopStream : integer) : MIDASstreamHandle; stdcall;
function MIDASplayStreamWaveFile(fileName : PChar; bufferLength : dword;
loopStream : integer) : MIDASstreamHandle; stdcall;
function MIDASstopStream(stream : MIDASstreamHandle) : boolean; stdcall;
function MIDASplayStreamPolling(sampleType : dword;
sampleRate : dword; bufferLength : dword) : MIDASstreamHandle; stdcall;
function MIDASfeedStreamData(stream : MIDASstreamHandle; data : Pbyte;
numBytes : dword; feedAll : boolean) : dword; stdcall;
function MIDASsetStreamRate(stream : MIDASstreamHandle; rate : dword)
: boolean; stdcall;
function MIDASsetStreamVolume(stream : MIDASstreamHandle; volume : dword)
: boolean; stdcall;
function MIDASsetStreamPanning(stream : MIDASstreamHandle; panning : integer)
: boolean; stdcall;
function MIDASgetStreamBytesBuffered(stream : MIDASstreamHandle) : boolean;
stdcall;
function MIDASpauseStream(stream : MIDASstreamHandle) : boolean; stdcall;
function MIDASresumeStream(stream : MIDASstreamHandle ) : boolean; stdcall;
function MIDASaddEchoEffect(echoSet : PMIDASechoSet) : MIDASechoHandle;
stdcall;
function MIDASremoveEchoEffect(echoHandle : MIDASechoHandle) : boolean;
stdcall;
implementation
function MIDASgetLastError : integer;
stdcall; external 'midas11.dll' name '_MIDASgetLastError@0';
function MIDASgetErrorMessage(errorCode : integer) : PChar;
stdcall; external 'midas11.dll' name '_MIDASgetErrorMessage@4';
function MIDASstartup : boolean;
stdcall; external 'midas11.dll' name '_MIDASstartup@0';
function MIDASconfig : boolean;
stdcall; external 'midas11.dll' name '_MIDASconfig@0';
function MIDASloadConfig(fileName : PChar) : boolean;
stdcall; external 'midas11.dll' name '_MIDASloadConfig@4';
function MIDASsaveConfig(fileName : PChar) : boolean;
stdcall; external 'midas11.dll' name '_MIDASsaveConfig@4';
function MIDASreadConfigRegistry(key : dword; subKey : PChar) : boolean;
stdcall; external 'midas11.dll' name '_MIDASreadConfigRegistry@8';
function MIDASwriteConfigRegistry(key : dword; subKey : PChar) : boolean;
stdcall; external 'midas11.dll' name '_MIDASwriteConfigRegistry@8';
function MIDASinit : boolean;
stdcall; external 'midas11.dll' name '_MIDASinit@0';
function MIDASsetOption(option : integer; value : dword) : boolean;
stdcall; external 'midas11.dll' name '_MIDASsetOption@8';
function MIDASgetOption(option : integer) : dword;
stdcall; external 'midas11.dll' name '_MIDASgetOption@4';
function MIDASclose : boolean;
stdcall; external 'midas11.dll' name '_MIDASclose@0';
function MIDASsuspend : boolean;
stdcall; external 'midas11.dll' name '_MIDASsuspend@0';
function MIDASresume : boolean; stdcall;
stdcall; external 'midas11.dll' name '_MIDASresume@0';
function MIDASopenChannels(numChannels : integer) : boolean;
stdcall; external 'midas11.dll' name '_MIDASopenChannels@4';
function MIDAScloseChannels : boolean;
stdcall; external 'midas11.dll' name '_MIDAScloseChannels@0';
function MIDASsetAmplification(amplification : dword) : boolean;
stdcall; external 'midas11.dll' name '_MIDASsetAmplification@4';
function MIDASstartBackgroundPlay(pollRate : dword) : boolean;
stdcall; external 'midas11.dll' name '_MIDASstartBackgroundPlay@4';
function MIDASstopBackgroundPlay : boolean;
stdcall; external 'midas11.dll' name '_MIDASstopBackgroundPlay@0';
function MIDASpoll : boolean;
stdcall; external 'midas11.dll' name '_MIDASpoll@0';
function MIDASlock : boolean;
stdcall; external 'midas11.dll' name '_MIDASlock@0';
function MIDASunlock : boolean;
stdcall; external 'midas11.dll' name '_MIDASunlock@0';
function MIDASgetVersionString : PChar;
stdcall; external 'midas11.dll' name '_MIDASgetVersionString@0';
function MIDASallocateChannel : dword;
stdcall; external 'midas11.dll' name '_MIDASallocateChannel@0';
function MIDASfreeChannel(channel : dword) : boolean;
stdcall; external 'midas11.dll' name '_MIDASfreeChannel@4';
function MIDASloadModule(fileName : PChar) : MIDASmodule;
stdcall; external 'midas11.dll' name '_MIDASloadModule@4';
function MIDASplayModule(module : MIDASmodule; loopSong : boolean) :
MIDASmodulePlayHandle;
stdcall; external 'midas11.dll' name '_MIDASplayModule@8';
function MIDASplayModuleSection(module : MIDASmodule; startPos, endPos,
restartPos : dword; loopSong : boolean) : MIDASmodulePlayHandle;
stdcall; external 'midas11.dll' name '_MIDASplayModuleSection@20';
function MIDASstopModule(playHandle : MIDASmodulePlayHandle) : boolean ;
stdcall; external 'midas11.dll' name '_MIDASstopModule@4';
function MIDASfreeModule(module : MIDASmodule) : boolean;
stdcall; external 'midas11.dll' name '_MIDASfreeModule@4';
function MIDASgetPlayStatus(playHandle : MIDASmodulePlayHandle;
status : PMIDASplayStatus) : boolean;
stdcall; external 'midas11.dll' name '_MIDASgetPlayStatus@8';
function MIDASsetPosition(playHandle : MIDASmodulePlayHandle;
newPosition : integer) : boolean;
stdcall; external 'midas11.dll' name '_MIDASsetPosition@8';
function MIDASsetMusicVolume(playHandle : MIDASmodulePlayHandle;
volume : dword) : boolean;
stdcall; external 'midas11.dll' name '_MIDASsetMusicVolume@8';
function MIDASgetModuleInfo(module : MIDASmodule; info : PMIDASmoduleInfo) :
boolean;
stdcall; external 'midas11.dll' name '_MIDASgetModuleInfo@8';
function MIDASgetInstrumentInfo(module : MIDASmodule; instNum : integer;
info : PMIDASinstrumentInfo) : boolean;
stdcall; external 'midas11.dll' name '_MIDASgetInstrumentInfo@12';
function MIDASfadeMusicChannel(playHandle : MIDASmodulePlayHandle; channel,
fade : dword) : boolean;
stdcall; external 'midas11.dll' name '_MIDASfadeMusicChannel@12';
function MIDASloadRawSample(fileName : PChar; sampleType,
loopSample : integer) : MIDASsample;
stdcall; external 'midas11.dll' name '_MIDASloadRawSample@12';
function MIDASloadWaveSample(fileName : PChar; loopSample : integer) :
MIDASsample;
stdcall; external 'midas11.dll' name '_MIDASloadWaveSample@8';
function MIDASfreeSample(sample : MIDASsample) : boolean;
stdcall; external 'midas11.dll' name '_MIDASfreeSample@4';
function MIDASallocAutoEffectChannels(numChannels : dword) : boolean;
stdcall; external 'midas11.dll' name '_MIDASallocAutoEffectChannels@4';
function MIDASfreeAutoEffectChannels : boolean;
stdcall; external 'midas11.dll' name '_MIDASfreeAutoEffectChannels@0';
function MIDASplaySample(sample : midasSample; channel : dword;
priority : integer; rate, volume : dword; panning : integer) :
MIDASsamplePlayHandle;
stdcall; external 'midas11.dll' name '_MIDASplaySample@24';
function MIDASstopSample(sample : MIDASsamplePlayHandle) : boolean;
stdcall; external 'midas11.dll' name '_MIDASstopSample@4';
function MIDASsetSampleRate(sample : MIDASsamplePlayHandle; rate : dword) :
boolean;
stdcall; external 'midas11.dll' name '_MIDASsetSampleRate@8';
function MIDASsetSampleVolume(sample : MIDASsamplePlayHandle; volume : dword)
: boolean;
stdcall; external 'midas11.dll' name '_MIDASsetSampleVolume@8';
function MIDASsetSamplePanning(sample : MIDASsamplePlayHandle;
panning : integer) : boolean;
stdcall; external 'midas11.dll' name '_MIDASsetSamplePanning@8';
function MIDASsetSamplePriority(sample : MIDASsamplePlayHandle;
priority : integer) : boolean;
stdcall; external 'midas11.dll' name '_MIDASsetSamplePriority@8';
function MIDASgetSamplePlayStatus(sample : MIDASsamplePlayHandle) : dword;
stdcall; external 'midas11.dll' name '_MIDASgetSamplePlayStatus@4';
function MIDASplayStreamFile(fileName : PChar;
sampleType : dword; sampleRate : dword; bufferLength : dword;
loopStream : integer) : MIDASstreamHandle;
stdcall; external 'midas11.dll' name '_MIDASplayStreamFile@20';
function MIDASplayStreamWaveFile(fileName : PChar; bufferLength : dword;
loopStream : integer) : MIDASstreamHandle;
stdcall; external 'midas11.dll' name '_MIDASplayStreamWaveFile@12';
function MIDASstopStream(stream : MIDASstreamHandle) : boolean;
stdcall; external 'midas11.dll' name '_MIDASstopStream@4';
function MIDASplayStreamPolling(sampleType : dword;
sampleRate : dword; bufferLength : dword) : MIDASstreamHandle;
stdcall; external 'midas11.dll' name '_MIDASplayStreamPolling@12';
function MIDASfeedStreamData(stream : MIDASstreamHandle; data : Pbyte;
numBytes : dword; feedAll : boolean) : dword;
stdcall; external 'midas11.dll' name '_MIDASfeedStreamData@16';
function MIDASsetStreamRate(stream : MIDASstreamHandle; rate : dword)
: boolean;
stdcall; external 'midas11.dll' name '_MIDASsetStreamRate@8';
function MIDASsetStreamVolume(stream : MIDASstreamHandle; volume : dword)
: boolean;
stdcall; external 'midas11.dll' name '_MIDASsetStreamVolume@8';
function MIDASsetStreamPanning(stream : MIDASstreamHandle; panning : integer)
: boolean;
stdcall; external 'midas11.dll' name '_MIDASsetStreamPanning@8';
function MIDASgetStreamBytesBuffered(stream : MIDASstreamHandle) : boolean;
stdcall; external 'midas11.dll' name '_MIDASgetStreamBytesBuffered@4';
function MIDASpauseStream(stream : MIDASstreamHandle) : boolean;
stdcall; external 'midas11.dll' name '_MIDASpauseStream@4';
function MIDASresumeStream(stream : MIDASstreamHandle ) : boolean;
stdcall; external 'midas11.dll' name '_MIDASresumeStream@4';
function MIDASaddEchoEffect(echoSet : PMIDASechoSet) : MIDASechoHandle;
stdcall; external 'midas11.dll' name '_MIDASaddEchoEffect@4';
function MIDASremoveEchoEffect(echoHandle : MIDASechoHandle) : boolean;
stdcall; external 'midas11.dll' name '_MIDASremoveEchoEffect@4';
BEGIN
END.
{*
* $Log: midasdll.pas,v $
* Revision 1.5 1997/07/31 14:30:58 pekangas
* Added option MIDAS_OPTION_FORCE_NO_SOUND
*
* Revision 1.4 1997/07/31 10:56:48 pekangas
* Renamed from MIDAS Sound System to MIDAS Digital Audio System
*
* Revision 1.3 1997/07/29 16:57:12 pekangas
* Added sample playing status query
*
* Revision 1.2 1997/07/29 16:51:09 pekangas
* Updated for 1.1 beta 1
*
* Revision 1.1 1997/05/23 14:47:44 pekangas
* Initial revision
*
*} | 39.913907 | 82 | 0.753941 |
f1da04b142e6f173bb7cb86ab29e64222c300d9c | 1,428 | dpr | Pascal | packages/Delphi_10.3/TypeB_MessagingHub_MANAGER.dpr | victorgv/TypeB_MessagingHub | ec057c4d0ddc1699d3c2d5ff36bedad70a73b67d | [
"MIT"
]
| null | null | null | packages/Delphi_10.3/TypeB_MessagingHub_MANAGER.dpr | victorgv/TypeB_MessagingHub | ec057c4d0ddc1699d3c2d5ff36bedad70a73b67d | [
"MIT"
]
| null | null | null | packages/Delphi_10.3/TypeB_MessagingHub_MANAGER.dpr | victorgv/TypeB_MessagingHub | ec057c4d0ddc1699d3c2d5ff36bedad70a73b67d | [
"MIT"
]
| null | null | null | program TypeB_MessagingHub_MANAGER;
uses
System.StartUpCopy,
FMX.Forms,
uFmxMain in '..\..\source\TypeB_MessagingHub_MANAGER\uFmxMain.pas' {fmxMain},
uFmxUsers in '..\..\source\TypeB_MessagingHub_MANAGER\uFmxUsers.pas' {fmxUsers},
uFmxControlPanel in '..\..\source\TypeB_MessagingHub_MANAGER\uFmxControlPanel.pas' {fmxControlPanel},
MyLibrary.FormUtil in '..\..\lib\MyDelphiLibrary\source\MyLibrary.FormUtil.pas',
uFmxLogin in '..\..\source\TypeB_MessagingHub_MANAGER\uFmxLogin.pas' {FmxLogin},
MyLibrary.DataModuleMain in '..\..\lib\MyDelphiLibrary\source\MyLibrary.DataModuleMain.pas' {MyLibrary_DataModuleMain: TDataModule},
MyLibrary.FormLogin in '..\..\lib\MyDelphiLibrary\source\FMX\FormLogin\MyLibrary.FormLogin.pas' {MyLibrary_FormLogin},
uDmMain in '..\..\source\TypeB_MessagingHub_MANAGER\uDmMain.pas' {DmMain: TDataModule},
MyLibrary.Core in '..\..\lib\MyDelphiLibrary\source\MyLibrary.Core.pas',
MyLibrary.Session in '..\..\lib\MyDelphiLibrary\source\MyLibrary.Session.pas',
MyLibrary.DMVCF.Connection in '..\..\lib\MyDelphiLibrary\source\DMVCFramework\Client\MyLibrary.DMVCF.Connection.pas',
MyLibrary.UserLanguageStrings in '..\..\lib\MyDelphiLibrary\source\MyLibrary.UserLanguageStrings.pas';
{$R *.res}
begin
Application.Initialize;
DmMain := TDmMain.Create(nil);
try
Application.CreateForm(TfmxMain, fmxMain);
Application.Run;
finally
DmMain.Free;
end;
end.
| 46.064516 | 134 | 0.766106 |
c31d0d9e1eb85fa2ef967203e4e3184c654af5bf | 1,730 | pas | Pascal | hedgewars/uDebug.pas | RobWatlingSF/hedgewars | 74f633d76bf95674f68f6872472bd21825f1f8c0 | [
"Apache-2.0"
]
| null | null | null | hedgewars/uDebug.pas | RobWatlingSF/hedgewars | 74f633d76bf95674f68f6872472bd21825f1f8c0 | [
"Apache-2.0"
]
| null | null | null | hedgewars/uDebug.pas | RobWatlingSF/hedgewars | 74f633d76bf95674f68f6872472bd21825f1f8c0 | [
"Apache-2.0"
]
| null | null | null | (*
* Hedgewars, a free turn based strategy game
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*)
{$INCLUDE "options.inc"}
unit uDebug;
interface
procedure OutError(Msg: shortstring; isFatalError: boolean);
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline;
procedure SDLTry(Assert: boolean; isFatal: boolean);
implementation
uses SDLh, uConsole, uCommands, uConsts;
procedure OutError(Msg: shortstring; isFatalError: boolean);
begin
WriteLnToConsole(Msg);
if isFatalError then
begin
ParseCommand('fatal ' + lastConsoleline, true);
// hint for the 'coverity' source analyzer
// this halt is never actually reached because ParseCommands will halt first
halt(HaltFatalError);
end;
end;
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean);
begin
if not Assert then
OutError(Msg, isFatal)
end;
procedure SDLTry(Assert: boolean; isFatal: boolean);
var s: shortstring;
begin
if not Assert then
begin
s:= SDL_GetError();
OutError(s, isFatal)
end
end;
end.
| 28.360656 | 80 | 0.744509 |
fc3305f8e9ff715866e24809f04c6f921640593e | 690 | pas | Pascal | 10019.pas | felikjunvianto/kfile-uvaoj-submissions | 5bd8b3b413ca8523abe412b0a0545f766f70ce63 | [
"MIT"
]
| null | null | null | 10019.pas | felikjunvianto/kfile-uvaoj-submissions | 5bd8b3b413ca8523abe412b0a0545f766f70ce63 | [
"MIT"
]
| null | null | null | 10019.pas | felikjunvianto/kfile-uvaoj-submissions | 5bd8b3b413ca8523abe412b0a0545f766f70ce63 | [
"MIT"
]
| null | null | null | var n,m,x:longint;
function pangkat(acu:longint):longint;
var x:longint;
begin
pangkat:=1;
for x:=1 to acu do pangkat:=pangkat*16;
end;
function binhex(m:longint):longint;
var temp:string;
x:longint;
begin
str(m,temp);
m:=0;
for x:=1 to length(temp) do m:=m+(ord(temp[x])-ord('0'))*pangkat(x-1);
binhex:=0;
repeat
if m mod 2 = 1 then inc(binhex);
m:=m div 2;
until m=0;
end;
function bindes(m:longint):longint;
begin
bindes:=0;
repeat
if m mod 2 =1 then inc(bindes);
m:=m div 2;
until m=0;
end;
begin
readln(n);
for x:=1 to n do
begin
readln(m);
writeln(bindes(m),' ',binhex(m));
end;
end. | 16.428571 | 73 | 0.582609 |
fc13a7ef62ce83b6fc0eccd2123372107238191c | 117 | pas | Pascal | Native/Delphi/Apps/TicTacToe/TicTacToeLogic/src/Enumerations/TicTacToe_WinnerUnit.pas | jpluimers/bo.codeplex | 787ef3b5a8c6ced0a985361243c48a6c76f5d655 | [
"BSD-3-Clause"
]
| 5 | 2017-05-12T08:03:54.000Z | 2022-02-15T08:23:27.000Z | Native/Delphi/Apps/TicTacToe/TicTacToeLogic/src/Enumerations/TicTacToe_WinnerUnit.pas | jpluimers/bo.codeplex | 787ef3b5a8c6ced0a985361243c48a6c76f5d655 | [
"BSD-3-Clause"
]
| null | null | null | Native/Delphi/Apps/TicTacToe/TicTacToeLogic/src/Enumerations/TicTacToe_WinnerUnit.pas | jpluimers/bo.codeplex | 787ef3b5a8c6ced0a985361243c48a6c76f5d655 | [
"BSD-3-Clause"
]
| null | null | null | unit TicTacToe_WinnerUnit;
interface
type
TWinner = (None, Nought, Cross, Draw);
implementation
end.
| 10.636364 | 41 | 0.683761 |
c3afb5849447df6c6490415379dd168cee64395a | 21,183 | pas | Pascal | fpcdws/dwsConvExprs.pas | noshbar/c_dwscript | c2df9341a9f22d2974d1235f3968a4a3d9f3b32a | [
"Condor-1.1"
]
| 4 | 2018-09-18T07:35:52.000Z | 2021-02-18T18:21:54.000Z | fpcdws/dwsConvExprs.pas | noshbar/c_dwscript | c2df9341a9f22d2974d1235f3968a4a3d9f3b32a | [
"Condor-1.1"
]
| null | null | null | fpcdws/dwsConvExprs.pas | noshbar/c_dwscript | c2df9341a9f22d2974d1235f3968a4a3d9f3b32a | [
"Condor-1.1"
]
| 1 | 2020-10-30T07:24:05.000Z | 2020-10-30T07:24:05.000Z | {**********************************************************************}
{ }
{ "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 Initial Developer of the Original Code is Matthias }
{ Ackermann. For other initial contributors, see contributors.txt }
{ Subsequent portions Copyright Creative IT. }
{ }
{ Current maintainer: Eric Grange }
{ }
{**********************************************************************}
unit dwsConvExprs;
{$I dws.inc}
interface
uses
Variants, SysUtils,
dwsUtils, dwsDataContext, dwsStack, dwsXPlatform, dwsErrors, dwsStrings,
dwsExprs, dwsExprList, dwsConstExprs, dwsSymbols, dwsUnitSymbols;
type
// newType(x)
TConvExpr = class(TUnaryOpExpr)
public
class function WrapWithConvCast(prog : TdwsProgram; const scriptPos : TScriptPos;
toTyp : TTypeSymbol; expr : TTypedExpr;
const reportError : String) : TTypedExpr; static;
function Eval(exec : TdwsExecution) : Variant; override;
end;
// Just wraps with a typ for an invalid conversion expr
// this is used only to keep compiling, the resulting program is not executable
TConvInvalidExpr = class sealed (TConvExpr)
protected
function GetIsConstant : Boolean; override;
public
constructor Create(prog : TdwsProgram; expr : TTypedExpr; toTyp : TTypeSymbol); reintroduce;
end;
// Float(int x)
TConvIntToFloatExpr = class (TUnaryOpFloatExpr)
function EvalAsFloat(exec : TdwsExecution) : Double; override;
end;
// Float(variant x)
TConvVarToFloatExpr = class (TUnaryOpFloatExpr)
function EvalAsFloat(exec : TdwsExecution) : Double; override;
end;
// Integer(variant x)
TConvVarToIntegerExpr = class (TUnaryOpIntExpr)
function EvalAsInteger(exec : TdwsExecution) : Int64; override;
end;
// Integer(ordinal x)
TConvOrdToIntegerExpr = class (TUnaryOpIntExpr)
function EvalAsInteger(exec : TdwsExecution) : Int64; override;
function Optimize(prog : TdwsProgram; exec : TdwsExecution) : TProgramExpr; override;
end;
// String(variant x)
TConvVarToStringExpr = class (TUnaryOpStringExpr)
procedure EvalAsString(exec : TdwsExecution; var Result : UnicodeString); override;
end;
// Boolean(int x)
TConvIntToBoolExpr = class (TUnaryOpBoolExpr)
function EvalAsBoolean(exec : TdwsExecution) : Boolean; override;
end;
// Boolean(float x)
TConvFloatToBoolExpr = class (TUnaryOpBoolExpr)
function EvalAsBoolean(exec : TdwsExecution) : Boolean; override;
end;
// Boolean(variant x)
TConvVarToBoolExpr = class (TUnaryOpBoolExpr)
function EvalAsBoolean(exec : TdwsExecution) : Boolean; override;
end;
// Variant(simple)
TConvVariantExpr = class (TUnaryOpVariantExpr)
procedure EvalAsVariant(exec : TdwsExecution; var Result : Variant); override;
end;
// Static Array to Dynamic Array
TConvStaticArrayToDynamicExpr = class (TUnaryOpExpr)
constructor Create(prog : TdwsProgram; expr : TArrayConstantExpr; toTyp : TDynamicArraySymbol); reintroduce;
function Eval(exec : TdwsExecution) : Variant; override;
end;
// Static Array to set of
TConvStaticArrayToSetOfExpr = class (TPosDataExpr)
private
FExpr : TArrayConstantExpr;
protected
function GetSubExpr(i : Integer) : TExprBase; override;
function GetSubExprCount : Integer; override;
public
constructor Create(prog : TdwsProgram; const scriptPos : TScriptPos;
expr : TArrayConstantExpr; toTyp : TSetOfSymbol);
destructor Destroy; override;
procedure EvalAsTData(exec : TdwsExecution; var data : TData);
function IsWritable: Boolean; override;
procedure GetDataPtr(exec : TdwsExecution; var result : IDataContext); override;
property Expr : TArrayConstantExpr read FExpr write FExpr;
end;
// ExternalClass(x)
TConvExternalExpr = class (TUnaryOpVariantExpr)
procedure EvalAsVariant(exec : TdwsExecution; var Result : Variant); override;
end;
// cast something as Typ
TAsCastExpr = class(TUnaryOpExpr)
private
FPos : TScriptPos;
public
constructor Create(prog : TdwsProgram; const aPos : TScriptPos;
expr : TTypedExpr; toTyp : TTypeSymbol); reintroduce;
function Eval(exec : TdwsExecution) : Variant; override;
end;
// class as TMyClass
TClassAsClassExpr = class(TAsCastExpr)
protected
procedure RaiseMetaClassCastFailed(exec : TdwsExecution; classSym : TClassSymbol);
public
function Eval(exec : TdwsExecution) : Variant; override;
end;
// obj as TMyClass
TObjAsClassExpr = class(TAsCastExpr)
protected
procedure RaiseInstanceClassCastFailed(exec : TdwsExecution; classSym : TClassSymbol);
public
procedure EvalAsScriptObj(exec : TdwsExecution; var Result : IScriptObj); override;
end;
// obj.ClassType
TObjToClassTypeExpr = class(TUnaryOpExpr)
public
constructor Create(prog : TdwsProgram; expr : TTypedExpr); override;
function Eval(exec : TdwsExecution) : Variant; override;
end;
// obj as Interface
TObjAsIntfExpr = class(TAsCastExpr)
public
procedure EvalAsScriptObj(exec : TdwsExecution; var Result : IScriptObj); override;
end;
// interface as Interface
TIntfAsIntfExpr = class(TAsCastExpr)
public
procedure EvalAsScriptObj(exec : TdwsExecution; var Result : IScriptObj); override;
end;
// interface as class
TIntfAsClassExpr = class(TAsCastExpr)
public
procedure EvalAsScriptObj(exec : TdwsExecution; var Result : IScriptObj); override;
end;
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
implementation
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
uses dwsCoreExprs;
// ------------------
// ------------------ TConvExpr ------------------
// ------------------
// WrapWithConvCast
//
class function TConvExpr.WrapWithConvCast(prog : TdwsProgram; const scriptPos : TScriptPos;
toTyp : TTypeSymbol; expr : TTypedExpr;
const reportError : String) : TTypedExpr;
procedure ReportIncompatibleTypes;
var
cleft, cright: UnicodeString;
begin
if reportError='' then Exit;
if toTyp = nil then
cleft := SYS_VOID
else cleft := toTyp.Caption;
if expr.Typ = nil then
cright := SYS_VOID
else cright := expr.Typ.Caption;
prog.CompileMsgs.AddCompilerErrorFmt(scriptPos, reportError, [cright, cleft]);
end;
var
arrayConst : TArrayConstantExpr;
begin
Result:=expr;
if (toTyp=nil) or (expr.Typ=nil) then begin
ReportIncompatibleTypes;
Exit;
end;
if expr.Typ=toTyp then Exit;
if expr.ClassType=TArrayConstantExpr then begin
arrayConst:=TArrayConstantExpr(expr);
if toTyp is TDynamicArraySymbol then begin
if (toTyp.Typ.IsOfType(expr.Typ.Typ))
or ((arrayConst.ElementCount=0) and (arrayConst.Typ.Typ.IsOfType(prog.TypVariant))) then
Result:=TConvStaticArrayToDynamicExpr.Create(prog, arrayConst,
TDynamicArraySymbol(toTyp))
end else if toTyp is TSetOfSymbol then begin
if (arrayConst.ElementCount=0) or arrayConst.Typ.Typ.IsOfType(toTyp.Typ) then
Result:=TConvStaticArrayToSetOfExpr.Create(prog, scriptPos, arrayConst, TSetOfSymbol(toTyp));
end;
end else if expr.Typ.UnAliasedTypeIs(TBaseVariantSymbol) then begin
if toTyp.IsOfType(prog.TypInteger) then
Result:=TConvVarToIntegerExpr.Create(prog, expr)
else if toTyp.IsOfType(prog.TypFloat) then
Result:=TConvVarToFloatExpr.Create(prog, expr)
else if toTyp.IsOfType(prog.TypString) then
Result:=TConvVarToStringExpr.Create(prog, expr)
else if toTyp.IsOfType(prog.TypBoolean) then
Result:=TConvVarToBoolExpr.Create(prog, expr);
end else if (toTyp is TStructuredTypeMetaSymbol)
and (expr.Typ.IsOfType(toTyp.Typ)) then begin
if toTyp.ClassType=TClassOfSymbol then begin
Result:=TObjToClassTypeExpr.Create(prog, expr);
if toTyp.Typ<>expr.Typ then
Result:=TClassAsClassExpr.Create(prog, scriptPos, Result, toTyp);
end else begin
Assert(False);
Result:=nil;
end;
end else begin
if toTyp.IsOfType(prog.TypFloat)
and expr.IsOfType(prog.TypInteger) then begin
if expr is TConstIntExpr then begin
Result:=TConstFloatExpr.CreateTypedVariantValue(prog, prog.TypFloat, TConstIntExpr(expr).Value);
expr.Free;
end else Result:=TConvIntToFloatExpr.Create(prog, expr);
end;
end;
// Look if Types are compatible
if not toTyp.IsCompatible(Result.Typ) then
ReportIncompatibleTypes;
end;
// Eval
//
function TConvExpr.Eval(exec : TdwsExecution) : Variant;
begin
Assert(False);
end;
// ------------------
// ------------------ TConvInvalidExpr ------------------
// ------------------
// Create
//
constructor TConvInvalidExpr.Create(prog : TdwsProgram; expr : TTypedExpr; toTyp : TTypeSymbol);
begin
inherited Create(prog, expr);
Typ:=toTyp;
end;
// GetIsConstant
//
function TConvInvalidExpr.GetIsConstant : Boolean;
begin
Result:=False;
end;
// ------------------
// ------------------ TConvIntToFloatExpr ------------------
// ------------------
// EvalAsFloat
//
function TConvIntToFloatExpr.EvalAsFloat(exec : TdwsExecution) : Double;
begin
Result:=FExpr.EvalAsInteger(exec);
end;
// ------------------
// ------------------ TConvVarToFloatExpr ------------------
// ------------------
// EvalAsFloat
//
function TConvVarToFloatExpr.EvalAsFloat(exec : TdwsExecution) : Double;
var
v : Variant;
begin
FExpr.EvalAsVariant(exec, v);
Result:=v;
end;
// ------------------
// ------------------ TConvVarToIntegerExpr ------------------
// ------------------
// EvalAsInteger
//
function TConvVarToIntegerExpr.EvalAsInteger(exec : TdwsExecution) : Int64;
var
v : Variant;
begin
FExpr.EvalAsVariant(exec, v);
Result:=v;
end;
// ------------------
// ------------------ TConvOrdToIntegerExpr ------------------
// ------------------
// EvalAsInteger
//
function TConvOrdToIntegerExpr.EvalAsInteger(exec : TdwsExecution) : Int64;
begin
Result:=FExpr.EvalAsInteger(exec);
end;
// Optimize
//
function TConvOrdToIntegerExpr.Optimize(prog : TdwsProgram; exec : TdwsExecution) : TProgramExpr;
begin
// this can happen when an integer was qualifed as a type
if Expr.ClassType=TConstIntExpr then begin
if Expr.Typ=Typ then begin
Result:=Expr;
Expr:=nil;
end else begin
Result:=TConstIntExpr.CreateUnified(prog, Typ, TConstIntExpr(Expr).Value);
end;
Free;
end else Result:=Self;
end;
// ------------------
// ------------------ TConvVarToStringExpr ------------------
// ------------------
// EvalAsString
//
procedure TConvVarToStringExpr.EvalAsString(exec : TdwsExecution; var Result : UnicodeString);
var
v : Variant;
begin
FExpr.EvalAsVariant(exec, v);
VariantToString(v, Result);
end;
// ------------------
// ------------------ TConvIntToBoolExpr ------------------
// ------------------
// EvalAsBoolean
//
function TConvIntToBoolExpr.EvalAsBoolean(exec : TdwsExecution) : Boolean;
begin
Result:=(FExpr.EvalAsInteger(exec)<>0);
end;
// ------------------
// ------------------ TConvFloatToBoolExpr ------------------
// ------------------
// EvalAsBoolean
//
function TConvFloatToBoolExpr.EvalAsBoolean(exec : TdwsExecution) : Boolean;
begin
Result:=(FExpr.EvalAsFloat(exec)<>0);
end;
// ------------------
// ------------------ TConvVarToBoolExpr ------------------
// ------------------
// EvalAsBoolean
//
function TConvVarToBoolExpr.EvalAsBoolean(exec : TdwsExecution) : Boolean;
var
v : Variant;
begin
FExpr.EvalAsVariant(exec, v);
Result:=v;
end;
// ------------------
// ------------------ TConvVariantExpr ------------------
// ------------------
// EvalAsVariant
//
procedure TConvVariantExpr.EvalAsVariant(exec : TdwsExecution; var Result : Variant);
begin
FExpr.EvalAsVariant(exec, Result);
end;
// ------------------
// ------------------ TConvStaticArrayToDynamicExpr ------------------
// ------------------
// Create
//
constructor TConvStaticArrayToDynamicExpr.Create(prog : TdwsProgram; expr : TArrayConstantExpr;
toTyp : TDynamicArraySymbol);
begin
inherited Create(prog, expr);
Typ:=toTyp;
end;
// Eval
//
function TConvStaticArrayToDynamicExpr.Eval(exec : TdwsExecution) : Variant;
var
arr : TArrayConstantExpr;
dynArray : TScriptDynamicArray;
begin
arr:=TArrayConstantExpr(Expr);
dynArray:=TScriptDynamicArray.CreateNew(TDynamicArraySymbol(Typ).Typ);
dynArray.ReplaceData(arr.EvalAsTData(exec));
Result:=IUnknown(IScriptObj(dynArray));
end;
// ------------------
// ------------------ TConvExternalExpr ------------------
// ------------------
// EvalAsVariant
//
procedure TConvExternalExpr.EvalAsVariant(exec : TdwsExecution; var Result : Variant);
begin
Expr.EvalAsVariant(exec, Result);
end;
// ------------------
// ------------------ TAsCastExpr ------------------
// ------------------
// Create
//
constructor TAsCastExpr.Create(prog : TdwsProgram; const aPos : TScriptPos;
expr : TTypedExpr; toTyp : TTypeSymbol);
begin
inherited Create(prog, expr);
FPos:=aPos;
FTyp:=toTyp;
end;
// Eval
//
function TAsCastExpr.Eval(exec : TdwsExecution) : Variant;
var
scriptObj : IScriptObj;
begin
EvalAsScriptObj(exec, scriptObj);
Result:=scriptObj;
end;
// ------------------
// ------------------ TClassAsClassExpr ------------------
// ------------------
// RaiseMetaClassCastFailed
//
procedure TClassAsClassExpr.RaiseMetaClassCastFailed(exec : TdwsExecution; classSym : TClassSymbol);
begin
RaiseScriptError(exec, EClassCast.CreatePosFmt(FPos, RTE_MetaClassCastFailed,
[classSym.Caption, FTyp.Name]))
end;
// Eval
//
function TClassAsClassExpr.Eval(exec : TdwsExecution) : Variant;
var
ref : TClassSymbol;
begin
ref:=TClassSymbol(Expr.EvalAsInteger(exec));
Result:=Int64(ref);
if ref<>nil then begin
if not FTyp.IsCompatible(ref.MetaSymbol) then
RaiseMetaClassCastFailed(exec, ref);
end;
end;
// ------------------
// ------------------ TObjAsClassExpr ------------------
// ------------------
// RaiseInstanceClassCastFailed
//
procedure TObjAsClassExpr.RaiseInstanceClassCastFailed(exec : TdwsExecution; classSym : TClassSymbol);
begin
RaiseScriptError(exec, EClassCast.CreatePosFmt(FPos, RTE_ClassInstanceCastFailed,
[classSym.Caption, FTyp.Caption]))
end;
// EvalAsScriptObj
//
procedure TObjAsClassExpr.EvalAsScriptObj(exec : TdwsExecution; var Result : IScriptObj);
begin
Expr.EvalAsScriptObj(exec, Result);
if Assigned(Result) and not (FTyp.IsCompatible(Result.ClassSym)) then
RaiseInstanceClassCastFailed(exec, Result.ClassSym);
end;
// ------------------
// ------------------ TObjToClassTypeExpr ------------------
// ------------------
// Create
//
constructor TObjToClassTypeExpr.Create(prog : TdwsProgram; expr : TTypedExpr);
begin
inherited Create(prog, expr);
Typ:=(expr.Typ as TStructuredTypeSymbol).MetaSymbol;
end;
// Eval
//
function TObjToClassTypeExpr.Eval(exec : TdwsExecution) : Variant;
var
obj : IScriptObj;
begin
Expr.EvalAsScriptObj(exec, obj);
if obj=nil then
Result:=Int64(0)
else Result:=Int64(obj.ClassSym);
end;
// ------------------
// ------------------ TObjAsIntfExpr ------------------
// ------------------
// EvalAsScriptObj
//
procedure TObjAsIntfExpr.EvalAsScriptObj(exec : TdwsExecution; var Result : IScriptObj);
procedure RaiseIntfCastFailed;
begin
RaiseScriptError(exec, EClassCast.CreatePosFmt(ScriptPos, RTE_ObjCastToIntfFailed,
[Result.ClassSym.Caption, FTyp.Caption]))
end;
var
intf : TScriptInterface;
resolved : TResolvedInterface;
begin
Expr.EvalAsScriptObj(exec, Result);
if Assigned(Result) then begin
if not Result.ClassSym.ResolveInterface(TInterfaceSymbol(Typ), resolved) then
RaiseIntfCastFailed;
intf:=TScriptInterface.Create(Result, resolved);
Result:=intf;
end;
end;
// ------------------
// ------------------ TIntfAsIntfExpr ------------------
// ------------------
// EvalAsScriptObj
//
procedure TIntfAsIntfExpr.EvalAsScriptObj(exec : TdwsExecution; var Result : IScriptObj);
procedure RaiseIntfCastFailed;
begin
RaiseScriptError(exec, EClassCast.CreatePosFmt(ScriptPos, RTE_IntfCastToIntfFailed,
[Result.ClassSym.Caption, FTyp.Caption]))
end;
var
intf : TScriptInterface;
instance : IScriptObj;
resolved : TResolvedInterface;
begin
Expr.EvalAsScriptObj(exec, Result);
if Assigned(Result) then begin
instance:=TScriptInterface(Result.GetSelf).Instance;
if not instance.ClassSym.ResolveInterface(TInterfaceSymbol(Typ), resolved) then
RaiseIntfCastFailed;
intf:=TScriptInterface.Create(instance, resolved);
Result:=intf;
end;
end;
// ------------------
// ------------------ TIntfAsClassExpr ------------------
// ------------------
// EvalAsScriptObj
//
procedure TIntfAsClassExpr.EvalAsScriptObj(exec : TdwsExecution; var Result : IScriptObj);
procedure RaiseIntfCastFailed;
begin
RaiseScriptError(exec, EClassCast.CreatePosFmt(ScriptPos, RTE_IntfCastToObjFailed,
[Result.ClassSym.Caption, FTyp.Caption]))
end;
var
intf : TScriptInterface;
begin
Expr.EvalAsScriptObj(exec, Result);
if Assigned(Result) then begin
intf:=TScriptInterface(Result.GetSelf);
Result:=intf.Instance;
if not Result.ClassSym.IsCompatible(FTyp) then
RaiseIntfCastFailed;
end;
end;
// ------------------
// ------------------ TConvStaticArrayToSetOfExpr ------------------
// ------------------
// Create
//
constructor TConvStaticArrayToSetOfExpr.Create(prog : TdwsProgram; const scriptPos : TScriptPos;
expr : TArrayConstantExpr; toTyp : TSetOfSymbol);
begin
inherited Create(prog, scriptPos, toTyp);
FExpr:=expr;
end;
// Destroy
//
destructor TConvStaticArrayToSetOfExpr.Destroy;
begin
inherited;
FExpr.Free;
end;
// EvalAsTData
//
procedure TConvStaticArrayToSetOfExpr.EvalAsTData(exec : TdwsExecution; var data : TData);
var
i, v : Integer;
setOfSym : TSetOfSymbol;
begin
setOfSym:=TSetOfSymbol(Typ);
SetLength(data, setOfSym.Size);
Typ.InitData(data, 0);
for i:=0 to Expr.ElementCount-1 do begin
v:=Expr.Elements[i].EvalAsInteger(exec)-setOfSym.MinValue;
if Cardinal(v)<Cardinal(setOfSym.CountValue) then
data[v shr 6]:=data[v shr 6] or (Int64(1) shl (v and 63));
end;
end;
// IsWritable
//
function TConvStaticArrayToSetOfExpr.IsWritable: Boolean;
begin
Result:=False;
end;
// GetDataPtr
//
procedure TConvStaticArrayToSetOfExpr.GetDataPtr(exec : TdwsExecution; var result : IDataContext);
var
data : TData;
begin
EvalAsTData(exec, data);
result:=exec.Stack.CreateDataContext(data, 0);
end;
// GetSubExpr
//
function TConvStaticArrayToSetOfExpr.GetSubExpr(i : Integer) : TExprBase;
begin
Result:=FExpr;
end;
// GetSubExprCount
//
function TConvStaticArrayToSetOfExpr.GetSubExprCount : Integer;
begin
Result:=1;
end;
end.
| 29.217931 | 114 | 0.603172 |
fcf66a59df784bb5a107ea1f15f70d481ddece49 | 8,711 | pas | Pascal | source/glscene/FileFormats/GLFileSTL.pas | xtreme3d/xtreme3d | 0d9128d427f0f29290f1b9a2b25e7297ace900a9 | [
"FTL",
"MIT",
"BSD-3-Clause"
]
| 22 | 2016-04-23T07:54:02.000Z | 2021-07-11T14:21:40.000Z | source/glscene/FileFormats/GLFileSTL.pas | xtreme3d/xtreme3d | 0d9128d427f0f29290f1b9a2b25e7297ace900a9 | [
"FTL",
"MIT",
"BSD-3-Clause"
]
| 62 | 2016-05-02T21:36:13.000Z | 2020-02-22T15:11:52.000Z | source/glscene/FileFormats/GLFileSTL.pas | xtreme3d/xtreme3d | 0d9128d427f0f29290f1b9a2b25e7297ace900a9 | [
"FTL",
"MIT",
"BSD-3-Clause"
]
| 6 | 2017-12-29T18:38:33.000Z | 2020-07-26T18:52:19.000Z | //
// This unit is part of the GLScene Project, http://glscene.org
//
{: GLFileSTL<p>
Support-code to load STL Files into TGLFreeForm-Components in GLScene.<p>
Note that you must manually add this unit to one of your project's uses
to enable support for STL files at run-time.<p>
<b>History : </b><font size=-1><ul>
<li>22/11/02 - EG - Write capability now properly declared
<li>17/10/02 - EG - Created from split of GLVectorFileObjects,
ASCII STL support (Adem)
</ul><p>
}
unit GLFileSTL;
interface
uses Classes, GLVectorFileObjects, GLMisc, ApplicationFileIO;
type
// TGLSTLVectorFile
//
{: The STL vector file (stereolithography format).<p>
It is a list of the triangular surfaces that describe a computer generated
solid model. This is the standard input for most rapid prototyping machines.<p>
There are two flavors of STL, the "text" and the "binary", this class
reads both, but exports only the "binary" version.<p>
Original Binary importer code by Paul M. Bearne, Text importer by Adem. }
TGLSTLVectorFile = class(TVectorFile)
public
{ Public Declarations }
class function Capabilities : TDataFileCapabilities; override;
procedure LoadFromStream(aStream: TStream); override;
procedure SaveToStream(aStream: TStream); override;
end;
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
implementation
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
uses TypesSTL, VectorGeometry, VectorLists, SysUtils, GLUtils;
const
cSOLID_LABEL = 'SOLID';
cFACETNORMAL_LABEL = 'FACET NORMAL ';
cOUTERLOOP_LABEL = 'OUTER LOOP';
cVERTEX_LABEL = 'VERTEX';
cENDLOOP_LABEL = 'ENDLOOP';
cENDFACET_LABEL = 'ENDFACET';
cENDSOLID_LABEL = 'ENDSOLID';
cFULL_HEADER_LEN = 84;
// ------------------
// ------------------ TGLSTLVectorFile ------------------
// ------------------
// Capabilities
//
class function TGLSTLVectorFile.Capabilities : TDataFileCapabilities;
begin
Result:=[dfcRead, dfcWrite];
end;
// LoadFromStream
//
procedure TGLSTLVectorFile.LoadFromStream(aStream : TStream);
var
sl : TStringList;
procedure DecodeSTLNormals(const aString : String; var aNormal : TSTLVertex);
begin
sl.CommaText:=aString;
if sl.Count<>5 then
raise Exception.Create('Invalid Normal')
else begin
aNormal[0]:=StrToFloatDef(sl[2], 0);
aNormal[1]:=StrToFloatDef(sl[3], 0);
aNormal[2]:=StrToFloatDef(sl[4], 0);
end;
end;
procedure DecodeSTLVertex(const aString : String; var aVertex : TSTLVertex);
begin
sl.CommaText:=aString;
if (sl.Count<>4) or (CompareText(sl[0], cVERTEX_LABEL)<>0) then
raise Exception.Create('Invalid Vertex')
else begin
aVertex[0]:=StrToFloatDef(sl[1], 0);
aVertex[1]:=StrToFloatDef(sl[2], 0);
aVertex[2]:=StrToFloatDef(sl[3], 0);
end;
end;
var
isBinary : Boolean;
headerBuf : array [0..cFULL_HEADER_LEN-1] of Char;
positionBackup : Integer;
fileContent : TStringList;
curLine : String;
i : Integer;
mesh : TMeshObject;
header : TSTLHeader;
dataFace : TSTLFace;
calcNormal : TAffineVector;
begin
positionBackup:=aStream.Position;
aStream.Read(headerBuf[0], cFULL_HEADER_LEN);
aStream.Position:=positionBackup;
isBinary:=True;
i:=0;
while i<80 do begin
if (headerBuf[i]<#32) and (headerBuf[i]<>#0) then begin
isBinary:=False;
Break;
end;
Inc(i);
end;
mesh:=TMeshObject.CreateOwned(Owner.MeshObjects);
try
mesh.Mode:=momTriangles;
if isBinary then begin
aStream.Read(header, SizeOf(TSTLHeader));
for i:=0 to header.nbFaces-1 do begin
aStream.Read(dataFace, SizeOf(TSTLFace));
with dataFace, mesh do begin
// STL faces have a normal, but do not necessarily follow the winding rule,
// so we must first determine if the triangle is properly oriented
// and rewind it properly if not...
calcNormal:=CalcPlaneNormal(v1, v2, v3);
if VectorDotProduct(calcNormal, normal)>0 then
Vertices.Add(v1, v2, v3)
else Vertices.Add(v3, v2, v1);
Normals.Add(normal, normal, normal);
end;
end;
end else begin
fileContent:=TStringList.Create;
sl:=TStringList.Create;
try
fileContent.LoadFromStream(aStream);
i:=0;
curLine:=Trim(UpperCase(fileContent[i]));
if Pos(cSOLID_LABEL, curLine)=1 then begin
mesh.Vertices.Capacity:=(fileContent.Count-2) div 7;
mesh.Normals.Capacity:=(fileContent.Count-2) div 7;
Inc(i);
curLine:=Trim(UpperCase(fileContent[i]));
while i<fileContent.Count do begin
if Pos(cFACETNORMAL_LABEL, curLine)=1 then begin
DecodeSTLNormals(curLine, dataFace.normal);
Inc(i);
curLine:=Trim(UpperCase(fileContent[i]));
if Pos(cOUTERLOOP_LABEL, curLine)=1 then begin
Inc(i);
curLine:=Trim(fileContent[i]);
DecodeSTLVertex(curLine, dataFace.v1);
Inc(i);
curLine:=Trim(fileContent[i]);
DecodeSTLVertex(curLine, dataFace.v2);
Inc(i);
curLine:=Trim(fileContent[i]);
DecodeSTLVertex(curLine, dataFace.v3);
end;
Inc(i);
curLine:=Trim(UpperCase(fileContent[i]));
if Pos(cENDLOOP_LABEL, curLine)<>1 then
raise Exception.Create('End of Loop Not Found')
else begin
calcNormal:=CalcPlaneNormal(dataFace.v1, dataFace.v2, dataFace.v3);
if VectorDotProduct(calcNormal, dataFace.normal)>0 then
mesh.Vertices.Add(dataFace.v1, dataFace.v2, dataFace.v3)
else mesh.Vertices.Add(dataFace.v3, dataFace.v2, dataFace.v1);
mesh.Normals.Add(dataFace.normal, dataFace.normal, dataFace.normal);
end;
end;
Inc(i);
curLine:=Trim(UpperCase(fileContent[i]));
if Pos(cENDFACET_LABEL, curLine)<>1 then
raise Exception.Create('End of Facet Not found');
Inc(i);
curLine:=Trim(UpperCase(fileContent[i]));
if Pos(cENDSOLID_LABEL, curLine)=1 then Break;
end;
end;
finally
sl.Free;
fileContent.Free;
end;
end;
except
on E : Exception do begin
mesh.Free;
end;
end;
end;
// SaveToStream
//
procedure TGLSTLVectorFile.SaveToStream(aStream: TStream);
var
i : Integer;
header : TSTLHeader;
dataFace : TSTLFace;
list : TAffineVectorList;
const
cHeaderTag = 'GLScene STL export';
begin
list:=Owner.MeshObjects.ExtractTriangles;
try
FillChar(header.dummy[0], SizeOf(header.dummy), 0);
Move(cHeaderTag, header.dummy[0], Length(cHeaderTag));
header.nbFaces:=list.Count div 3;
aStream.Write(header, SizeOf(header));
i:=0; while i<list.Count do begin
dataFace.normal:=CalcPlaneNormal(list[i], list[i+1], list[i+2]);
dataFace.v1:=list[i];
dataFace.v2:=list[i+1];
dataFace.v3:=list[i+2];
aStream.Write(dataFace, SizeOf(dataFace));
Inc(i, 3);
end;
finally
list.Free;
end;
end;
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
initialization
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
RegisterVectorFileFormat('stl', 'Stereolithography files', TGLSTLVectorFile);
end.
| 33.894942 | 92 | 0.529101 |
fca15621c2e74ba25937c15a83d6f53315afc941 | 475,214 | pas | Pascal | Libraries/TBCEditor/Source/BCEditor.Editor.Base.pas | jpluimers/Concepts | 78598ab6f1b4206bbc4ed9c7bc15705ad4ade1fe | [
"Apache-2.0"
]
| 2 | 2020-01-04T08:19:10.000Z | 2020-02-19T22:25:38.000Z | Libraries/TBCEditor/Source/BCEditor.Editor.Base.pas | jpluimers/Concepts | 78598ab6f1b4206bbc4ed9c7bc15705ad4ade1fe | [
"Apache-2.0"
]
| null | null | null | Libraries/TBCEditor/Source/BCEditor.Editor.Base.pas | jpluimers/Concepts | 78598ab6f1b4206bbc4ed9c7bc15705ad4ade1fe | [
"Apache-2.0"
]
| 1 | 2020-02-19T22:25:42.000Z | 2020-02-19T22:25:42.000Z | unit BCEditor.Editor.Base;
interface
uses
Winapi.Windows, Winapi.Messages, System.Classes, System.SysUtils, System.Contnrs, System.UITypes,
Vcl.Forms, Vcl.Controls, Vcl.Graphics, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Dialogs,
BCEditor.Consts, BCEditor.Editor.ActiveLine, BCEditor.Editor.Bookmarks, BCEditor.Editor.Caret,
BCEditor.Editor.CodeFolding, BCEditor.Editor.CodeFolding.Regions, BCEditor.Editor.CodeFolding.Ranges,
BCEditor.Types, BCEditor.Editor.CompletionProposal, BCEditor.Editor.CompletionProposal.PopupWindow,
BCEditor.Editor.Glyph, BCEditor.Editor.InternalImage, BCEditor.Editor.KeyCommands, BCEditor.Editor.LeftMargin,
BCEditor.Editor.LineSpacing, BCEditor.Editor.MatchingPair, BCEditor.Editor.Minimap, BCEditor.Editor.Replace,
BCEditor.Editor.RightMargin, BCEditor.Editor.Scroll, BCEditor.Editor.Search, BCEditor.Editor.Directories,
BCEditor.Editor.Selection, BCEditor.Editor.SkipRegions, BCEditor.Editor.SpecialChars, BCEditor.Editor.Tabs,
BCEditor.Editor.Undo, BCEditor.Editor.Undo.List, BCEditor.Editor.WordWrap, BCEditor.Editor.CodeFolding.Hint.Form,
BCEditor.Highlighter, BCEditor.Highlighter.Attributes, BCEditor.KeyboardHandler, BCEditor.Lines, BCEditor.Search,
BCEditor.Search.RegularExpressions, BCEditor.Search.WildCard, BCEditor.TextDrawer, BCEditor.Editor.SyncEdit,
BCEditor.Utils{$IFDEF USE_ALPHASKINS}, sCommonData, acSBUtils{$ENDIF};
const
BCEDITOR_DEFAULT_OPTIONS = [eoAutoIndent, eoDragDropEditing];
type
TBCBaseEditor = class(TCustomControl)
strict private
FActiveLine: TBCEditorActiveLine;
FAllCodeFoldingRanges: TBCEditorAllCodeFoldingRanges;
FAltEnabled: Boolean;
FAlwaysShowCaret: Boolean;
FBackgroundColor: TColor;
FBookmarks: array [0 .. 8] of TBCEditorBookmark;
FBorderStyle: TBorderStyle;
FBufferBmp: Vcl.Graphics.TBitmap;
FCaret: TBCEditorCaret;
FCaretOffset: TPoint;
FDisplayCaretX: Integer;
FDisplayCaretY: Integer;
FDragBeginTextCaretPosition: TBCEditorTextPosition;
FChainedEditor: TBCBaseEditor;
FCharWidth: Integer;
FCodeFolding: TBCEditorCodeFolding;
FCodeFoldingHintForm: TBCEditorCodeFoldingHintForm;
FCodeFoldingLock: Boolean;
FCodeFoldingRangeFromLine: array of TBCEditorCodeFoldingRange;
FCodeFoldingRangeToLine: array of TBCEditorCodeFoldingRange;
FCodeFoldingTreeLine: array of Boolean;
FCommandDrop: Boolean;
{$IFDEF USE_ALPHASKINS}
FCommonData: TsScrollWndData;
{$ENDIF}
FCompletionProposal: TBCEditorCompletionProposal;
FCompletionProposalPopupWindow: TBCEditorCompletionProposalPopupWindow;
FCompletionProposalTimer: TTimer;
FCurrentMatchingPair: TBCEditorMatchingTokenResult;
FCurrentMatchingPairMatch: TBCEditorMatchingPairMatch;
FDirectories: TBCEditorDirectories;
FDoubleClickTime: Cardinal;
FEncoding: TEncoding;
FFontDummy: TFont;
FForegroundColor: TColor;
FHighlightedFoldRange: TBCEditorCodeFoldingRange;
FHighlighter: TBCEditorHighlighter;
FHookedCommandHandlers: TObjectList;
FInsertMode: Boolean;
FInternalBookmarkImage: TBCEditorInternalImage;
FInvalidateRect: TRect;
FIsScrolling: Boolean;
FKeyboardHandler: TBCEditorKeyboardHandler;
FKeyCommands: TBCEditorKeyCommands;
FLastDblClick: Cardinal;
FLastKey: Word;
FLastLineNumberCount: Integer;
FLastRow: Integer;
FLastShiftState: TShiftState;
FLastSortOrder: TBCEditorSortOrder;
FLastTopLine: Integer;
FLeftChar: Integer;
FLeftMargin: TBCEditorLeftMargin;
FLeftMarginCharWidth: Integer;
FLineHeight: Integer;
FLineNumbersCache: array of Integer;
FLineNumbersCount: Integer;
FLines: TBCEditorLines;
FLinespacing: TBCEditorLineSpacing;
FMarkList: TBCEditorBookmarkList;
FMatchingPair: TBCEditorMatchingPair;
FMatchingPairMatchStack: array of TBCEditorMatchingPairTokenMatch;
FMatchingPairOpenDuplicate, FMatchingPairCloseDuplicate: array of Integer;
FMinimap: TBCEditorMinimap;
FMinimapBufferBmp: Vcl.Graphics.TBitmap;
FMinimapClickOffsetY: Integer;
FMinimapIndicatorBlendFunction: TBlendFunction;
FMinimapIndicatorBitmap: Vcl.Graphics.TBitmap;
FMinimapShadowAlphaArray: array of Single;
FMinimapShadowAlphaByteArray: array of Byte;
FMinimapShadowBlendFunction: TBlendFunction;
FMinimapShadowBitmap: Vcl.Graphics.TBitmap;
FModified: Boolean;
FMouseDownX: Integer;
FMouseDownY: Integer;
FMouseOverURI: Boolean;
FMouseMoveScrollCursors: array [0..7] of HCursor;
FMouseMoveScrolling: Boolean;
FMouseMoveScrollingPoint: TPoint;
FMouseMoveScrollTimer: TTimer;
FMouseWheelAccumulator: Integer;
FOldMouseMovePoint: TPoint;
FOnAfterBookmarkPanelPaint: TBCEditorBookmarkPanelPaintEvent;
FOnAfterBookmarkPlaced: TNotifyEvent;
FOnAfterClearBookmark: TNotifyEvent;
FOnAfterLinePaint: TBCEditorLinePaintEvent;
FOnBeforeBookmarkPanelPaint: TBCEditorBookmarkPanelPaintEvent;
FOnBeforeBookmarkPlaced: TBCEditorBookmarkEvent;
FOnBeforeClearBookmark: TBCEditorBookmarkEvent;
FOnBookmarkPanelLinePaint: TBCEditorBookmarkPanelLinePaintEvent;
FOnCaretChanged: TBCEditorCaretChangedEvent;
FOnChange: TNotifyEvent;
FOnChainLinesChanged: TNotifyEvent;
FOnChainLinesChanging: TNotifyEvent;
FOnChainLinesCleared: TNotifyEvent;
FOnChainLinesDeleted: TStringListChangeEvent;
FOnChainLinesInserted: TStringListChangeEvent;
FOnChainLinesPutted: TStringListChangeEvent;
FOnChainRedoAdded: TNotifyEvent;
FOnChainUndoAdded: TNotifyEvent;
FOnCommandProcessed: TBCEditorProcessCommandEvent;
FOnContextHelp: TBCEditorContextHelpEvent;
FOnCreateFileStream: TBCEditorCreateFileStreamEvent;
FOnCustomLineColors: TBCEditorCustomLineColorsEvent;
FOnCustomTokenAttribute: TBCEditorCustomTokenAttributeEvent;
FOnDropFiles: TBCEditorDropFilesEvent;
FOnKeyPressW: TBCEditorKeyPressWEvent;
FOnLeftMarginClick: TLeftMarginClickEvent;
FOnLinesDeleted: TStringListChangeEvent;
FOnLinesInserted: TStringListChangeEvent;
FOnLinesPutted: TStringListChangeEvent;
FOnPaint: TBCEditorPaintEvent;
FOnProcessCommand: TBCEditorProcessCommandEvent;
FOnProcessUserCommand: TBCEditorProcessCommandEvent;
FOnReplaceText: TBCEditorReplaceTextEvent;
FOnRightMarginMouseUp: TNotifyEvent;
FOnScroll: TBCEditorScrollEvent;
FOnSelectionChanged: TNotifyEvent;
FOptions: TBCEditorOptions;
FOriginalLines: TBCEditorLines;
FOriginalRedoList: TBCEditorUndoList;
FOriginalUndoList: TBCEditorUndoList;
FPaintLock: Integer;
FReadOnly: Boolean;
FRedoList: TBCEditorUndoList;
FReplace: TBCEditorReplace;
FRescanCodeFolding: Boolean;
FResetLineNumbersCache: Boolean;
FRightMargin: TBCEditorRightMargin;
FRightMarginMovePosition: Integer;
FSaveSelectionMode: TBCEditorSelectionMode;
FScroll: TBCEditorScroll;
FScrollDeltaX: Integer;
FScrollDeltaY: Integer;
FScrollTimer: TTimer;
{$IFDEF USE_ALPHASKINS}
FScrollWnd: TacScrollWnd;
{$ENDIF}
FSearch: TBCEditorSearch;
FSearchEngine: TBCEditorSearchCustom;
FSelectedCaseCycle: TBCEditorCase;
FSelectedCaseText: string;
FSelection: TBCEditorSelection;
FSelectionBeginPosition: TBCEditorTextPosition;
FSelectionEndPosition: TBCEditorTextPosition;
FSpecialChars: TBCEditorSpecialChars;
FStateFlags: TBCEditorStateFlags;
FSyncEdit: TBCEditorSyncEdit;
FTabs: TBCEditorTabs;
FTextDrawer: TBCEditorTextDrawer;
FTextOffset: Integer;
FTopLine: Integer;
FUndo: TBCEditorUndo;
FUndoList: TBCEditorUndoList;
FUndoRedo: Boolean;
FURIOpener: Boolean;
FVisibleChars: Integer;
FVisibleLines: Integer;
FWantReturns: Boolean;
FWindowProducedMessage: Boolean;
FWordWrap: TBCEditorWordWrap;
FWordWrapLineLengths: array of Integer;
function AddMultiByteFillerChars(AText: PChar; ALength: Integer): string;
function CodeFoldingCollapsableFoldRangeForLine(ALine: Integer): TBCEditorCodeFoldingRange;
function CodeFoldingFoldRangeForLineTo(ALine: Integer): TBCEditorCodeFoldingRange;
function CodeFoldingLineInsideRange(ALine: Integer): TBCEditorCodeFoldingRange;
function CodeFoldingRangeForLine(ALine: Integer): TBCEditorCodeFoldingRange;
function CodeFoldingTreeEndForLine(ALine: Integer): Boolean;
function CodeFoldingTreeLineForLine(ALine: Integer): Boolean;
function DoOnCodeFoldingHintClick(X, Y: Integer): Boolean;
function ExtraLineSpacing: Integer;
function FindHookedCommandEvent(AHookedCommandEvent: TBCEditorHookedCommandEvent): Integer;
function GetCanPaste: Boolean;
function GetCanRedo: Boolean;
function GetCanUndo: Boolean;
function GetCharAtCursor: Char;
function GetClipboardText: string;
function GetCommentAtTextPosition(ATextPosition: TBCEditorTextPosition): string;
function GetDisplayCaretPosition: TBCEditorDisplayPosition;
function GetDisplayLineNumber(const ADisplayLineNumber: Integer): Integer;
function GetDisplayPosition(AColumn, ARow: Integer): TBCEditorDisplayPosition;
function GetDisplayTextLineNumber(ADisplayLineNumber: Integer): Integer;
function GetEndOfLine(ALine: PChar): PChar;
function GetHighlighterAttributeAtRowColumn(const ATextPosition: TBCEditorTextPosition; var AToken: string;
var ATokenType: TBCEditorRangeType; var AStart: Integer; var AHighlighterAttribute: TBCEditorHighlighterAttribute): Boolean;
function GetHookedCommandHandlersCount: Integer;
function GetTextCaretPosition: TBCEditorTextPosition;
function GetLeadingExpandedLength(const AStr: string; ABorder: Integer = 0): Integer;
function GetLineIndentLevel(ALine: Integer): Integer;
function GetMatchingToken(ADisplayPosition: TBCEditorDisplayPosition; var AMatch: TBCEditorMatchingPairMatch): TBCEditorMatchingTokenResult;
function GetMouseMoveScrollCursors(AIndex: Integer): HCURSOR;
function GetMouseMoveScrollCursorIndex: Integer;
function GetSelectionAvailable: Boolean;
function GetSelectedText: string;
function GetSearchResultCount: Integer;
function GetSelectionBeginPosition: TBCEditorTextPosition;
function GetSelectionEndPosition: TBCEditorTextPosition;
function GetText: string;
function GetTextBetween(ATextBeginPosition: TBCEditorTextPosition; ATextEndPosition: TBCEditorTextPosition): string;
function GetTextCaretY: Integer;
function GetTextOffset: Integer;
function GetVisibleChars: Integer;
function GetWordAtCursor: string;
function GetWordAtMouse: string;
function GetWordAtTextPosition(ATextPosition: TBCEditorTextPosition): string;
function IsCommentAtCaretPosition: Boolean;
function IsKeywordAtCaretPosition(APOpenKeyWord: PBoolean = nil; AHighlightAfterToken: Boolean = True): Boolean;
function IsKeywordAtCaretPositionOrAfter(ACaretPosition: TBCEditorTextPosition): Boolean;
function IsWordSelected: Boolean;
function LeftSpaceCount(const ALine: string; AWantTabs: Boolean = False): Integer;
function NextSelectedWordPosition: Boolean;
function NextWordPosition: TBCEditorTextPosition; overload;
function NextWordPosition(const ATextPosition: TBCEditorTextPosition): TBCEditorTextPosition; overload;
function OpenClipboard: Boolean;
function PreviousWordPosition: TBCEditorTextPosition; overload;
function PreviousWordPosition(const ATextPosition: TBCEditorTextPosition; APreviousLine: Boolean = False): TBCEditorTextPosition; overload;
function RescanHighlighterRangesFrom(AIndex: Integer): Integer;
function RowColumnToCharIndex(ATextPosition: TBCEditorTextPosition): Integer;
function SearchText(const ASearchText: string; AChanged: Boolean = False): Integer;
function StringWordEnd(const ALine: string; AStart: Integer): Integer;
function StringWordStart(const ALine: string; AStart: Integer): Integer;
procedure ActiveLineChanged(Sender: TObject);
procedure AssignSearchEngine;
procedure AfterSetText(Sender: TObject);
procedure BeforeSetText(Sender: TObject);
procedure CaretChanged(Sender: TObject);
procedure CheckIfAtMatchingKeywords;
procedure ClearCodeFolding;
procedure CodeFoldingCollapse(AFoldRange: TBCEditorCodeFoldingRange);
procedure CodeFoldingLinesDeleted(AFirstLine: Integer; ACount: Integer);
procedure CodeFoldingResetCaches;
procedure CodeFoldingOnChange(AEvent: TBCEditorCodeFoldingChanges);
procedure CodeFoldingUncollapse(AFoldRange: TBCEditorCodeFoldingRange);
procedure CompletionProposalTimerHandler(Sender: TObject);
procedure ComputeCaret(X, Y: Integer);
procedure ComputeScroll(X, Y: Integer);
procedure CreateLineNumbersCache(AResetCache: Boolean = False);
procedure DeflateMinimapRect(var ARect: TRect);
procedure DoBlockComment;
procedure DoCutToClipboard;
procedure DoEndKey(ASelection: Boolean);
procedure DoHomeKey(ASelection: Boolean);
procedure DoInternalUndo;
procedure DoInternalRedo;
procedure DoLineComment;
procedure DoPasteFromClipboard;
procedure DoSelectedText(const AValue: string); overload;
procedure DoSelectedText(APasteMode: TBCEditorSelectionMode; AValue: PChar; AAddToUndoList: Boolean); overload;
procedure DoSelectedText(APasteMode: TBCEditorSelectionMode; AValue: PChar; AAddToUndoList: Boolean;
ATextCaretPosition: TBCEditorTextPosition; AChangeBlockNumber: Integer = 0); overload;
procedure DoShiftTabKey;
procedure DoSyncEdit;
procedure DoTabKey;
procedure DoToggleSelectedCase(const ACommand: TBCEditorCommand);
procedure DoTrimTrailingSpaces(ATextLine: Integer);
procedure DragMinimap(Y: Integer);
procedure DrawCursor(ACanvas: TCanvas);
procedure FindAll(const ASearchText: string = '');
procedure FindWords(const AWord: string; AList: TList; ACaseSensitive: Boolean; AWholeWordsOnly: Boolean);
procedure FontChanged(Sender: TObject);
procedure GetMinimapLeftRight(var ALeft: Integer; var ARight: Integer);
procedure InitCodeFolding;
procedure LinesChanging(Sender: TObject);
procedure MinimapChanged(Sender: TObject);
procedure MouseMoveScrollTimerHandler(Sender: TObject);
procedure MoveCaretAndSelection(const ABeforeTextPosition, AAfterTextPosition: TBCEditorTextPosition; ASelectionCommand: Boolean);
procedure MoveCaretHorizontally(const X: Integer; ASelectionCommand: Boolean);
procedure MoveCaretVertically(const Y: Integer; ASelectionCommand: Boolean);
procedure OpenLink(AURI: string; ARangeType: TBCEditorRangeType);
procedure PreviousSelectedWordPosition;
procedure RefreshFind;
procedure RightMarginChanged(Sender: TObject);
procedure ScrollChanged(Sender: TObject);
procedure ScrollTimerHandler(Sender: TObject);
procedure SearchChanged(AEvent: TBCEditorSearchChanges);
procedure SelectionChanged(Sender: TObject);
procedure SetActiveLine(const AValue: TBCEditorActiveLine);
procedure SetBackgroundColor(const AValue: TColor);
procedure SetBorderStyle(AValue: TBorderStyle);
procedure SetDisplayCaretX(AValue: Integer);
procedure SetDisplayCaretY(AValue: Integer);
procedure SetClipboardText(const AText: string);
procedure SetCodeFolding(AValue: TBCEditorCodeFolding);
procedure SetDefaultKeyCommands;
procedure SetForegroundColor(const AValue: TColor);
procedure SetInsertMode(const AValue: Boolean);
procedure SetTextCaretX(AValue: Integer);
procedure SetTextCaretY(AValue: Integer);
procedure SetKeyCommands(const AValue: TBCEditorKeyCommands);
procedure SetLeftChar(AValue: Integer);
procedure SetLeftMargin(const AValue: TBCEditorLeftMargin);
procedure SetLeftMarginWidth(AValue: Integer);
procedure SetLines(AValue: TBCEditorLines);
procedure SetLineWithRightTrim(ALine: Integer; const ALineText: string);
procedure SetModified(AValue: Boolean);
procedure SetMouseMoveScrollCursors(AIndex: Integer; AValue: HCURSOR);
procedure SetOptions(AValue: TBCEditorOptions);
procedure SetTextCaretPosition(AValue: TBCEditorTextPosition);
procedure SetRightMargin(const AValue: TBCEditorRightMargin);
procedure SetScroll(const AValue: TBCEditorScroll);
procedure SetSearch(const AValue: TBCEditorSearch);
procedure SetSelectedText(const AValue: string);
procedure SetSelectedWord;
procedure SetSelection(const AValue: TBCEditorSelection);
procedure SetSelectionBeginPosition(AValue: TBCEditorTextPosition);
procedure SetSelectionEndPosition(AValue: TBCEditorTextPosition);
procedure SetSpecialChars(const AValue: TBCEditorSpecialChars);
procedure SetSyncEdit(const AValue: TBCEditorSyncEdit);
procedure SetTabs(const AValue: TBCEditorTabs);
procedure SetText(const AValue: string);
procedure SetTextBetween(ATextBeginPosition: TBCEditorTextPosition; ATextEndPosition: TBCEditorTextPosition; const AValue: string);
procedure SetTopLine(AValue: Integer);
procedure SetUndo(const AValue: TBCEditorUndo);
procedure SetWordBlock(ATextPosition: TBCEditorTextPosition);
procedure SetWordWrap(const AValue: TBCEditorWordWrap);
procedure SizeOrFontChanged(const AFontChanged: Boolean);
procedure SpecialCharsChanged(Sender: TObject);
procedure SyncEditChanged(Sender: TObject);
procedure SwapInt(var ALeft, ARight: Integer);
procedure TabsChanged(Sender: TObject);
procedure UndoRedoAdded(Sender: TObject);
procedure UpdateFoldRanges(ACurrentLine, ALineCount: Integer); overload;
procedure UpdateFoldRanges(AFoldRanges: TBCEditorCodeFoldingRanges; ALineCount: Integer); overload;
procedure UpdateModifiedStatus;
procedure UpdateScrollBars;
procedure UpdateWordWrap(const AValue: Boolean);
procedure WMCaptureChanged(var AMessage: TMessage); message WM_CAPTURECHANGED;
procedure WMChar(var AMessage: TWMChar); message WM_CHAR;
procedure WMClear(var AMessage: TMessage); message WM_CLEAR;
procedure WMCopy(var AMessage: TMessage); message WM_COPY;
procedure WMCut(var AMessage: TMessage); message WM_CUT;
procedure WMDropFiles(var AMessage: TMessage); message WM_DROPFILES;
procedure WMEraseBkgnd(var AMessage: TMessage); message WM_ERASEBKGND;
procedure WMGetDlgCode(var AMessage: TWMGetDlgCode); message WM_GETDLGCODE;
procedure WMGetText(var AMessage: TWMGetText); message WM_GETTEXT;
procedure WMGetTextLength(var AMessage: TWMGetTextLength); message WM_GETTEXTLENGTH;
procedure WMHScroll(var AMessage: TWMScroll); message WM_HSCROLL;
procedure WMIMEChar(var AMessage: TMessage); message WM_IME_CHAR;
procedure WMIMEComposition(var AMessage: TMessage); message WM_IME_COMPOSITION;
procedure WMIMENotify(var AMessage: TMessage); message WM_IME_NOTIFY;
procedure WMKillFocus(var AMessage: TWMKillFocus); message WM_KILLFOCUS;
{$IFDEF USE_VCL_STYLES}
procedure WMNCPaint(var AMessage: TMessage); message WM_NCPAINT;
{$ENDIF}
procedure WMPaste(var AMessage: TMessage); message WM_PASTE;
procedure WMSetCursor(var AMessage: TWMSetCursor); message WM_SETCURSOR;
procedure WMSetFocus(var AMessage: TWMSetFocus); message WM_SETFOCUS;
procedure WMSetText(var AMessage: TWMSetText); message WM_SETTEXT;
procedure WMSize(var AMessage: TWMSize); message WM_SIZE;
procedure WMUndo(var AMessage: TMessage); message WM_UNDO;
procedure WMVScroll(var AMessage: TWMScroll); message WM_VSCROLL;
procedure WordWrapChanged(Sender: TObject);
protected
function DoMouseWheel(AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint): Boolean; override;
function DoOnReplaceText(const ASearch, AReplace: string; ALine, AColumn: Integer; DeleteLine: Boolean): TBCEditorReplaceAction;
function DoSearchMatchNotFoundWraparoundDialog: Boolean; virtual;
function GetReadOnly: Boolean; virtual;
function GetSelectionLength: Integer;
function PixelsToNearestRowColumn(X, Y: Integer): TBCEditorDisplayPosition;
function PixelsToRowColumn(X, Y: Integer): TBCEditorDisplayPosition;
function RowColumnToPixels(const ADisplayPosition: TBCEditorDisplayPosition): TPoint;
procedure ChainLinesChanged(Sender: TObject);
procedure ChainLinesChanging(Sender: TObject);
procedure ChainLinesCleared(Sender: TObject);
procedure ChainLinesDeleted(Sender: TObject; AIndex: Integer; ACount: Integer);
procedure ChainLinesInserted(Sender: TObject; AIndex: Integer; ACount: Integer);
procedure ChainLinesPutted(Sender: TObject; AIndex: Integer; ACount: Integer);
procedure ChainUndoRedoAdded(Sender: TObject);
procedure CreateParams(var AParams: TCreateParams); override;
procedure CreateWnd; override;
procedure DblClick; override;
procedure DecPaintLock;
procedure DestroyWnd; override;
procedure DoBlockIndent;
procedure DoBlockUnindent;
procedure DoChange; virtual;
procedure DoCopyToClipboard(const AText: string);
procedure DoExecuteCompletionProposal; virtual;
procedure DoKeyPressW(var AMessage: TWMKey);
procedure DoOnAfterBookmarkPlaced;
procedure DoOnAfterClearBookmark;
procedure DoOnBeforeBookmarkPlaced(var ABookmark: TBCEditorBookmark);
procedure DoOnBeforeClearBookmark(var ABookmark: TBCEditorBookmark);
procedure DoOnCommandProcessed(ACommand: TBCEditorCommand; AChar: Char; AData: pointer);
procedure DoOnLeftMarginClick(AButton: TMouseButton; AShift: TShiftState; X, Y: Integer);
procedure DoOnMinimapClick(AButton: TMouseButton; X, Y: Integer);
procedure DoOnSearchMapClick(AButton: TMouseButton; X, Y: Integer);
procedure DoOnPaint;
procedure DoOnProcessCommand(var ACommand: TBCEditorCommand; var AChar: Char; AData: pointer); virtual;
procedure DoSearchStringNotFoundDialog; virtual;
procedure DoTripleClick;
procedure DragCanceled; override;
procedure DragOver(ASource: TObject; X, Y: Integer; AState: TDragState; var AAccept: Boolean); override;
procedure FreeHintForm(var AForm: TBCEditorCodeFoldingHintForm);
procedure FreeCompletionProposalPopupWindow;
procedure HideCaret;
procedure IncPaintLock;
procedure InvalidateRect(const ARect: TRect);
procedure KeyDown(var AKey: Word; AShift: TShiftState); override;
procedure KeyPressW(var AKey: Char);
procedure KeyUp(var AKey: Word; AShift: TShiftState); override;
procedure LinesChanged(Sender: TObject);
procedure LinesHookChanged;
procedure LinesBeforeDeleted(Sender: TObject; AIndex: Integer; ACount: Integer);
procedure LinesBeforeInserted(Sender: TObject; AIndex: Integer; ACount: Integer);
procedure LinesBeforePutted(Sender: TObject; AIndex: Integer; ACount: Integer);
procedure LinesCleared(Sender: TObject);
procedure LinesDeleted(Sender: TObject; AIndex: Integer; ACount: Integer);
procedure LinesInserted(Sender: TObject; AIndex: Integer; ACount: Integer);
procedure LinesPutted(Sender: TObject; AIndex: Integer; ACount: Integer);
procedure Loaded; override;
procedure MarkListChange(Sender: TObject);
procedure MouseDown(AButton: TMouseButton; AShift: TShiftState; X, Y: Integer); override;
procedure MouseMove(AShift: TShiftState; X, Y: Integer); override;
procedure MouseUp(AButton: TMouseButton; AShift: TShiftState; X, Y: Integer); override;
procedure NotifyHookedCommandHandlers(AAfterProcessing: Boolean; var ACommand: TBCEditorCommand; var AChar: Char;
AData: pointer);
procedure Paint; override;
procedure PaintCodeFolding(AClipRect: TRect; AFirstRow, ALastRow: Integer);
procedure PaintCodeFoldingLine(AClipRect: TRect; ALine: Integer);
procedure PaintCodeFoldingCollapsedLine(AFoldRange: TBCEditorCodeFoldingRange; ALineRect: TRect);
procedure PaintCodeFoldingCollapseMark(AFoldRange: TBCEditorCodeFoldingRange; ATokenPosition, ATokenLength, ALine,
AScrolledXBy: Integer; ALineRect: TRect);
procedure PaintGuides(AFirstRow, ALastRow: Integer; AMinimap: Boolean);
procedure PaintLeftMargin(const AClipRect: TRect; AFirstLine, ALastTextLine, ALastLine: Integer);
procedure PaintMinimapIndicator(AClipRect: TRect);
procedure PaintMinimapShadow(AClipRect: TRect);
procedure PaintMouseMoveScrollPoint;
procedure PaintRightMarginMove;
procedure PaintSearchMap(AClipRect: TRect);
procedure PaintSearchResults;
procedure PaintSpecialChars(ALine, AFirstColumn: Integer; ALineRect: TRect);
procedure PaintSyncItems;
procedure PaintTextLines(AClipRect: TRect; AFirstRow, ALastRow: Integer; AMinimap: Boolean);
procedure RecalculateCharExtent;
procedure RedoItem;
procedure ResetCaret(ADoUpdate: Boolean = True);
procedure ScanCodeFoldingRanges; virtual;
procedure ScanMatchingPair;
procedure SetAlwaysShowCaret(const AValue: Boolean);
procedure SetDisplayCaretPosition(AValue: TBCEditorDisplayPosition);
procedure SetName(const AValue: TComponentName); override;
procedure SetReadOnly(AValue: Boolean); virtual;
procedure SetSelectedTextEmpty(const AChangeString: string = '');
procedure SetWantReturns(AValue: Boolean);
procedure ShowCaret;
procedure UndoItem;
procedure UpdateMouseCursor;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
{$IFDEF USE_ALPHASKINS}
procedure AfterConstruction; override;
{$ENDIF}
function CaretInView: Boolean;
function CreateFileStream(const AFileName: string): TStream; virtual;
function DisplayToTextPosition(const ADisplayPosition: TBCEditorDisplayPosition): TBCEditorTextPosition;
function GetColorsFileName(const AFileName: string): string;
function GetHighlighterFileName(const AFileName: string): string;
function FindPrevious: Boolean;
function FindNext(AChanged: Boolean = False): Boolean;
function GetBookmark(ABookmark: Integer; var ATextPosition: TBCEditorTextPosition): Boolean;
function GetPositionOfMouse(out ATextPosition: TBCEditorTextPosition): Boolean;
function GetWordAtPixels(X, Y: Integer): string;
function IsBookmark(ABookmark: Integer): Boolean;
function IsCommentChar(AChar: Char): Boolean;
function IsTextPositionInSelection(const ATextPosition: TBCEditorTextPosition): Boolean;
function IsWordBreakChar(AChar: Char): Boolean;
function IsWordChar(AChar: Char): Boolean;
function ReplaceText(const ASearchText: string; const AReplaceText: string): Integer;
function SplitTextIntoWords(AStringList: TStrings; ACaseSensitive: Boolean): string;
function TextToDisplayPosition(const ATextPosition: TBCEditorTextPosition; ARealWidth: Boolean = True): TBCEditorDisplayPosition;
function TranslateKeyCode(ACode: Word; AShift: TShiftState; var AData: pointer): TBCEditorCommand;
function WordEnd: TBCEditorTextPosition; overload;
function WordEnd(const ATextPosition: TBCEditorTextPosition): TBCEditorTextPosition; overload;
function WordStart: TBCEditorTextPosition; overload;
function WordStart(const ATextPosition: TBCEditorTextPosition): TBCEditorTextPosition; overload;
procedure AddKeyCommand(ACommand: TBCEditorCommand; AShift: TShiftState; AKey: Word; ASecondaryShift: TShiftState = []; ASecondaryKey: Word = 0);
procedure AddKeyDownHandler(AHandler: TKeyEvent);
procedure AddKeyPressHandler(AHandler: TBCEditorKeyPressWEvent);
procedure AddKeyUpHandler(AHandler: TKeyEvent);
procedure AddMouseCursorHandler(AHandler: TBCEditorMouseCursorEvent);
procedure AddMouseDownHandler(AHandler: TMouseEvent);
procedure AddMouseUpHandler(AHandler: TMouseEvent);
procedure BeginUndoBlock;
procedure BeginUpdate;
procedure CaretZero;
procedure ChainEditor(AEditor: TBCBaseEditor);
procedure Clear;
procedure ClearBookmark(ABookmark: Integer);
procedure ClearBookmarks;
procedure ClearMarks;
procedure ClearMatchingPair;
procedure ClearSelection;
procedure ClearUndo;
procedure CodeFoldingCollapseAll;
procedure CodeFoldingCollapseLevel(ALevel: Integer);
procedure CodeFoldingUncollapseAll;
procedure CodeFoldingUncollapseLevel(ALevel: Integer; ANeedInvalidate: Boolean = True);
procedure CommandProcessor(ACommand: TBCEditorCommand; AChar: Char; AData: pointer);
procedure CopyToClipboard;
procedure CutToClipboard;
procedure DeleteLines(const ALineNumber: Integer; const ACount: Integer);
procedure DeleteWhitespace;
procedure DoUndo;
procedure DragDrop(ASource: TObject; X, Y: Integer); override;
procedure EndUndoBlock;
procedure EndUpdate;
procedure EnsureCursorPositionVisible(AForceToMiddle: Boolean = False; AEvenIfVisible: Boolean = False);
procedure ExecuteCommand(ACommand: TBCEditorCommand; AChar: Char; AData: Pointer); virtual;
procedure ExportToHTML(const AFileName: string; const ACharSet: string = ''; AEncoding: System.SysUtils.TEncoding = nil); overload;
procedure ExportToHTML(AStream: TStream; const ACharSet: string = ''; AEncoding: System.SysUtils.TEncoding = nil); overload;
procedure GotoBookmark(ABookmark: Integer);
procedure GotoLineAndCenter(ATextLine: Integer);
procedure HookEditorLines(ALines: TBCEditorLines; AUndo, ARedo: TBCEditorUndoList);
procedure InsertLine(const ALineNumber: Integer; const AValue: string);
procedure InsertBlock(const ABlockBeginPosition, ABlockEndPosition: TBCEditorTextPosition; AChangeStr: PChar; AAddToUndoList: Boolean);
procedure InvalidateLeftMargin;
procedure InvalidateLeftMarginLine(ALine: Integer);
procedure InvalidateLeftMarginLines(AFirstLine, ALastLine: Integer);
procedure InvalidateLine(ALine: Integer);
procedure InvalidateLines(AFirstLine, ALastLine: Integer);
procedure InvalidateMinimap;
procedure InvalidateSelection;
procedure LeftMarginChanged(Sender: TObject);
procedure LoadFromFile(const AFileName: string; AEncoding: System.SysUtils.TEncoding = nil);
procedure LoadFromStream(AStream: TStream; AEncoding: System.SysUtils.TEncoding = nil);
procedure LockUndo;
procedure Notification(AComponent: TComponent; AOperation: TOperation); override;
procedure PasteFromClipboard;
procedure DoRedo;
procedure RegisterCommandHandler(const AHookedCommandEvent: TBCEditorHookedCommandEvent; AHandlerData: Pointer);
procedure RemoveChainedEditor;
procedure RemoveKeyDownHandler(AHandler: TKeyEvent);
procedure RemoveKeyPressHandler(AHandler: TBCEditorKeyPressWEvent);
procedure RemoveKeyUpHandler(AHandler: TKeyEvent);
procedure RemoveMouseCursorHandler(AHandler: TBCEditorMouseCursorEvent);
procedure RemoveMouseDownHandler(AHandler: TMouseEvent);
procedure RemoveMouseUpHandler(AHandler: TMouseEvent);
procedure ReplaceLine(const ALineNumber: Integer; const AValue: string);
procedure RescanCodeFoldingRanges;
procedure SaveToFile(const AFileName: string; AEncoding: System.SysUtils.TEncoding = nil);
procedure SaveToStream(AStream: TStream; AEncoding: System.SysUtils.TEncoding = nil);
procedure SelectAll;
procedure SetBookmark(AIndex: Integer; ATextPosition: TBCEditorTextPosition);
procedure SetCaretAndSelection(ACaretPosition, ABlockBeginPosition, ABlockEndPosition: TBCEditorTextPosition);
procedure SetFocus; override;
procedure SetLineColor(ALine: Integer; AForegroundColor, ABackgroundColor: TColor);
procedure SetLineColorToDefault(ALine: Integer);
procedure Sort(ASortOrder: TBCEditorSortOrder = soToggle);
procedure ToggleBookmark(AIndex: Integer = -1);
procedure ToggleSelectedCase(ACase: TBCEditorCase = cNone);
procedure UnhookEditorLines;
procedure UnlockUndo;
procedure UnregisterCommandHandler(AHookedCommandEvent: TBCEditorHookedCommandEvent);
procedure UpdateCaret;
procedure WndProc(var AMessage: TMessage); override;
property ActiveLine: TBCEditorActiveLine read FActiveLine write SetActiveLine;
property BackgroundColor: TColor read FBackgroundColor write SetBackgroundColor default clWindow;
property AllCodeFoldingRanges: TBCEditorAllCodeFoldingRanges read FAllCodeFoldingRanges;
property AlwaysShowCaret: Boolean read FAlwaysShowCaret write SetAlwaysShowCaret;
property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle;
property CanPaste: Boolean read GetCanPaste;
property CanRedo: Boolean read GetCanRedo;
property CanUndo: Boolean read GetCanUndo;
property Canvas;
property Caret: TBCEditorCaret read FCaret write FCaret;
property CharAtCursor: Char read GetCharAtCursor;
property DisplayCaretX: Integer read FDisplayCaretX write SetDisplayCaretX;
property DisplayCaretPosition: TBCEditorDisplayPosition read GetDisplayCaretPosition write SetDisplayCaretPosition;
property DisplayCaretY: Integer read FDisplayCaretY write SetDisplayCaretY;
property CharWidth: Integer read FCharWidth;
property CodeFolding: TBCEditorCodeFolding read FCodeFolding write SetCodeFolding;
property CompletionProposal: TBCEditorCompletionProposal read FCompletionProposal write FCompletionProposal;
property Cursor default crIBeam;
property Directories: TBCEditorDirectories read FDirectories write FDirectories;
property Encoding: TEncoding read FEncoding write FEncoding;
property Font;
property ForegroundColor: TColor read FForegroundColor write SetForegroundColor default clWindowText;
property Highlighter: TBCEditorHighlighter read FHighlighter;
property InsertMode: Boolean read FInsertMode write SetInsertMode default True;
property IsScrolling: Boolean read FIsScrolling;
property KeyCommands: TBCEditorKeyCommands read FKeyCommands write SetKeyCommands stored False;
property LeftChar: Integer read FLeftChar write SetLeftChar;
property LeftMargin: TBCEditorLeftMargin read FLeftMargin write SetLeftMargin;
property LineHeight: Integer read FLineHeight;
property LineNumbersCount: Integer read FLineNumbersCount;
property Lines: TBCEditorLines read FLines write SetLines;
property LineSpacing: TBCEditorLineSpacing read FLinespacing write FLinespacing;
property Marks: TBCEditorBookmarkList read FMarkList;
property MatchingPair: TBCEditorMatchingPair read FMatchingPair write FMatchingPair;
property Minimap: TBCEditorMinimap read FMinimap write FMinimap;
property Modified: Boolean read FModified write SetModified;
property MouseMoveScrollCursors[AIndex: Integer]: HCURSOR read GetMouseMoveScrollCursors write SetMouseMoveScrollCursors;
property OnAfterBookmarkPanelPaint: TBCEditorBookmarkPanelPaintEvent read FOnAfterBookmarkPanelPaint write FOnAfterBookmarkPanelPaint;
property OnAfterBookmarkPlaced: TNotifyEvent read FOnAfterBookmarkPlaced write FOnAfterBookmarkPlaced;
property OnAfterClearBookmark: TNotifyEvent read FOnAfterClearBookmark write FOnAfterClearBookmark;
property OnAfterLinePaint: TBCEditorLinePaintEvent read FOnAfterLinePaint write FOnAfterLinePaint;
property OnBeforeBookmarkPlaced: TBCEditorBookmarkEvent read FOnBeforeBookmarkPlaced write FOnBeforeBookmarkPlaced;
property OnBeforeClearBookmark: TBCEditorBookmarkEvent read FOnBeforeClearBookmark write FOnBeforeClearBookmark;
property OnBeforeBookmarkPanelPaint: TBCEditorBookmarkPanelPaintEvent read FOnBeforeBookmarkPanelPaint write FOnBeforeBookmarkPanelPaint;
property OnBookmarkPanelLinePaint: TBCEditorBookmarkPanelLinePaintEvent read FOnBookmarkPanelLinePaint write FOnBookmarkPanelLinePaint;
property OnCaretChanged: TBCEditorCaretChangedEvent read FOnCaretChanged write FOnCaretChanged;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnCommandProcessed: TBCEditorProcessCommandEvent read FOnCommandProcessed write FOnCommandProcessed;
property OnContextHelp: TBCEditorContextHelpEvent read FOnContextHelp write FOnContextHelp;
property OnCreateFileStream: TBCEditorCreateFileStreamEvent read FOnCreateFileStream write FOnCreateFileStream;
property OnCustomLineColors: TBCEditorCustomLineColorsEvent read FOnCustomLineColors write FOnCustomLineColors;
property OnCustomTokenAttribute: TBCEditorCustomTokenAttributeEvent read FOnCustomTokenAttribute write FOnCustomTokenAttribute;
property OnDropFiles: TBCEditorDropFilesEvent read FOnDropFiles write FOnDropFiles;
property OnKeyPress: TBCEditorKeyPressWEvent read FOnKeyPressW write FOnKeyPressW;
property OnLeftMarginClick: TLeftMarginClickEvent read FOnLeftMarginClick write FOnLeftMarginClick;
property OnLinesDeleted: TStringListChangeEvent read FOnLinesDeleted write FOnLinesDeleted;
property OnLinesInserted: TStringListChangeEvent read FOnLinesInserted write FOnLinesInserted;
property OnLinesPutted: TStringListChangeEvent read FOnLinesPutted write FOnLinesPutted;
property OnPaint: TBCEditorPaintEvent read FOnPaint write FOnPaint;
property OnProcessCommand: TBCEditorProcessCommandEvent read FOnProcessCommand write FOnProcessCommand;
property OnProcessUserCommand: TBCEditorProcessCommandEvent read FOnProcessUserCommand write FOnProcessUserCommand;
property OnReplaceText: TBCEditorReplaceTextEvent read FOnReplaceText write FOnReplaceText;
property OnRightMarginMouseUp: TNotifyEvent read FOnRightMarginMouseUp write FOnRightMarginMouseUp;
property OnSelectionChanged: TNotifyEvent read FOnSelectionChanged write FOnSelectionChanged;
property OnScroll: TBCEditorScrollEvent read FOnScroll write FOnScroll;
property Options: TBCEditorOptions read FOptions write SetOptions default BCEDITOR_DEFAULT_OPTIONS;
property PaintLock: Integer read FPaintLock;
property ParentColor default False;
property ParentFont default False;
property ReadOnly: Boolean read GetReadOnly write SetReadOnly default False;
property TextCaretPosition: TBCEditorTextPosition read GetTextCaretPosition write SetTextCaretPosition;
property RedoList: TBCEditorUndoList read FRedoList;
property Replace: TBCEditorReplace read FReplace write FReplace;
property RightMargin: TBCEditorRightMargin read FRightMargin write SetRightMargin;
property Scroll: TBCEditorScroll read FScroll write SetScroll;
property Search: TBCEditorSearch read FSearch write SetSearch;
property SearchResultCount: Integer read GetSearchResultCount;
property Selection: TBCEditorSelection read FSelection write SetSelection;
property SelectionAvailable: Boolean read GetSelectionAvailable;
property SelectionBeginPosition: TBCEditorTextPosition read GetSelectionBeginPosition write SetSelectionBeginPosition;
property SelectionEndPosition: TBCEditorTextPosition read GetSelectionEndPosition write SetSelectionEndPosition;
property SelectedText: string read GetSelectedText write SetSelectedText;
{$IFDEF USE_ALPHASKINS}
property SkinData: TsScrollWndData read FCommonData write FCommonData;
{$ENDIF}
property SpecialChars: TBCEditorSpecialChars read FSpecialChars write SetSpecialChars;
property SyncEdit: TBCEditorSyncEdit read FSyncEdit write SetSyncEdit;
property Tabs: TBCEditorTabs read FTabs write SetTabs;
property TabStop default True;
property Text: string read GetText write SetText;
property TextBetween[ATextBeginPosition: TBCEditorTextPosition; ATextEndPosition: TBCEditorTextPosition]: string read GetTextBetween write SetTextBetween;
property TopLine: Integer read FTopLine write SetTopLine;
property Undo: TBCEditorUndo read FUndo write SetUndo;
property UndoList: TBCEditorUndoList read FUndoList;
property URIOpener: Boolean read FURIOpener write FURIOpener;
property VisibleChars: Integer read GetVisibleChars;
property VisibleLines: Integer read FVisibleLines;
property WantReturns: Boolean read FWantReturns write SetWantReturns default True;
property WordAtCursor: string read GetWordAtCursor;
property WordAtMouse: string read GetWordAtMouse;
property WordWrap: TBCEditorWordWrap read FWordWrap write SetWordWrap;
end;
EBCEditorBaseException = class(Exception);
implementation
{$R BCEditor.res}
uses
Winapi.ShellAPI, Winapi.Imm, System.Math, System.Types, Vcl.Clipbrd, System.Character, Vcl.Menus,
BCEditor.Editor.LeftMargin.Border, BCEditor.Editor.LeftMargin.LineNumbers, BCEditor.Editor.Scroll.Hint,
BCEditor.Editor.Search.Map, BCEditor.Editor.Undo.Item, BCEditor.Editor.Utils, BCEditor.Encoding, BCEditor.Language,
BCEditor.Highlighter.Rules, BCEditor.Export.HTML{$IFDEF USE_VCL_STYLES}, Vcl.Themes, BCEditor.StyleHooks{$ENDIF}
{$IFDEF USE_ALPHASKINS}, Winapi.CommCtrl, sVCLUtils, sMessages, sConst, sSkinProps{$ENDIF};
type
TBCEditorAccessWinControl = class(TWinControl);
var
GScrollHintWindow: THintWindow;
GRightMarginHintWindow: THintWindow;
function GetScrollHint: THintWindow;
begin
if not Assigned(GScrollHintWindow) then
begin
GScrollHintWindow := THintWindow.Create(Application);
GScrollHintWindow.DoubleBuffered := True;
end;
Result := GScrollHintWindow;
end;
function GetRightMarginHint: THintWindow;
begin
if not Assigned(GRightMarginHintWindow) then
begin
GRightMarginHintWindow := THintWindow.Create(Application);
GRightMarginHintWindow.DoubleBuffered := True;
end;
Result := GRightMarginHintWindow;
end;
{ TBCBaseEditor }
constructor TBCBaseEditor.Create(AOwner: TComponent);
var
i: Integer;
begin
inherited Create(AOwner);
{$IFDEF USE_ALPHASKINS}
FCommonData := TsScrollWndData.Create(Self, True);
FCommonData.COC := COC_TsMemo;
if FCommonData.SkinSection = '' then
FCommonData.SkinSection := s_Edit;
{$ENDIF}
Height := 150;
Width := 200;
Cursor := crIBeam;
Color := clWindow;
DoubleBuffered := False;
ControlStyle := ControlStyle + [csOpaque, csSetCaption, csNeedsBorderPaint];
FBackgroundColor := clWindow;
FForegroundColor := clWindowText;
FBorderStyle := bsSingle;
FDoubleClickTime := GetDoubleClickTime;
FLastSortOrder := soDesc;
FResetLineNumbersCache := True;
FSelectedCaseText := '';
FURIOpener := False;
FCodeFoldingLock := False;
{ Code folding }
FAllCodeFoldingRanges := TBCEditorAllCodeFoldingRanges.Create;
FCodeFolding := TBCEditorCodeFolding.Create;
FCodeFolding.OnChange := CodeFoldingOnChange;
{ Directory }
FDirectories := TBCEditorDirectories.Create;
{ Matching pair }
FMatchingPair := TBCEditorMatchingPair.Create;
{ Line spacing }
FLinespacing := TBCEditorLineSpacing.Create;
FLinespacing.OnChange := FontChanged;
{ Special chars }
FSpecialChars := TBCEditorSpecialChars.Create;
FSpecialChars.OnChange := SpecialCharsChanged;
{ Caret }
FCaret := TBCEditorCaret.Create;
FCaret.OnChange := CaretChanged;
{ Text buffer }
FLines := TBCEditorLines.Create(Self);
FLines.OnBeforeSetText := BeforeSetText;
FLines.OnAfterSetText := AfterSetText;
FOriginalLines := FLines;
with FLines do
begin
OnChange := LinesChanged;
OnChanging := LinesChanging;
OnCleared := LinesCleared;
OnDeleted := LinesDeleted;
OnInserted := LinesInserted;
OnPutted := LinesPutted;
OnBeforePutted := LinesBeforePutted;
end;
{ Font }
FFontDummy := TFont.Create;
with FFontDummy do
begin
Name := 'Courier New';
Size := 10;
end;
Font.Assign(FFontDummy);
Font.OnChange := FontChanged;
{ Painting }
FBufferBmp := Vcl.Graphics.TBitmap.Create;
FMinimapBufferBmp := Vcl.Graphics.TBitmap.Create;
FTextDrawer := TBCEditorTextDrawer.Create([fsBold], FFontDummy);
ParentFont := False;
ParentColor := False;
{ Undo & Redo }
FUndoRedo := False;
FUndo := TBCEditorUndo.Create;
FUndoList := TBCEditorUndoList.Create;
FUndoList.OnAddedUndo := UndoRedoAdded;
FOriginalUndoList := FUndoList;
FRedoList := TBCEditorUndoList.Create;
FRedoList.OnAddedUndo := UndoRedoAdded;
FOriginalRedoList := FRedoList;
FCommandDrop := False;
{ Active line, selection }
FSelection := TBCEditorSelection.Create;
FSelection.OnChange := SelectionChanged;
{ Bookmarks }
FMarkList := TBCEditorBookmarkList.Create(Self);
FMarkList.OnChange := MarkListChange;
{ LeftMargin mast be initialized strongly after FTextDrawer initialization }
FLeftMargin := TBCEditorLeftMargin.Create(Self);
FLeftMargin.OnChange := LeftMarginChanged;
{ Right edge }
FRightMargin := TBCEditorRightMargin.Create;
FRightMargin.OnChange := RightMarginChanged;
{ Tabs }
TabStop := True;
FTabs := TBCEditorTabs.Create;
FTabs.OnChange := TabsChanged;
{ Text }
FInsertMode := True;
FKeyboardHandler := TBCEditorKeyboardHandler.Create;
FKeyCommands := TBCEditorKeyCommands.Create(Self);
SetDefaultKeyCommands;
FWantReturns := True;
FLeftChar := 1;
FTopLine := 1;
FDisplayCaretX := 1;
FDisplayCaretY := 1;
FSelectionBeginPosition.Char := 1;
FSelectionBeginPosition.Line := 1;
FSelectionEndPosition := FSelectionBeginPosition;
FOptions := BCEDITOR_DEFAULT_OPTIONS;
{ Scroll }
FScrollTimer := TTimer.Create(Self);
FScrollTimer.Enabled := False;
FScrollTimer.Interval := 100;
FScrollTimer.OnTimer := ScrollTimerHandler;
{ Scroll }
FMouseMoveScrollTimer := TTimer.Create(Self);
FMouseMoveScrollTimer.Enabled := False;
FMouseMoveScrollTimer.Interval := 100;
FMouseMoveScrollTimer.OnTimer := MouseMoveScrollTimerHandler;
{ Completion proposal }
FCompletionProposal := TBCEditorCompletionProposal.Create(Self);
FCompletionProposalTimer := TTimer.Create(Self);
FCompletionProposalTimer.Enabled := False;
FCompletionProposalTimer.OnTimer := CompletionProposalTimerHandler;
{ Search }
FSearch := TBCEditorSearch.Create;
FSearch.OnChange := SearchChanged;
AssignSearchEngine;
FReplace := TBCEditorReplace.Create;
{ Scroll }
FScroll := TBCEditorScroll.Create;
FScroll.OnChange := ScrollChanged;
{ Minimap }
FMinimapIndicatorBlendFunction.BlendOp := AC_SRC_OVER;
FMinimapIndicatorBlendFunction.BlendFlags := 0;
FMinimapIndicatorBlendFunction.AlphaFormat := 0;
FMinimapIndicatorBitmap := Vcl.Graphics.TBitmap.Create;
FMinimapShadowBlendFunction.BlendOp := AC_SRC_OVER;
FMinimapShadowBlendFunction.BlendFlags := 0;
FMinimapShadowBlendFunction.AlphaFormat := AC_SRC_ALPHA;
FMinimapShadowBitmap := Vcl.Graphics.TBitmap.Create;
FMinimapShadowBitmap.PixelFormat := pf32Bit;
FMinimap := TBCEditorMinimap.Create;
FMinimap.OnChange := MinimapChanged;
{ Active line }
FActiveLine := TBCEditorActiveLine.Create;
FActiveLine.OnChange := ActiveLineChanged;
{ Word wrap }
FWordWrap := TBCEditorWordWrap.Create;
FWordWrap.OnChange := WordWrapChanged;
{ Sync edit }
FSyncEdit := TBCEditorSyncEdit.Create;
FSyncEdit.OnChange := SyncEditChanged;
{ Do update character constraints }
FontChanged(nil);
TabsChanged(nil);
{ Text }
FTextOffset := GetTextOffset;
{ Highlighter }
FHighlighter := TBCEditorHighlighter.Create(Self);
{ Mouse wheel scroll cursors }
for i := 0 to 7 do
FMouseMoveScrollCursors[i] := LoadCursor(HInstance, PChar(BCEDITOR_MOUSE_MOVE_SCROLL + IntToStr(i)));
end;
destructor TBCBaseEditor.Destroy;
begin
{$IFDEF USE_ALPHASKINS}
if FScrollWnd <> nil then
begin
FScrollWnd.Free;
FScrollWnd := nil;
end;
if Assigned(FCommonData) then
begin
FCommonData.Free;
FCommonData := nil;
end;
{$ENDIF}
ClearCodeFolding;
FCodeFolding.Free;
FDirectories.Free;
FAllCodeFoldingRanges.Free;
FHighlighter.Free;
FHighlighter := nil;
if Assigned(FChainedEditor) or (FLines <> FOriginalLines) then
RemoveChainedEditor;
FreeCompletionProposalPopupWindow;
{ Do not use FreeAndNil, it first nils and then frees causing problems with code accessing FHookedCommandHandlers
while destruction }
FHookedCommandHandlers.Free;
FHookedCommandHandlers := nil;
FMarkList.Free;
FKeyCommands.Free;
FKeyCommands := nil;
FKeyboardHandler.Free;
FSelection.Free;
FOriginalUndoList.Free;
FOriginalRedoList.Free;
FLeftMargin.Free;
FLeftMargin := nil; { notification has a check }
FMinimapIndicatorBitmap.Free;
FMinimapShadowBitmap.Free;
FMinimap.Free;
FWordWrap.Free;
FTextDrawer.Free;
FInternalBookmarkImage.Free;
FFontDummy.Free;
FOriginalLines.Free;
FBufferBmp.Free;
FMinimapBufferBmp.Free;
FActiveLine.Free;
FRightMargin.Free;
FScroll.Free;
FSearch.Free;
FReplace.Free;
FTabs.Free;
FUndo.Free;
FLinespacing.Free;
FSpecialChars.Free;
FCaret.Free;
FMatchingPair.Free;
FCompletionProposal.Free;
FSyncEdit.Free;
if Assigned(FSearchEngine) then
begin
FSearchEngine.Free;
FSearchEngine := nil;
end;
if Assigned(FCodeFoldingHintForm) then
FCodeFoldingHintForm.Release;
inherited Destroy;
end;
{ Private declarations }
function TBCBaseEditor.AddMultiByteFillerChars(AText: PChar; ALength: Integer): string;
var
i: Integer;
LCharCount: Integer;
begin
Result := '';
for i := 0 to ALength - 1 do
begin
if Ord(AText[i]) < 128 then
LCharCount := 1
else
LCharCount := FTextDrawer.GetCharCount(@AText[i]);
Result := Result + AText[i];
if LCharCount > 1 then
Result := Result + StringOfChar(BCEDITOR_FILLER_CHAR, LCharCount - 1);
end;
end;
function TBCBaseEditor.CodeFoldingCollapsableFoldRangeForLine(ALine: Integer): TBCEditorCodeFoldingRange;
var
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
Result := nil;
LCodeFoldingRange := CodeFoldingRangeForLine(ALine);
if Assigned(LCodeFoldingRange) and LCodeFoldingRange.Collapsable then
Result := LCodeFoldingRange;
end;
function TBCBaseEditor.CodeFoldingFoldRangeForLineTo(ALine: Integer): TBCEditorCodeFoldingRange;
var
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
Result := nil;
if (ALine > 0) and (ALine < Length(FCodeFoldingRangeToLine)) then
begin
LCodeFoldingRange := FCodeFoldingRangeToLine[ALine];
if Assigned(LCodeFoldingRange) then
if (LCodeFoldingRange.ToLine = ALine) and not LCodeFoldingRange.ParentCollapsed then
Result := LCodeFoldingRange;
end;
end;
function TBCBaseEditor.CodeFoldingLineInsideRange(ALine: Integer): TBCEditorCodeFoldingRange;
var
LLength: Integer;
begin
Result := nil;
LLength := Length(FCodeFoldingRangeFromLine) - 1;
if ALine > LLength then
ALine := LLength;
while (ALine > 0) and not Assigned(FCodeFoldingRangeFromLine[ALine]) do
Dec(ALine);
if (ALine > 0) and Assigned(FCodeFoldingRangeFromLine[ALine]) then
Result := FCodeFoldingRangeFromLine[ALine]
end;
function TBCBaseEditor.CodeFoldingRangeForLine(ALine: Integer): TBCEditorCodeFoldingRange;
begin
Result := nil;
if (ALine > 0) and (ALine < Length(FCodeFoldingRangeFromLine)) then
Result := FCodeFoldingRangeFromLine[ALine]
end;
function TBCBaseEditor.CodeFoldingTreeEndForLine(ALine: Integer): Boolean;
begin
Result := False;
if (ALine > 0) and (ALine < Length(FCodeFoldingRangeToLine)) then
Result := Assigned(FCodeFoldingRangeToLine[ALine]);
end;
function TBCBaseEditor.CodeFoldingTreeLineForLine(ALine: Integer): Boolean;
begin
Result := False;
if (ALine > 0) and (ALine < Length(FCodeFoldingTreeLine)) then
Result := FCodeFoldingTreeLine[ALine]
end;
function TBCBaseEditor.DoOnCodeFoldingHintClick(X, Y: Integer): Boolean;
var
LFoldRange: TBCEditorCodeFoldingRange;
LDisplayPosition: TBCEditorDisplayPosition;
LPoint: TPoint;
LScrolledXBy: Integer;
LCollapseMarkRect: TRect;
begin
Result := True;
LDisplayPosition := PixelsToNearestRowColumn(X, Y);
LFoldRange := CodeFoldingCollapsableFoldRangeForLine(GetDisplayTextLineNumber(LDisplayPosition.Row));
if Assigned(LFoldRange) and LFoldRange.Collapsed then
begin
LScrolledXBy := (LeftChar - 1) * CharWidth;
LPoint := Point(X, Y);
LCollapseMarkRect := LFoldRange.CollapseMarkRect;
if LCollapseMarkRect.Right - LScrolledXBy > 0 then
begin
OffsetRect(LCollapseMarkRect, -LScrolledXBy, 0);
if PtInRect(LCollapseMarkRect, LPoint) then
begin
FreeHintForm(FCodeFoldingHintForm);
CodeFoldingUncollapse(LFoldRange);
Exit;
end;
end;
end;
Result := False;
end;
procedure TBCBaseEditor.DoTrimTrailingSpaces(ATextLine: Integer);
begin
if eoTrimTrailingSpaces in FOptions then
FLines.TrimTrailingSpaces(ATextLine);
end;
function TBCBaseEditor.ExtraLineSpacing: Integer;
begin
Result := 0;
case FLinespacing.Rule of
lsSingle:
Result := 2;
lsOneAndHalf:
Result := FLineHeight div 2 + 2;
lsDouble:
Result := FLineHeight + 2;
lsSpecified:
Result := FLinespacing.Spacing;
end;
end;
function TBCBaseEditor.FindHookedCommandEvent(AHookedCommandEvent: TBCEditorHookedCommandEvent): Integer;
var
LHookedCommandHandler: TBCEditorHookedCommandHandler;
begin
Result := GetHookedCommandHandlersCount - 1;
while Result >= 0 do
begin
LHookedCommandHandler := TBCEditorHookedCommandHandler(FHookedCommandHandlers[Result]);
if LHookedCommandHandler.Equals(AHookedCommandEvent) then
Break;
Dec(Result);
end;
end;
function TBCBaseEditor.GetCanPaste: Boolean;
begin
Result := not ReadOnly and (IsClipboardFormatAvailable(CF_TEXT) or IsClipboardFormatAvailable(CF_UNICODETEXT));
end;
function TBCBaseEditor.GetCanRedo: Boolean;
begin
Result := not ReadOnly and FRedoList.CanUndo;
end;
function TBCBaseEditor.GetCanUndo: Boolean;
begin
Result := not ReadOnly and FUndoList.CanUndo;
end;
function TBCBaseEditor.GetDisplayCaretPosition: TBCEditorDisplayPosition;
begin
Result.Column := FDisplayCaretX;
Result.Row := FDisplayCaretY;
end;
function TBCBaseEditor.GetCharAtCursor: Char;
var
LTextPosition: TBCEditorTextPosition;
LTextLine: string;
LLength: Integer;
begin
Result := BCEDITOR_NONE_CHAR;
LTextPosition := TextCaretPosition;
if (LTextPosition.Line >= 0) and (LTextPosition.Line < FLines.Count) then
begin
LTextLine := FLines[LTextPosition.Line];
LLength := Length(LTextLine);
if LLength = 0 then
Exit;
if LTextPosition.Char <= LLength then
Result := LTextLine[LTextPosition.Char];
end;
end;
function TBCBaseEditor.GetCommentAtTextPosition(ATextPosition: TBCEditorTextPosition): string;
var
LTextLine: string;
LLength, LStop: Integer;
begin
Result := '';
if (ATextPosition.Line >= 0) and (ATextPosition.Line < FLines.Count) then
begin
LTextLine := FLines[ATextPosition.Line];
LLength := Length(LTextLine);
if LLength = 0 then
Exit;
if (ATextPosition.Char >= 1) and (ATextPosition.Char <= LLength) and IsCommentChar(LTextLine[ATextPosition.Char]) then
begin
LStop := ATextPosition.Char;
while (LStop <= LLength) and IsCommentChar(LTextLine[LStop]) do
Inc(LStop);
while (ATextPosition.Char > 1) and IsCommentChar(LTextLine[ATextPosition.Char - 1]) do
Dec(ATextPosition.Char);
if LStop > ATextPosition.Char then
Result := Copy(LTextLine, ATextPosition.Char, LStop - ATextPosition.Char);
end;
end;
end;
function TBCBaseEditor.GetClipboardText: string;
var
LGlobalMem: HGLOBAL;
LLocaleID: LCID;
LBytePointer: PByte;
function AnsiStringToString(const AValue: AnsiString; ACodePage: Word): string;
var
LInputLength, LOutputLength: Integer;
begin
LInputLength := Length(AValue);
LOutputLength := MultiByteToWideChar(ACodePage, 0, PAnsiChar(AValue), LInputLength, nil, 0);
SetLength(Result, LOutputLength);
MultiByteToWideChar(ACodePage, 0, PAnsiChar(AValue), LInputLength, PChar(Result), LOutputLength);
end;
function CodePageFromLocale(ALanguage: LCID): Integer;
var
LBuffer: array [0 .. 6] of Char;
begin
GetLocaleInfo(ALanguage, LOCALE_IDEFAULTANSICODEPAGE, LBuffer, 6);
Result := StrToIntDef(LBuffer, GetACP);
end;
begin
Result := '';
if not OpenClipboard then
Exit;
try
if Clipboard.HasFormat(CF_UNICODETEXT) then
begin
LGlobalMem := Clipboard.GetAsHandle(CF_UNICODETEXT);
if LGlobalMem <> 0 then
try
Result := PChar(GlobalLock(LGlobalMem));
finally
GlobalUnlock(LGlobalMem);
end;
end
else
begin
LLocaleID := 0;
LGlobalMem := Clipboard.GetAsHandle(CF_LOCALE);
if LGlobalMem <> 0 then
try
LLocaleID := PInteger(GlobalLock(LGlobalMem))^;
finally
GlobalUnlock(LGlobalMem);
end;
LGlobalMem := Clipboard.GetAsHandle(CF_TEXT);
if LGlobalMem <> 0 then
try
LBytePointer := GlobalLock(LGlobalMem);
Result := AnsiStringToString(PAnsiChar(LBytePointer), CodePageFromLocale(LLocaleID));
finally
GlobalUnlock(LGlobalMem);
end;
end;
finally
Clipboard.Close;
end;
end;
function TBCBaseEditor.GetDisplayLineNumber(const ADisplayLineNumber: Integer): Integer;
var
LFirst: Integer;
LLast: Integer;
LPivot: Integer;
LFound: Boolean;
begin
Result := ADisplayLineNumber;
if Assigned(FLineNumbersCache) and (FLineNumbersCache[ADisplayLineNumber] = ADisplayLineNumber) then
Result := ADisplayLineNumber
else
begin
LFirst := Low(FLineNumbersCache);
LLast := High(FLineNumbersCache);
LFound := False;
while (LFirst <= LLast) and (not LFound) do
begin
LPivot := (LFirst + LLast) div 2;
if FLineNumbersCache[LPivot] = ADisplayLineNumber then
begin
LFound := True;
Result := LPivot;
if FWordWrap.Enabled then
begin
Dec(LPivot);
while FLineNumbersCache[LPivot] = ADisplayLineNumber do
begin
Result := LPivot;
Dec(LPivot);
end;
end;
end
else
if FLineNumbersCache[LPivot] > ADisplayLineNumber then
LLast := LPivot - 1
else
LFirst := LPivot + 1;
end;
end;
end;
function TBCBaseEditor.GetDisplayPosition(AColumn, ARow: Integer): TBCEditorDisplayPosition;
begin
Result.Column := AColumn;
Result.Row := ARow;
end;
function TBCBaseEditor.GetEndOfLine(ALine: PChar): PChar;
begin
Result := ALine;
if Assigned(Result) then
while (Result^ <> BCEDITOR_NONE_CHAR) and (Result^ <> BCEDITOR_LINEFEED) and (Result^ <> BCEDITOR_CARRIAGE_RETURN) do
Inc(Result);
end;
function TBCBaseEditor.GetHighlighterAttributeAtRowColumn(const ATextPosition: TBCEditorTextPosition; var AToken: string;
var ATokenType: TBCEditorRangeType; var AStart: Integer; var AHighlighterAttribute: TBCEditorHighlighterAttribute): Boolean;
var
LPositionX, LPositionY: Integer;
LLine: string;
begin
LPositionY := ATextPosition.Line;
if Assigned(Highlighter) and (LPositionY >= 0) and (LPositionY < FLines.Count) then
begin
LLine := FLines[LPositionY];
if LPositionY = 0 then
Highlighter.ResetCurrentRange
else
Highlighter.SetCurrentRange(FLines.Ranges[LPositionY - 1]);
Highlighter.SetCurrentLine(LLine);
LPositionX := ATextPosition.Char;
if (LPositionX > 0) and (LPositionX <= Length(LLine)) then
while not Highlighter.GetEndOfLine do
begin
AStart := Highlighter.GetTokenPosition + 1;
Highlighter.GetToken(AToken);
if (LPositionX >= AStart) and (LPositionX < AStart + Length(AToken)) then
begin
AHighlighterAttribute := Highlighter.GetTokenAttribute;
ATokenType := Highlighter.GetTokenKind;
Exit(True);
end;
Highlighter.Next;
end;
end;
AToken := '';
AHighlighterAttribute := nil;
Result := False;
end;
function TBCBaseEditor.GetHookedCommandHandlersCount: Integer;
begin
if Assigned(FHookedCommandHandlers) then
Result := FHookedCommandHandlers.Count
else
Result := 0;
end;
function TBCBaseEditor.GetTextCaretPosition: TBCEditorTextPosition;
begin
Result := DisplayToTextPosition(DisplayCaretPosition);
end;
function TBCBaseEditor.GetLeadingExpandedLength(const AStr: string; ABorder: Integer = 0): Integer;
var
LChar: PChar;
LLength: Integer;
begin
Result := 0;
LChar := PChar(AStr);
if ABorder > 0 then
LLength := Min(PInteger(LChar - 2)^, ABorder)
else
LLength := PInteger(LChar - 2)^;
while LLength > 0 do
begin
if LChar^ = BCEDITOR_TAB_CHAR then
Inc(Result, FTabs.Width - (Result mod FTabs.Width))
else
if LChar^ = BCEDITOR_SPACE_CHAR then
Inc(Result)
else
Exit;
Inc(LChar);
Dec(LLength);
end;
end;
function TBCBaseEditor.GetLineIndentLevel(ALine: Integer): Integer;
var
LPLine: PChar;
begin
Result := 0;
if ALine >= FLines.Count then
Exit;
LPLine := PChar(FLines[ALine]);
while (LPLine^ <> BCEDITOR_NONE_CHAR) and ((LPLine^ = BCEDITOR_TAB_CHAR) or (LPLine^ = BCEDITOR_SPACE_CHAR)) do
begin
if LPLine^ = BCEDITOR_TAB_CHAR then
begin
if toColumns in FTabs.Options then
Inc(Result, FTabs.Width - Result mod FTabs.Width)
else
Inc(Result, FTabs.Width);
end
else
Inc(Result);
Inc(LPLine);
end;
end;
function TBCBaseEditor.GetMatchingToken(ADisplayPosition: TBCEditorDisplayPosition; var AMatch: TBCEditorMatchingPairMatch): TBCEditorMatchingTokenResult;
var
i, j: Integer;
LTokenMatch: PBCEditorMatchingPairToken;
LToken, LOriginalToken, LElement: string;
LLevel, LDeltaLevel: Integer;
LMatchStackID: Integer;
LOpenDuplicateLength, LCloseDuplicateLength: Integer;
LCurrentLineText: string;
function IsCommentOrString(AElement: string): Boolean;
begin
Result := (AElement = BCEDITOR_ATTRIBUTE_ELEMENT_COMMENT) or (AElement = BCEDITOR_ATTRIBUTE_ELEMENT_STRING);
end;
function IsOpenToken: Boolean;
var
i: Integer;
begin
Result := True;
for i := 0 to LOpenDuplicateLength - 1 do
if LToken = PBCEditorMatchingPairToken(FHighlighter.MatchingPairs[FMatchingPairOpenDuplicate[i]])^.OpenToken then
begin
LElement := FHighlighter.GetCurrentRangeAttribute.Element;
if not IsCommentOrString(LElement) then
Exit;
end;
Result := False
end;
function IsCloseToken: Boolean;
var
i: Integer;
begin
Result := True;
for i := 0 to LCloseDuplicateLength - 1 do
if LToken = PBCEditorMatchingPairToken(FHighlighter.MatchingPairs[FMatchingPairCloseDuplicate[i]])^.CloseToken then
begin
LElement := FHighlighter.GetCurrentRangeAttribute.Element;
if not IsCommentOrString(LElement) then
Exit;
end;
Result := False
end;
function CheckToken: Boolean;
begin
with FHighlighter do
begin
GetToken(LToken);
LToken := LowerCase(LToken);
if IsCloseToken then
Dec(LLevel)
else
if IsOpenToken then
Inc(LLevel);
if LLevel = 0 then
begin
GetMatchingToken := trOpenAndCloseTokenFound;
GetToken(AMatch.CloseToken);
AMatch.CloseTokenPos.Line := ADisplayPosition.Row - 1;
AMatch.CloseTokenPos.Char := GetTokenPosition + 1;
Result := True;
end
else
begin
Next;
Result := False;
end;
end;
end;
procedure CheckTokenBack;
begin
with FHighlighter do
begin
GetToken(LToken);
LToken := LowerCase(LToken);
if IsCloseToken then
begin
Dec(LLevel);
if LMatchStackID >= 0 then
Dec(LMatchStackID);
end
else
if IsOpenToken then
begin
Inc(LLevel);
Inc(LMatchStackID);
if LMatchStackID >= Length(FMatchingPairMatchStack) then
SetLength(FMatchingPairMatchStack, Length(FMatchingPairMatchStack) + 32);
GetToken(FMatchingPairMatchStack[LMatchStackID].Token);
FMatchingPairMatchStack[LMatchStackID].Position.Line := ADisplayPosition.Row - 1;
FMatchingPairMatchStack[LMatchStackID].Position.Char := GetTokenPosition + 1;
end;
Next;
end;
end;
procedure InitializeCurrentLine;
begin
if ADisplayPosition.Row = 1 then
FHighlighter.ResetCurrentRange
else
FHighlighter.SetCurrentRange(FLines.Ranges[ ADisplayPosition.Row - 1]);
{ Get line with tabs converted to spaces like PaintTextLines does. }
LCurrentLineText := FLines.ExpandedStrings[ADisplayPosition.Row - 1];
LCurrentLineText := AddMultiByteFillerChars(PChar(LCurrentLineText), Length(LCurrentLineText));
FHighlighter.SetCurrentLine(LCurrentLineText);
end;
var
LCaretX: Integer;
LMathingPairToken: TBCEditorMatchingPairToken;
begin
Result := trNotFound;
if FHighlighter = nil then
Exit;
Dec(ADisplayPosition.Column);
with FHighlighter do
begin
InitializeCurrentLine;
LCaretX := ADisplayPosition.Column + 1;
while not GetEndOfLine and (LCaretX > GetTokenPosition + GetTokenLength) do
Next;
if GetEndOfLine then
Exit;
LElement := FHighlighter.GetCurrentRangeAttribute.Element;
if IsCommentOrString(LElement) then
Exit;
i := 0;
j := FHighlighter.MatchingPairs.Count;
GetToken(LOriginalToken);
LToken := Trim(LowerCase(LOriginalToken));
if LToken = '' then
Exit;
while i < j do
begin
LMathingPairToken := PBCEditorMatchingPairToken(FHighlighter.MatchingPairs[i])^;
if LToken = LMathingPairToken.CloseToken then
begin
Result := trCloseTokenFound;
AMatch.CloseToken := LOriginalToken;
AMatch.CloseTokenPos.Line := ADisplayPosition.Row - 1;
AMatch.CloseTokenPos.Char := GetTokenPosition + 1;
Break;
end
else
if LToken = LMathingPairToken.OpenToken then
begin
Result := trOpenTokenFound;
AMatch.OpenToken := LOriginalToken;
AMatch.OpenTokenPos.Line := ADisplayPosition.Row - 1;
AMatch.OpenTokenPos.Char := GetTokenPosition + 1;
Break;
end;
Inc(i);
end;
if Result = trNotFound then
Exit;
LTokenMatch := FHighlighter.MatchingPairs.Items[i];
AMatch.TokenAttribute := GetTokenAttribute;
if j > Length(FMatchingPairOpenDuplicate) then
begin
SetLength(FMatchingPairOpenDuplicate, j);
SetLength(FMatchingPairCloseDuplicate, j);
end;
LOpenDuplicateLength := 0;
LCloseDuplicateLength := 0;
for i := 0 to j - 1 do
begin
LMathingPairToken := PBCEditorMatchingPairToken(FHighlighter.MatchingPairs[i])^;
if LTokenMatch^.OpenToken = LMathingPairToken.OpenToken then
begin
FMatchingPairCloseDuplicate[LCloseDuplicateLength] := i;
Inc(LCloseDuplicateLength);
end;
if LTokenMatch^.CloseToken = LMathingPairToken.CloseToken then
begin
FMatchingPairOpenDuplicate[LOpenDuplicateLength] := i;
Inc(LOpenDuplicateLength);
end;
end;
if Result = trOpenTokenFound then
begin
LLevel := 1;
Next;
while True do
begin
while not GetEndOfLine do
if CheckToken then
Exit;
Inc(ADisplayPosition.Row);
if ADisplayPosition.Row > FLines.Count then
Break;
SetCurrentLine(FLines.ExpandedStrings[ADisplayPosition.Row - 1]);
end;
end
else
begin
if Length(FMatchingPairMatchStack) < 32 then
SetLength(FMatchingPairMatchStack, 32);
LMatchStackID := -1;
LLevel := -1;
InitializeCurrentLine;
while not GetEndOfLine and (GetTokenPosition < AMatch.CloseTokenPos.Char - 1) do
CheckTokenBack;
if LMatchStackID > -1 then
begin
Result := trCloseAndOpenTokenFound;
AMatch.OpenToken := FMatchingPairMatchStack[LMatchStackID].Token;
AMatch.OpenTokenPos := FMatchingPairMatchStack[LMatchStackID].Position;
end
else
while ADisplayPosition.Row > 1 do
begin
LDeltaLevel := -LLevel - 1;
Dec(ADisplayPosition.Row);
InitializeCurrentLine;
LMatchStackID := -1;
while not GetEndOfLine do
CheckTokenBack;
if LDeltaLevel <= LMatchStackID then
begin
Result := trCloseAndOpenTokenFound;
AMatch.OpenToken := FMatchingPairMatchStack[LMatchStackID - LDeltaLevel].Token;
AMatch.OpenTokenPos := FMatchingPairMatchStack[LMatchStackID - LDeltaLevel].Position;
Exit;
end;
end;
end;
end;
end;
function TBCBaseEditor.GetMouseMoveScrollCursors(AIndex: Integer): HCURSOR;
begin
Result := 0;
if (AIndex >= Low(FMouseMoveScrollCursors)) and (AIndex <= High(FMouseMoveScrollCursors)) then
Result := FMouseMoveScrollCursors[AIndex];
end;
function TBCBaseEditor.GetTextCaretY: Integer;
begin
Result := GetDisplayTextLineNumber(DisplayCaretY) - 1;
end;
function TBCBaseEditor.GetMouseMoveScrollCursorIndex: Integer;
var
LCursorPoint: TPoint;
LLeftX, LRightX, LTopY, LBottomY: Integer;
begin
Result := scNone;
Winapi.Windows.GetCursorPos(LCursorPoint);
LCursorPoint := ScreenToClient(LCursorPoint);
LLeftX := FMouseMoveScrollingPoint.X - FScroll.Indicator.Width;
LRightX := FMouseMoveScrollingPoint.X + 4;
LTopY := FMouseMoveScrollingPoint.Y - FScroll.Indicator.Height;
LBottomY := FMouseMoveScrollingPoint.Y + 4;
if LCursorPoint.Y < LTopY then
begin
if LCursorPoint.X < LLeftX then
Exit(scNorthWest)
else
if (LCursorPoint.X >= LLeftX) and (LCursorPoint.X <= LRightX) then
Exit(scNorth)
else
Exit(scNorthEast)
end;
if LCursorPoint.Y > LBottomY then
begin
if LCursorPoint.X < LLeftX then
Exit(scSouthWest)
else
if (LCursorPoint.X >= LLeftX) and (LCursorPoint.X <= LRightX) then
Exit(scSouth)
else
Exit(scSouthEast)
end;
if LCursorPoint.X < LLeftX then
Exit(scWest);
if LCursorPoint.X > LRightX then
Exit(scEast);
end;
function TBCBaseEditor.GetSelectionAvailable: Boolean;
begin
Result := FSelection.Visible and
((FSelectionBeginPosition.Char <> FSelectionEndPosition.Char) or
((FSelectionBeginPosition.Line <> FSelectionEndPosition.Line) and (FSelection.ActiveMode <> smColumn)));
end;
function TBCBaseEditor.GetSelectedText: string;
function CopyPadded(const AValue: string; Index, Count: Integer): string;
var
i: Integer;
LSourceLength, LDestinationLength: Integer;
LPResult: PChar;
begin
LSourceLength := Length(AValue);
LDestinationLength := Index + Count;
if LSourceLength >= LDestinationLength then
Result := Copy(AValue, Index, Count)
else
begin
SetLength(Result, LDestinationLength);
LPResult := PChar(Result);
StrCopy(LPResult, PChar(Copy(AValue, Index, Count)));
Inc(LPResult, Length(AValue));
for i := 0 to LDestinationLength - LSourceLength - 1 do
LPResult[i] := BCEDITOR_SPACE_CHAR;
end;
end;
procedure CopyAndForward(const AValue: string; AIndex, ACount: Integer; var APResult: PChar);
var
LPSource: PChar;
LSourceLength: Integer;
LDestinationLength: Integer;
begin
LSourceLength := Length(AValue);
if (AIndex <= LSourceLength) and (ACount > 0) then
begin
Dec(AIndex);
LPSource := PChar(AValue) + AIndex;
LDestinationLength := Min(LSourceLength - AIndex, ACount);
Move(LPSource^, APResult^, LDestinationLength * SizeOf(Char));
Inc(APResult, LDestinationLength);
APResult^ := BCEDITOR_NONE_CHAR;
end;
end;
function CopyPaddedAndForward(const AValue: string; Index, Count: Integer; var PResult: PChar): Integer;
var
LPOld: PChar;
LLength, i: Integer;
begin
Result := 0;
LPOld := PResult;
CopyAndForward(AValue, Index, Count, PResult);
LLength := Count - (PResult - LPOld);
if not (eoTrimTrailingSpaces in Options) and (PResult - LPOld > 0) then
begin
for i := 0 to LLength - 1 do
PResult[i] := BCEDITOR_SPACE_CHAR;
Inc(PResult, LLength);
end
else
Result := LLength;
end;
function DoGetSelectedText: string;
var
LFirst, LLast, LTotalLength: Integer;
LColumnFrom, LColumnTo: Integer;
i, L, R: Integer;
S: string;
P: PChar;
LRow: Integer;
LTextPosition: TBCEditorTextPosition;
LDisplayPosition: TBCEditorDisplayPosition;
LTrimCount: Integer;
begin
LColumnFrom := SelectionBeginPosition.Char;
LFirst := SelectionBeginPosition.Line;
LColumnTo := SelectionEndPosition.Char;
LLast := SelectionEndPosition.Line;
case FSelection.ActiveMode of
smNormal:
begin
if LFirst = LLast then
Result := Copy(Lines[LFirst], LColumnFrom, LColumnTo - LColumnFrom)
else
begin
{ Calculate total length of result string }
LTotalLength := Max(0, Length(Lines[LFirst]) - LColumnFrom + 1);
Inc(LTotalLength, Length(SLineBreak));
for i := LFirst + 1 to LLast - 1 do
begin
Inc(LTotalLength, Length(Lines[i]));
Inc(LTotalLength, Length(SLineBreak));
end;
Inc(LTotalLength, LColumnTo - 1);
SetLength(Result, LTotalLength);
P := PChar(Result);
CopyAndForward(Lines[LFirst], LColumnFrom, MaxInt, P);
CopyAndForward(SLineBreak, 1, MaxInt, P);
for i := LFirst + 1 to LLast - 1 do
begin
CopyAndForward(Lines[i], 1, MaxInt, P);
CopyAndForward(SLineBreak, 1, MaxInt, P);
end;
CopyAndForward(Lines[LLast], 1, LColumnTo - 1, P);
end;
end;
smColumn:
begin
with TextToDisplayPosition(SelectionBeginPosition) do
begin
LFirst := Row;
LColumnFrom := Column;
end;
with TextToDisplayPosition(SelectionEndPosition) do
begin
LLast := Row;
LColumnTo := Column;
end;
if LColumnFrom > LColumnTo then
SwapInt(LColumnFrom, LColumnTo);
LTotalLength := ((LColumnTo - LColumnFrom) + Length(SLineBreak)) * (LLast - LFirst + 1);
SetLength(Result, LTotalLength);
P := PChar(Result);
LTotalLength := 0;
for LRow := LFirst to LLast do
begin
LDisplayPosition.Row := LRow;
LDisplayPosition.Column := LColumnFrom;
LTextPosition := DisplayToTextPosition(LDisplayPosition);
L := LTextPosition.Char;
S := FLines[LTextPosition.Line];
LDisplayPosition.Column := LColumnTo;
R := DisplayToTextPosition(LDisplayPosition).Char;
LTrimCount := CopyPaddedAndForward(S, L, R - L, P);
LTotalLength := LTotalLength + (R - L) - LTrimCount + Length(SLineBreak);
CopyAndForward(SLineBreak, 1, MaxInt, P);
end;
SetLength(Result, Max(LTotalLength - Length(SLineBreak), 0));
end;
end;
end;
begin
if not SelectionAvailable then
Result := ''
else
Result := DoGetSelectedText;
end;
function TBCBaseEditor.GetSearchResultCount: Integer;
begin
Result := FSearch.Lines.Count;
end;
function TBCBaseEditor.GetSelectionBeginPosition: TBCEditorTextPosition;
var
LLineLength: Integer;
begin
if (FSelectionEndPosition.Line < FSelectionBeginPosition.Line) or
((FSelectionEndPosition.Line = FSelectionBeginPosition.Line) and (FSelectionEndPosition.Char < FSelectionBeginPosition.Char)) then
Result := FSelectionEndPosition
else
Result := FSelectionBeginPosition;
LLineLength := Length(FLines[Result.Line]);
if Result.Char > LLineLength then
Result.Char := LLineLength + 1;
end;
function TBCBaseEditor.GetSelectionEndPosition: TBCEditorTextPosition;
var
LLineLength: Integer;
begin
if (FSelectionEndPosition.Line < FSelectionBeginPosition.Line) or
((FSelectionEndPosition.Line = FSelectionBeginPosition.Line) and (FSelectionEndPosition.Char < FSelectionBeginPosition.Char)) then
Result := FSelectionBeginPosition
else
Result := FSelectionEndPosition;
LLineLength := Length(FLines[Result.Line]);
if Result.Char > LLineLength then
Result.Char := LLineLength + 1;
end;
function TBCBaseEditor.GetText: string;
begin
Result := FLines.Text;
end;
function TBCBaseEditor.GetTextBetween(ATextBeginPosition: TBCEditorTextPosition; ATextEndPosition: TBCEditorTextPosition): string;
var
LSelectionMode: TBCEditorSelectionMode;
begin
LSelectionMode := FSelection.Mode;
FSelection.Mode := smNormal;
FSelectionBeginPosition := ATextBeginPosition;
FSelectionEndPosition := ATextEndPosition;
Result := SelectedText;
FSelection.Mode := LSelectionMode;
end;
procedure TBCBaseEditor.CreateLineNumbersCache(AResetCache: Boolean = False);
var
i, j, k: Integer;
LAdded: Boolean;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
LCollapsedCodeFolding: array of Boolean;
LLineNumbersCacheLength, LStringLength: Integer;
LTextLine: string;
LRowBegin: PChar;
LLineEnd: PChar;
LRowEnd: PChar;
LRunner: PChar;
LRowMinEnd: PChar;
LMinRowLength: Word;
LMaxRowLength: Word;
procedure ResizeCacheArray;
begin
if FWordWrap.Enabled and (k >= LLineNumbersCacheLength) then { resize }
begin
Inc(LLineNumbersCacheLength, 256);
SetLength(FLineNumbersCache, LLineNumbersCacheLength);
if FWordWrap.Enabled then
SetLength(FWordWrapLineLengths, LLineNumbersCacheLength);
end;
end;
procedure AddLineNumberIntoCache;
begin
FLineNumbersCache[k] := j;
Inc(k);
ResizeCacheArray;
end;
begin
if FResetLineNumbersCache or AResetCache then
begin
FResetLineNumbersCache := False;
SetLength(LCollapsedCodeFolding, Lines.Count + 1);
for i := 0 to FAllCodeFoldingRanges.AllCount - 1 do
begin
LCodeFoldingRange := FAllCodeFoldingRanges[i];
if Assigned(LCodeFoldingRange) and LCodeFoldingRange.Collapsed and not LCodeFoldingRange.ParentCollapsed then
for j := LCodeFoldingRange.FromLine + 1 to LCodeFoldingRange.ToLine do
LCollapsedCodeFolding[j] := True;
end;
SetLength(FLineNumbersCache, 0);
SetLength(FWordWrapLineLengths, 0);
LLineNumbersCacheLength := Lines.Count + 1;
if FWordWrap.Enabled then
begin
Inc(LLineNumbersCacheLength, 256);
SetLength(FWordWrapLineLengths, LLineNumbersCacheLength);
end;
SetLength(FLineNumbersCache, LLineNumbersCacheLength);
j := 1;
k := 1;
for i := 1 to Lines.Count do //FI:W528 FixInsight ignore
begin
while (j <= Lines.Count) and LCollapsedCodeFolding[j] do { skip collapsed lines }
Inc(j);
if j > Lines.Count then
Break;
LAdded := False;
if FWordWrap.Enabled then
begin
LTextLine := FLines.ExpandedStrings[j - 1];
LStringLength := Length(LTextLine);
LMaxRowLength := GetVisibleChars;
if (LStringLength > LMaxRowLength) and (LMaxRowLength > 0) then
begin
LRowBegin := PChar(LTextLine);
LMinRowLength := Max(LMaxRowLength div 3, 1);
LRowEnd := LRowBegin + LMaxRowLength;
LLineEnd := LRowBegin + LStringLength;
while LRowEnd < LLineEnd do
begin
LRowMinEnd := LRowBegin + LMinRowLength;
LRunner := LRowEnd;
while LRunner > LRowMinEnd do
begin
if IsWordBreakChar(LRunner^) then
begin
LRowEnd := LRunner;
if LRowEnd - LRowBegin < LMaxRowLength then
Inc(LRowEnd);
Break;
end;
Dec(LRunner);
end;
LAdded := True;
FWordWrapLineLengths[k] := LRowEnd - LRowBegin;
AddLineNumberIntoCache;
LRowBegin := LRowEnd;
Inc(LRowEnd, LMaxRowLength);
end;
if LLineEnd > LRowBegin then
begin
FWordWrapLineLengths[k] := LLineEnd - LRowBegin;
AddLineNumberIntoCache;
end;
end;
end;
if not LAdded then
AddLineNumberIntoCache;
Inc(j);
end;
if k <> Length(FLineNumbersCache) then
begin
SetLength(FLineNumbersCache, k);
if FWordWrap.Enabled then
SetLength(FWordWrapLineLengths, k);
end;
SetLength(LCollapsedCodeFolding, 0);
FLineNumbersCount := Length(FLineNumbersCache) - 1;
end;
end;
function TBCBaseEditor.GetDisplayTextLineNumber(ADisplayLineNumber: Integer): Integer;
begin
Result := ADisplayLineNumber;
CreateLineNumbersCache;
if Assigned(FLineNumbersCache) and (ADisplayLineNumber <= FLineNumbersCount) then
Result := FLineNumbersCache[ADisplayLineNumber];
end;
function TBCBaseEditor.GetTextOffset: Integer;
begin
Result := FLeftMargin.GetWidth + FCodeFolding.GetWidth - (LeftChar - 1) * FCharWidth;
if FMinimap.Align = maLeft then
Inc(Result, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(Result, FSearch.Map.GetWidth);
end;
function TBCBaseEditor.GetWordAtCursor: string;
begin
Result := GetWordAtTextPosition(TextCaretPosition);
end;
function TBCBaseEditor.GetWordAtMouse: string;
var
LTextPosition: TBCEditorTextPosition;
begin
Result := '';
if GetPositionOfMouse(LTextPosition) then
Result := GetWordAtTextPosition(LTextPosition);
end;
function TBCBaseEditor.GetWordAtTextPosition(ATextPosition: TBCEditorTextPosition): string;
var
LTextLine: string;
LLength, LStop: Integer;
begin
Result := '';
if (ATextPosition.Line >= 0) and (ATextPosition.Line < FLines.Count) then
begin
LTextLine := FLines[ATextPosition.Line];
LLength := Length(LTextLine);
if LLength = 0 then
Exit;
if (ATextPosition.Char >= 1) and (ATextPosition.Char <= LLength) and not IsWordBreakChar(LTextLine[ATextPosition.Char]) then
begin
LStop := ATextPosition.Char;
while (LStop <= LLength) and not IsWordBreakChar(LTextLine[LStop]) do
Inc(LStop);
while (ATextPosition.Char > 1) and not IsWordBreakChar(LTextLine[ATextPosition.Char - 1]) do
Dec(ATextPosition.Char);
if LStop > ATextPosition.Char then
Result := Copy(LTextLine, ATextPosition.Char, LStop - ATextPosition.Char);
end;
end;
end;
function TBCBaseEditor.GetVisibleChars: Integer;
begin
Result := FVisibleChars;
if FWordWrap.Enabled then
case FWordWrap.Style of
wwsClientWidth:
Result := FVisibleChars;
wwsRightMargin:
Result := FRightMargin.Position;
wwsSpecified:
Result := FWordWrap.Position;
end
end;
function TBCBaseEditor.IsCommentAtCaretPosition: Boolean;
var
i: Integer;
LTextPosition: TBCEditorTextPosition;
LCommentAtCursor: string;
function CheckComment(AComment: string): Boolean;
var
LCommentPtr, LCommentAtCursorPtr: PChar;
begin
LCommentPtr := PChar(AComment);
LCommentAtCursorPtr := PChar(LCommentAtCursor);
while (LCommentPtr^ <> BCEDITOR_NONE_CHAR) and (LCommentAtCursorPtr^ <> BCEDITOR_NONE_CHAR) and
(UpCase(LCommentAtCursorPtr^) = LCommentPtr^) do
begin
Inc(LCommentPtr);
Inc(LCommentAtCursorPtr);
end;
Result := LCommentPtr^ = BCEDITOR_NONE_CHAR;
end;
begin
Result := False;
if not FCodeFolding.Visible then
Exit;
if Assigned(FHighlighter) and (Length(FHighlighter.Comments.BlockComments) = 0)
and (Length(FHighlighter.Comments.LineComments) = 0) then
Exit;
if Assigned(FHighlighter) then
begin
LTextPosition := TextCaretPosition;
Dec(LTextPosition.Char);
LCommentAtCursor := GetCommentAtTextPosition(LTextPosition);
if LCommentAtCursor <> '' then
begin
i := 0;
while i < Length(FHighlighter.Comments.BlockComments) do
begin
if CheckComment(FHighlighter.Comments.BlockComments[i]) then
Exit(True);
if CheckComment(FHighlighter.Comments.BlockComments[i + 1]) then
Exit(True);
Inc(i, 2);
end;
for i := 0 to Length(FHighlighter.Comments.LineComments) - 1 do
if CheckComment(FHighlighter.Comments.LineComments[i]) then
Exit(True);
end;
end;
end;
function TBCBaseEditor.IsKeywordAtCaretPosition(APOpenKeyWord: PBoolean = nil; AHighlightAfterToken: Boolean = True): Boolean;
var
i, j: Integer;
LWordAtCursor, LWordAtOneBeforeCursor: string;
LFoldRegion: TBCEditorCodeFoldingRegion;
LFoldRegionItem: TBCEditorCodeFoldingRegionItem;
LTextPosition: TBCEditorTextPosition;
function CheckToken(AKeyword: string): Boolean;
var
LWordAtCursorPtr: PChar;
function AreKeywordsSame(AKeywordPtr: PChar): Boolean;
begin
while (AKeywordPtr^ <> BCEDITOR_NONE_CHAR) and (LWordAtCursorPtr^ <> BCEDITOR_NONE_CHAR) and
(UpCase(LWordAtCursorPtr^) = AKeywordPtr^) do
begin
Inc(AKeywordPtr);
Inc(LWordAtCursorPtr);
end;
Result := AKeywordPtr^ = BCEDITOR_NONE_CHAR;
end;
begin
Result := False;
if LWordAtCursor <> '' then
begin
LWordAtCursorPtr := PChar(LWordAtCursor);
if AreKeywordsSame(PChar(AKeyword)) then
Result := True
end
else
if AHighlightAfterToken and (LWordAtOneBeforeCursor <> '') then
begin
LWordAtCursorPtr := PChar(LWordAtOneBeforeCursor);
if AreKeywordsSame(PChar(AKeyword)) then
Result := True;
end;
if Result then
if Assigned(APOpenKeyWord) then
APOpenKeyWord^ := True;
end;
begin
Result := False;
if not FCodeFolding.Visible then
Exit;
if Assigned(FHighlighter) and (Length(FHighlighter.CodeFoldingRegions) = 0) then
Exit;
if Assigned(FHighlighter) then
begin
LTextPosition := TextCaretPosition;
LWordAtCursor := GetWordAtTextPosition(LTextPosition);
LWordAtOneBeforeCursor := '';
if AHighlightAfterToken then
begin
Dec(LTextPosition.Char);
LWordAtOneBeforeCursor := GetWordAtTextPosition(LTextPosition);
end;
if (LWordAtCursor <> '') or (LWordAtOneBeforeCursor <> '') then
for i := 0 to Length(FHighlighter.CodeFoldingRegions) - 1 do
begin
LFoldRegion := FHighlighter.CodeFoldingRegions[i];
for j := 0 to LFoldRegion.Count - 1 do
begin
LFoldRegionItem := LFoldRegion.Items[j];
if CheckToken(LFoldRegionItem.OpenToken) then
Exit(True);
if LFoldRegionItem.OpenTokenCanBeFollowedBy <> '' then
if CheckToken(LFoldRegionItem.OpenTokenCanBeFollowedBy) then
Exit(True);
if CheckToken(LFoldRegionItem.CloseToken) then
Exit(True);
end;
end;
end;
end;
function TBCBaseEditor.IsKeywordAtCaretPositionOrAfter(ACaretPosition: TBCEditorTextPosition): Boolean;
var
i, j: Integer;
LLineText: string;
LFoldRegion: TBCEditorCodeFoldingRegion;
LFoldRegionItem: TBCEditorCodeFoldingRegionItem;
LKeyWordPtr, LBookmarkTextPtr, LTextPtr, LLinePtr: PChar;
procedure SkipEmptySpace;
begin
while (LTextPtr^ < BCEDITOR_EXCLAMATION_MARK) and (LTextPtr^ <> BCEDITOR_NONE_CHAR) do
Inc(LTextPtr);
end;
function IsValidChar(ACharacter: PChar): Boolean;
begin
Result := ACharacter^.IsUpper or ACharacter^.IsNumber;
end;
function IsWholeWord(AFirstChar, ALastChar: PChar): Boolean;
begin
Result := not IsValidChar(AFirstChar) and not IsValidChar(ALastChar);
end;
begin
Result := False;
if not FCodeFolding.Visible then
Exit;
if Assigned(FHighlighter) and (Length(FHighlighter.CodeFoldingRegions) = 0) then
Exit;
LLineText := FLines.GetLineText(ACaretPosition.Line);
if Trim(LLineText) = '' then
Exit;
LLinePtr := PChar(LLineText);
Inc(LLinePtr, ACaretPosition.Char - 2);
if not IsWordBreakChar(LLinePtr^) then
begin
while not IsWordBreakChar(LLinePtr^) and (ACaretPosition.Char > 0) do
begin
Dec(LLinePtr);
Dec(ACaretPosition.Char);
end;
Inc(LLinePtr);
end;
if LLinePtr^ = BCEDITOR_NONE_CHAR then
Exit;
if Assigned(FHighlighter) then
for i := 0 to Length(FHighlighter.CodeFoldingRegions) - 1 do
begin
LFoldRegion := FHighlighter.CodeFoldingRegions[i];
for j := 0 to LFoldRegion.Count - 1 do
begin
LFoldRegionItem := LFoldRegion.Items[j];
LTextPtr := LLinePtr;
while LTextPtr^ <> BCEDITOR_NONE_CHAR do
begin
SkipEmptySpace;
LBookmarkTextPtr := LTextPtr;
{ check if the open keyword found }
LKeyWordPtr := PChar(LFoldRegionItem.OpenToken);
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (UpCase(LTextPtr^) = LKeyWordPtr^) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then { if found, pop skip region from the stack }
begin
if IsWholeWord(LBookmarkTextPtr - 1, LTextPtr) then { not interested in partial hits }
Exit(True)
else
LTextPtr := LBookmarkTextPtr; { skip region close not found, return pointer back }
end
else
LTextPtr := LBookmarkTextPtr; { skip region close not found, return pointer back }
{ check if the close keyword found }
LKeyWordPtr := PChar(LFoldRegionItem.CloseToken);
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (UpCase(LTextPtr^) = LKeyWordPtr^) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then { if found, pop skip region from the stack }
begin
if IsWholeWord(LBookmarkTextPtr - 1, LTextPtr) then { not interested in partial hits }
Exit(True)
else
LTextPtr := LBookmarkTextPtr; { skip region close not found, return pointer back }
end
else
LTextPtr := LBookmarkTextPtr; { skip region close not found, return pointer back }
Inc(LTextPtr);
{ skip until next word }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and IsValidChar(LTextPtr - 1) do
Inc(LTextPtr);
end;
end;
end;
end;
function TBCBaseEditor.IsWordSelected: Boolean;
var
i: Integer;
LLineText: string;
LTextPtr: PChar;
begin
Result := False;
if FSelectionBeginPosition.Line <> FSelectionEndPosition.Line then
Exit;
LLineText := FLines.GetLineText(FSelectionBeginPosition.Line);
if LLineText = '' then
Exit;
LTextPtr := PChar(LLineText);
i := FSelectionBeginPosition.Char;
Inc(LTextPtr, i - 1);
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (i < FSelectionEndPosition.Char) do
begin
if IsWordBreakChar(LTextPtr^) then
Exit;
Inc(LTextPtr);
Inc(i);
end;
Result := True;
end;
function TBCBaseEditor.LeftSpaceCount(const ALine: string; AWantTabs: Boolean = False): Integer;
var
LPLine: PChar;
begin
LPLine := PChar(ALine);
if Assigned(LPLine) and (eoAutoIndent in FOptions) then
begin
Result := 0;
while (LPLine^ > BCEDITOR_NONE_CHAR) and (LPLine^ <= BCEDITOR_SPACE_CHAR) do
begin
if (LPLine^ = BCEDITOR_TAB_CHAR) and AWantTabs then
begin
if toColumns in FTabs.Options then
Inc(Result, FTabs.Width - Result mod FTabs.Width)
else
Inc(Result, FTabs.Width)
end
else
Inc(Result);
Inc(LPLine);
end;
end
else
Result := 0;
end;
function TBCBaseEditor.NextWordPosition: TBCEditorTextPosition;
begin
Result := NextWordPosition(TextCaretPosition);
end;
function TBCBaseEditor.NextWordPosition(const ATextPosition: TBCEditorTextPosition): TBCEditorTextPosition;
var
LLength: Integer;
LLine: string;
function StringScan(const ALine: string; AStart: Integer; ACharMethod: TBCEditorCharMethod): Integer;
var
LCharPointer: PChar;
begin
if (AStart > 0) and (AStart <= Length(ALine)) then
begin
LCharPointer := PChar(@ALine[AStart]);
repeat
if ACharMethod(LCharPointer^) then
Exit(AStart);
Inc(LCharPointer);
Inc(AStart);
until LCharPointer^ = BCEDITOR_NONE_CHAR;
end;
Result := 0;
end;
begin
Result := ATextPosition;
if (Result.Line >= 0) and (Result.Line < FLines.Count) then
begin
LLine := FLines[Result.Line];
LLength := Length(LLine);
if Result.Char >= LLength then
begin
if Result.Line >= FLines.Count - 1 then
begin
if not SelectionAvailable then
begin
Result.Line := 0;
Result.Char := 1;
end;
end
else
begin
Inc(Result.Line);
LLine := FLines[Result.Line];
Result.Char := 1;
Result := NextWordPosition(Result);
end;
end
else
begin
if not IsWordBreakChar(LLine[Result.Char]) then
Result.Char := StringScan(LLine, Result.Char, IsWordBreakChar);
if Result.Char > 0 then
Result.Char := StringScan(LLine, Result.Char, IsWordChar);
if Result.Char = 0 then
Result.Char := LLength + 1;
end;
end;
end;
function TBCBaseEditor.PixelsToNearestRowColumn(X, Y: Integer): TBCEditorDisplayPosition;
var
LLinesY: Integer;
begin
LLinesY := FVisibleLines * FLineHeight;
{ don't return a partially visible last line }
if Y >= LLinesY then
Y := Max(LLinesY - 1, 0);
Result := PixelsToRowColumn(X + 2, Y);
end;
function TBCBaseEditor.PixelsToRowColumn(X, Y: Integer): TBCEditorDisplayPosition;
var
LWidth: Integer;
begin
LWidth := 0;
if FMinimap.Align = maLeft then
Inc(LWidth, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LWidth, FSearch.Map.GetWidth);
Result.Column := Max(1, FLeftChar + ((X - LWidth - FLeftMargin.GetWidth - FCodeFolding.GetWidth) div FCharWidth));
Result.Row := Max(1, TopLine + Y div FLineHeight);
end;
function TBCBaseEditor.OpenClipboard: Boolean;
var
LRetryCount: Integer;
LDelayStepMs: Integer;
begin
LDelayStepMs := BCEDITOR_CLIPBOARD_DELAY_STEP_MS;
Result := False;
for LRetryCount := 1 to BCEDITOR_CLIPBOARD_MAX_RETRIES do
try
Clipboard.Open;
Result := True;
Break;
except
on Exception do
if LRetryCount = BCEDITOR_CLIPBOARD_MAX_RETRIES then
raise
else
begin
Sleep(LDelayStepMs);
Inc(LDelayStepMs, BCEDITOR_CLIPBOARD_DELAY_STEP_MS);
end;
end;
end;
function TBCBaseEditor.PreviousWordPosition: TBCEditorTextPosition;
begin
Result := PreviousWordPosition(TextCaretPosition);
end;
function TBCBaseEditor.PreviousWordPosition(const ATextPosition: TBCEditorTextPosition; APreviousLine: Boolean = False): TBCEditorTextPosition;
var
LLine: string;
LChar: Integer;
begin
Result := ATextPosition;
if (Result.Line >= 0) and (Result.Line < FLines.Count) then
begin
LLine := FLines[Result.Line];
Result.Char := Min(Result.Char, Length(LLine) + 1);
if Result.Char <= 1 then
begin
if Result.Line > 0 then
begin
Dec(Result.Line);
Result.Char := Length(FLines[Result.Line]) + 1;
Result := PreviousWordPosition(Result, True);
end
else
if not SelectionAvailable then
Result.Line := FLines.Count - 1
end
else
begin
if Result.Char > 1 then
begin
LChar := Result.Char;
if not APreviousLine then
Dec(LChar);
if not IsWordBreakChar(LLine[LChar]) then
Dec(Result.Char);
end;
if IsWordBreakChar(LLine[Result.Char]) then
begin
while (Result.Char > 0) and IsWordBreakChar(LLine[Result.Char]) do
Dec(Result.Char);
end
else
begin
while (Result.Char > 0) and not IsWordBreakChar(LLine[Result.Char]) do
Dec(Result.Char);
while (Result.Char > 0) and IsWordBreakChar(LLine[Result.Char]) do
Dec(Result.Char);
end;
if Result.Char > 0 then
Inc(Result.Char);
end;
end;
end;
function TBCBaseEditor.RescanHighlighterRangesFrom(AIndex: Integer): Integer;
var
LCurrentRange: TBCEditorRange;
begin
Result := AIndex;
if Result > FLines.Count then
Exit;
if Result = 0 then
FHighlighter.ResetCurrentRange
else
FHighlighter.SetCurrentRange(FLines.Ranges[Result - 1]);
repeat
FHighlighter.SetCurrentLine(FLines[Result]);
FHighlighter.NextToEndOfLine;
LCurrentRange := FHighlighter.GetCurrentRange;
if FLines.Ranges[Result] = LCurrentRange then
Exit;
FLines.Ranges[Result] := LCurrentRange;
Inc(Result);
until Result = FLines.Count;
Dec(Result);
end;
function TBCBaseEditor.RowColumnToCharIndex(ATextPosition: TBCEditorTextPosition): Integer;
var
i: Integer;
begin
Result := 0;
ATextPosition.Line := Min(FLines.Count, ATextPosition.Line) - 1;
for i := 0 to ATextPosition.Line do
Result := Result + Length(FLines[i]) + 2;
Result := Result + ATextPosition.Char - 1;
end;
function TBCBaseEditor.RowColumnToPixels(const ADisplayPosition: TBCEditorDisplayPosition): TPoint;
begin
Result.X := (ADisplayPosition.Column - 1) * FCharWidth + FTextOffset;
Result.Y := (ADisplayPosition.Row - FTopLine) * FLineHeight;
end;
function TBCBaseEditor.SearchText(const ASearchText: string; AChanged: Boolean = False): Integer;
var
LStartTextPosition, LEndTextPosition: TBCEditorTextPosition;
LCurrentTextPosition: TBCEditorTextPosition;
LSearchLength, LSearchIndex, LFound: Integer;
LFindAllCount: Integer;
LIsBackward, LIsFromCursor: Boolean;
LIsEndUndoBlock: Boolean;
LResultOffset: Integer;
function InValidSearchRange(AFirst, ALast: Integer): Boolean;
begin
Result := True;
if (FSelection.ActiveMode = smNormal) or not (soSelectedOnly in FSearch.Options) then
begin
if ((LCurrentTextPosition.Line = LStartTextPosition.Line) and
(not AChanged and (AFirst <= LStartTextPosition.Char) or
AChanged and (AFirst < LStartTextPosition.Char)) ) or
((LCurrentTextPosition.Line = LEndTextPosition.Line) and
(not AChanged and (ALast >= LEndTextPosition.Char) or
AChanged and (ALast > LEndTextPosition.Char)) ) then
Result := False;
end
else
if (FSelection.ActiveMode = smColumn) then
Result := (AFirst >= LStartTextPosition.Char) and (ALast <= LEndTextPosition.Char) or
(LEndTextPosition.Char - LStartTextPosition.Char < 1);
end;
begin
if not Assigned(FSearchEngine) then
raise EBCEditorBaseException.Create(SBCEditorSearchEngineNotAssigned);
Result := 0;
if Length(ASearchText) = 0 then
Exit;
LIsBackward := soBackwards in FSearch.Options;
LIsFromCursor := not AChanged or AChanged and not (soEntireScope in FSearch.Options);
if not SelectionAvailable then
FSearch.Options := FSearch.Options - [soSelectedOnly];
if soSelectedOnly in FSearch.Options then
begin
LStartTextPosition := SelectionBeginPosition;
LEndTextPosition := SelectionEndPosition;
if FSelection.ActiveMode = smColumn then
if LStartTextPosition.Char > LEndTextPosition.Char then
SwapInt(LStartTextPosition.Char, LEndTextPosition.Char);
if LIsBackward then
LCurrentTextPosition := LEndTextPosition
else
LCurrentTextPosition := LStartTextPosition;
end
else
begin
LStartTextPosition.Char := 1;
LStartTextPosition.Line := 0;
LEndTextPosition.Line := FLines.Count - 1;
LEndTextPosition.Char := FLines.StringLength(LEndTextPosition.Line);
if LIsFromCursor then
if LIsBackward then
LEndTextPosition := TextCaretPosition
else
if AChanged and SelectionAvailable then
LStartTextPosition := SelectionBeginPosition
else
LStartTextPosition := TextCaretPosition;
end;
if LIsBackward then
LCurrentTextPosition := LEndTextPosition
else
LCurrentTextPosition := LStartTextPosition;
FSearchEngine.Pattern := ASearchText;
case FSearch.Engine of
seNormal:
begin
TBCEditorNormalSearch(FSearchEngine).CaseSensitive := soCaseSensitive in FSearch.Options;
TBCEditorNormalSearch(FSearchEngine).WholeWordsOnly := soWholeWordsOnly in FSearch.Options;
end;
end;
LIsEndUndoBlock := False;
try
while (LCurrentTextPosition.Line >= LStartTextPosition.Line) and (LCurrentTextPosition.Line <= LEndTextPosition.Line) do
begin
LFindAllCount := FSearchEngine.FindAll(FLines[LCurrentTextPosition.Line]);
LResultOffset := 0;
if LIsBackward then
LSearchIndex := FSearchEngine.ResultCount - 1
else
LSearchIndex := 0;
while LFindAllCount > 0 do
begin
LFound := FSearchEngine.Results[LSearchIndex] + LResultOffset;
LSearchLength := FSearchEngine.Lengths[LSearchIndex];
if LIsBackward then
Dec(LSearchIndex)
else
Inc(LSearchIndex);
Dec(LFindAllCount);
if not InValidSearchRange(LFound, LFound + LSearchLength) then
Continue;
Inc(Result);
LCurrentTextPosition.Char := LFound;
SelectionBeginPosition := LCurrentTextPosition;
Inc(LCurrentTextPosition.Char, LSearchLength);
SelectionEndPosition := LCurrentTextPosition;
if LIsBackward then
TextCaretPosition := SelectionBeginPosition
else
begin
if TopLine + VisibleLines <= LCurrentTextPosition.Line then
TopLine := LCurrentTextPosition.Line - VisibleLines div 2 + 1;
TextCaretPosition := LCurrentTextPosition;
end;
Exit;
end;
if LIsBackward then
Dec(LCurrentTextPosition.Line)
else
Inc(LCurrentTextPosition.Line);
end;
finally
if LIsEndUndoBlock then
EndUndoBlock;
end;
end;
procedure TBCBaseEditor.ActiveLineChanged(Sender: TObject);
begin
if not (csLoading in ComponentState) then
begin
if Sender is TBCEditorActiveLine then
InvalidateLine(DisplayCaretY);
if Sender is TBCEditorGlyph then
InvalidateLeftMargin;
end;
end;
procedure TBCBaseEditor.AssignSearchEngine;
begin
if Assigned(FSearchEngine) then
begin
FSearchEngine.Free;
FSearchEngine := nil;
end;
case FSearch.Engine of
seNormal:
FSearchEngine := TBCEditorNormalSearch.Create;
seRegularExpression:
FSearchEngine := TBCEditorRegexSearch.Create;
seWildCard:
FSearchEngine := TBCEditorWildCardSearch.Create;
end;
end;
procedure TBCBaseEditor.AfterSetText(Sender: TObject);
begin
InitCodeFolding;
end;
procedure TBCBaseEditor.BeforeSetText(Sender: TObject);
begin
ClearCodeFolding;
end;
procedure TBCBaseEditor.CaretChanged(Sender: TObject);
begin
ResetCaret;
RecalculateCharExtent;
end;
procedure TBCBaseEditor.CheckIfAtMatchingKeywords;
var
LNewFoldRange: TBCEditorCodeFoldingRange;
LIsKeyWord, LOpenKeyWord: Boolean;
LLine: Integer;
begin
LIsKeyWord := IsKeywordAtCaretPosition(@LOpenKeyWord, mpoHighlightAfterToken in FMatchingPair.Options);
LNewFoldRange := nil;
LLine := GetTextCaretY + 1;
if LIsKeyWord and LOpenKeyWord then
LNewFoldRange := CodeFoldingRangeForLine(LLine)
else
if LIsKeyWord and not LOpenKeyWord then
LNewFoldRange := CodeFoldingFoldRangeForLineTo(LLine);
if LNewFoldRange <> FHighlightedFoldRange then
begin
if Assigned(FHighlightedFoldRange) then
with FHighlightedFoldRange do
InvalidateLines(FromLine, ToLine);
FHighlightedFoldRange := LNewFoldRange;
if Assigned(FHighlightedFoldRange) then
with FHighlightedFoldRange do
InvalidateLines(FromLine, ToLine);
end;
end;
procedure TBCBaseEditor.CodeFoldingCollapse(AFoldRange: TBCEditorCodeFoldingRange);
begin
ClearMatchingPair;
FResetLineNumbersCache := True;
with AFoldRange do
begin
Collapsed := True;
SetParentCollapsedOfSubCodeFoldingRanges(True, FoldRangeLevel);
end;
CheckIfAtMatchingKeywords;
Paint;
UpdateScrollBars;
end;
procedure TBCBaseEditor.CodeFoldingLinesDeleted(AFirstLine: Integer; ACount: Integer);
var
i: Integer;
LStartTextPosition, LEndTextPosition: TBCEditorTextPosition;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
if ACount > 0 then
begin
for i := AFirstLine + ACount - 1 downto AFirstLine do
begin
LCodeFoldingRange := CodeFoldingRangeForLine(i);
if Assigned(LCodeFoldingRange) then
begin
LStartTextPosition.Line := LCodeFoldingRange.FromLine;
LStartTextPosition.Char := 1;
LEndTextPosition.Line := LCodeFoldingRange.FromLine;
LEndTextPosition.Char := Length(FLines[LCodeFoldingRange.FromLine]);
FAllCodeFoldingRanges.Delete(LCodeFoldingRange);
end;
end;
UpdateFoldRanges(AFirstLine, -ACount);
LeftMarginChanged(Self);
end;
end;
procedure TBCBaseEditor.CodeFoldingResetCaches;
var
i, j, LLength: Integer;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
if not FCodeFolding.Visible then
Exit;
LLength := FLines.Count + 1;
SetLength(FCodeFoldingTreeLine, 0); { empty }
SetLength(FCodeFoldingTreeLine, LLength); { max }
SetLength(FCodeFoldingRangeFromLine, 0); { empty }
SetLength(FCodeFoldingRangeFromLine, LLength); { max }
SetLength(FCodeFoldingRangeToLine, 0); { empty }
SetLength(FCodeFoldingRangeToLine, LLength); { max }
for i := FAllCodeFoldingRanges.AllCount - 1 downto 0 do
begin
LCodeFoldingRange := FAllCodeFoldingRanges[i];
if Assigned(LCodeFoldingRange) then
if (not LCodeFoldingRange.ParentCollapsed) and ((LCodeFoldingRange.FromLine <> LCodeFoldingRange.ToLine) or
LCodeFoldingRange.RegionItem.TokenEndIsPreviousLine and (LCodeFoldingRange.FromLine = LCodeFoldingRange.ToLine)) then
if (LCodeFoldingRange.FromLine > 0) and (LCodeFoldingRange.FromLine <= LLength) then
begin
FCodeFoldingRangeFromLine[LCodeFoldingRange.FromLine] := LCodeFoldingRange;
if LCodeFoldingRange.Collapsable then
begin
for j := LCodeFoldingRange.FromLine + 1 to LCodeFoldingRange.ToLine - 1 do
FCodeFoldingTreeLine[j] := True;
FCodeFoldingRangeToLine[LCodeFoldingRange.ToLine] := LCodeFoldingRange;
end;
end;
end;
end;
procedure TBCBaseEditor.CodeFoldingOnChange(AEvent: TBCEditorCodeFoldingChanges);
begin
if AEvent = fcEnabled then
begin
if not FCodeFolding.Visible then
CodeFoldingUncollapseAll
else
InitCodeFolding;
end
else
if AEvent = fcRescan then
begin
InitCodeFolding;
if FHighlighter.FileName <> '' then
FHighlighter.LoadFromFile(FHighlighter.FileName);
end;
Invalidate;
end;
procedure TBCBaseEditor.CodeFoldingUncollapse(AFoldRange: TBCEditorCodeFoldingRange);
begin
ClearMatchingPair;
FResetLineNumbersCache := True;
with AFoldRange do
begin
Collapsed := False;
SetParentCollapsedOfSubCodeFoldingRanges(False, FoldRangeLevel);
end;
CheckIfAtMatchingKeywords;
Paint;
UpdateScrollBars;
end;
procedure TBCBaseEditor.CompletionProposalTimerHandler(Sender: TObject);
begin
FCompletionProposalTimer.Enabled := False;
DoExecuteCompletionProposal;
end;
procedure TBCBaseEditor.ComputeCaret(X, Y: Integer);
var
LCaretNearestPosition: TBCEditorDisplayPosition;
begin
LCaretNearestPosition := PixelsToNearestRowColumn(X, Y);
LCaretNearestPosition.Row := MinMax(LCaretNearestPosition.Row, 1, FLineNumbersCount);
if FWordWrap.Enabled then
if FWordWrapLineLengths[LCaretNearestPosition.Row] <> 0 then
LCaretNearestPosition.Column := MinMax(LCaretNearestPosition.Column, 1, FWordWrapLineLengths[LCaretNearestPosition.Row] + 1);
TextCaretPosition := DisplayToTextPosition(LCaretNearestPosition);
end;
procedure TBCBaseEditor.ComputeScroll(X, Y: Integer);
var
LScrollBounds: TRect;
LScrollBoundsLeft, LScrollBoundsRight: Integer;
LCursorIndex: Integer;
begin
if FMouseMoveScrolling then
begin
if (X < ClientRect.Left) or (X > ClientRect.Right) or (Y < ClientRect.Top) or (Y > ClientRect.Bottom) then
begin
FMouseMoveScrollTimer.Enabled := False;
Exit;
end;
LCursorIndex := GetMouseMoveScrollCursorIndex;
case LCursorIndex of
scNorthWest, scWest, scSouthWest:
FScrollDeltaX := (X - FMouseMoveScrollingPoint.X) div FCharWidth - 1;
scNorthEast, scEast, scSouthEast:
FScrollDeltaX := (X - FMouseMoveScrollingPoint.X) div FCharWidth + 1;
else
FScrollDeltaX := 0;
end;
case LCursorIndex of
scNorthWest, scNorth, scNorthEast:
FScrollDeltaY := (Y - FMouseMoveScrollingPoint.Y) div FLineHeight - 1;
scSouthWest, scSouth, scSouthEast:
FScrollDeltaY := (Y - FMouseMoveScrollingPoint.Y) div FLineHeight + 1;
else
FScrollDeltaY := 0;
end;
FMouseMoveScrollTimer.Enabled := (FScrollDeltaX <> 0) or (FScrollDeltaY <> 0);
end
else
begin
if not MouseCapture and not Dragging then
begin
FScrollTimer.Enabled := False;
Exit;
end;
LScrollBoundsLeft := FLeftMargin.GetWidth + FCodeFolding.GetWidth;
if FMinimap.Align = maLeft then
Inc(LScrollBoundsLeft, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LScrollBoundsLeft, FSearch.Map.GetWidth);
LScrollBoundsRight := LScrollBoundsLeft + VisibleChars * FCharWidth + 4;
LScrollBounds := Bounds(LScrollBoundsLeft, 0, LScrollBoundsRight, FVisibleLines * FLineHeight);
DeflateMinimapRect(LScrollBounds);
if BorderStyle = bsNone then
InflateRect(LScrollBounds, -2, -2);
if X < LScrollBounds.Left then
FScrollDeltaX := (X - LScrollBounds.Left) div FCharWidth - 1
else
if X >= LScrollBounds.Right then
FScrollDeltaX := (X - LScrollBounds.Right) div FCharWidth + 1
else
FScrollDeltaX := 0;
if Y < LScrollBounds.Top then
FScrollDeltaY := (Y - LScrollBounds.Top) div FLineHeight - 1
else
if Y >= LScrollBounds.Bottom then
FScrollDeltaY := (Y - LScrollBounds.Bottom) div FLineHeight + 1
else
FScrollDeltaY := 0;
FScrollTimer.Enabled := (FScrollDeltaX <> 0) or (FScrollDeltaY <> 0);
end;
end;
procedure TBCBaseEditor.DeflateMinimapRect(var ARect: TRect);
begin
if FMinimap.Align = maRight then
ARect.Right := ClientRect.Width - FMinimap.GetWidth
else
ARect.Left := FMinimap.GetWidth;
if FSearch.Map.Align = saRight then
Dec(ARect.Right, FSearch.Map.GetWidth)
else
Inc(ARect.Left, FSearch.Map.GetWidth);
end;
procedure TBCBaseEditor.DoToggleSelectedCase(const ACommand: TBCEditorCommand);
function ToggleCase(const AValue: string): string;
var
i: Integer;
S: string;
begin
Result := AnsiUpperCase(AValue);
S := AnsiLowerCase(AValue);
for i := 1 to Length(AValue) do
if Result[i] = AValue[i] then
Result[i] := S[i];
end;
function TitleCase(const AValue: string): string;
var
i, LLength: Integer;
S: string;
begin
Result := '';
i := 1;
LLength := Length(AValue);
while i <= LLength do
begin
S := AValue[i];
if i > 1 then
begin
if AValue[i - 1] = ' ' then
S := AnsiUpperCase(S)
else
S := AnsiLowerCase(S);
end
else
S := AnsiUpperCase(S);
Result := Result + S;
Inc(i);
end;
end;
var
LSelectedText: string;
LOldCaretPosition, LOldBlockBeginPosition, LOldBlockEndPosition: TBCEditorTextPosition;
LWasSelectionAvailable: Boolean;
begin
Assert((ACommand >= ecUpperCase) and (ACommand <= ecAlternatingCaseBlock));
if SelectionAvailable then
begin
LWasSelectionAvailable := True;
LOldBlockBeginPosition := SelectionBeginPosition;
LOldBlockEndPosition := SelectionEndPosition;
end
else
LWasSelectionAvailable := False;
LOldCaretPosition := TextCaretPosition;
try
LSelectedText := SelectedText;
if LSelectedText <> '' then
begin
case ACommand of
ecUpperCase, ecUpperCaseBlock:
LSelectedText := AnsiUpperCase(LSelectedText);
ecLowerCase, ecLowerCaseBlock:
LSelectedText := AnsiLowerCase(LSelectedText);
ecAlternatingCase, ecAlternatingCaseBlock:
LSelectedText := ToggleCase(LSelectedText);
ecSentenceCase:
LSelectedText := AnsiUpperCase(LSelectedText[1]) + AnsiLowerCase(Copy(LSelectedText, 2, Length(LSelectedText)));
ecTitleCase:
LSelectedText := TitleCase(LSelectedText);
end;
BeginUndoBlock;
try
if LWasSelectionAvailable then
FUndoList.AddChange(crSelection, LOldCaretPosition, LOldBlockBeginPosition, LOldBlockEndPosition, '',
FSelection.ActiveMode)
else
FUndoList.AddChange(crSelection, LOldCaretPosition, LOldCaretPosition, LOldCaretPosition, '',
FSelection.ActiveMode);
FUndoList.AddChange(crCaret, LOldCaretPosition, LOldBlockBeginPosition, LOldBlockEndPosition, '',
FSelection.ActiveMode);
SelectedText := LSelectedText;
finally
EndUndoBlock;
end;
end;
finally
if LWasSelectionAvailable and (ACommand >= ecUpperCaseBlock) then
begin
SelectionBeginPosition := LOldBlockBeginPosition;
SelectionEndPosition := LOldBlockEndPosition;
end;
if LWasSelectionAvailable or (ACommand < ecUpperCaseBlock) then
TextCaretPosition := LOldCaretPosition;
end;
end;
procedure TBCBaseEditor.DoEndKey(ASelection: Boolean);
var
LLineText: string;
LTextCaretPosition: TBCEditorTextPosition;
LEndOfLineCaretPosition: TBCEditorTextPosition;
LPLine: PChar;
LChar: Integer;
begin
LTextCaretPosition := TextCaretPosition;
LLineText := FLines[LTextCaretPosition.Line];
LEndOfLineCaretPosition := GetTextPosition(Length(LLineText) + 1, LTextCaretPosition.Line);
LPLine := PChar(LLineText);
Inc(LPLine, LEndOfLineCaretPosition.Char - 2);
LChar := LEndOfLineCaretPosition.Char;
while (LPLine^ > BCEDITOR_NONE_CHAR) and (LPLine^ <= BCEDITOR_SPACE_CHAR) do
begin
Dec(LChar);
Dec(LPLine);
end;
if LTextCaretPosition.Char < LChar then
LEndOfLineCaretPosition.Char := LChar;
MoveCaretAndSelection(LTextCaretPosition, LEndOfLineCaretPosition, ASelection);
end;
procedure TBCBaseEditor.DoHomeKey(ASelection: Boolean);
var
LLineText: string;
LTextCaretPosition: TBCEditorTextPosition;
LSpaceCount: Integer;
begin
LTextCaretPosition := TextCaretPosition;
LLineText := FLines[LTextCaretPosition.Line];
LSpaceCount := LeftSpaceCount(LLineText) + 1;
if LTextCaretPosition.Char <= LSpaceCount then
LSpaceCount := 1;
MoveCaretAndSelection(LTextCaretPosition, GetTextPosition(LSpaceCount, GetTextCaretY), ASelection);
end;
procedure TBCBaseEditor.DoShiftTabKey;
var
LNewX, LTabWidth: Integer;
LTextLine, LOldSelectedText: string;
LTextCaretPosition: TBCEditorTextPosition;
LChangeScroll: Boolean;
begin
if (toSelectedBlockIndent in FTabs.Options) and SelectionAvailable then
begin
DoBlockUnindent;
Exit;
end;
LTextCaretPosition := TextCaretPosition;
if toTabsToSpaces in FTabs.Options then
LTabWidth := FTabs.Width
else
LTabWidth := 1;
LNewX := TextCaretPosition.Char - LTabWidth;
if LNewX < 1 then
LNewX := 1;
if LNewX <> TextCaretPosition.Char then
begin
LOldSelectedText := Copy(FLines[LTextCaretPosition.Line], LNewX, LTabWidth);
if toTabsToSpaces in FTabs.Options then
begin
if LOldSelectedText <> StringOfChar(BCEDITOR_SPACE_CHAR, FTabs.Width) then
Exit;
end
else
if LOldSelectedText <> BCEDITOR_TAB_CHAR then
Exit;
LTextLine := FLines[LTextCaretPosition.Line];
Delete(LTextLine, LNewX, LTabWidth);
FLines[LTextCaretPosition.Line] := LTextLine;
LChangeScroll := not (soPastEndOfLine in FScroll.Options);
try
FScroll.Options := FScroll.Options + [soPastEndOfLine];
SetTextCaretX(LNewX);
finally
if LChangeScroll then
FScroll.Options := FScroll.Options - [soPastEndOfLine];
end;
FUndoList.AddChange(crDelete, LTextCaretPosition, TextCaretPosition, LTextCaretPosition, LOldSelectedText, smNormal,
2);
end;
end;
procedure TBCBaseEditor.DoSyncEdit;
var
i, j: Integer;
LEditText, LOldText: string;
LTextCaretPosition, LTextBeginPosition, LTextEndPosition, LTextSameLinePosition: TBCEditorTextPosition;
LDifference: Integer;
begin
LTextCaretPosition := TextCaretPosition;
LEditText := Copy(FLines[FSyncEdit.EditBeginPosition.Line], FSyncEdit.EditBeginPosition.Char,
FSyncEdit.EditEndPosition.Char - FSyncEdit.EditBeginPosition.Char);
LDifference := Length(LEditText) - FSyncEdit.EditWidth;
for i := 0 to FSyncEdit.SyncItems.Count - 1 do
begin
LTextBeginPosition := PBCEditorTextPosition(FSyncEdit.SyncItems.Items[i])^;
if (LTextBeginPosition.Line = FSyncEdit.EditBeginPosition.Line) and
(LTextBeginPosition.Char < FSyncEdit.EditBeginPosition.Char) then
begin
FSyncEdit.MoveBeginPositionChar(LDifference);
FSyncEdit.MoveEndPositionChar(LDifference);
LTextCaretPosition.Char := LTextCaretPosition.Char + LDifference;
//SetTextCaretX(TextCaretPosition.Char + LDifference);
end;
if (LTextBeginPosition.Line = FSyncEdit.EditBeginPosition.Line) and
(LTextBeginPosition.Char > FSyncEdit.EditBeginPosition.Char) then
begin
Inc(LTextBeginPosition.Char, LDifference);
PBCEditorTextPosition(FSyncEdit.SyncItems.Items[i])^.Char := LTextBeginPosition.Char;
end;
LTextEndPosition := LTextBeginPosition;
LTextEndPosition.Char := LTextEndPosition.Char + FSyncEdit.EditWidth;
LOldText := Copy(FLines[LTextBeginPosition.Line], LTextBeginPosition.Char, FSyncEdit.EditWidth);
FUndoList.AddChange(crDelete, LTextCaretPosition, LTextBeginPosition, LTextEndPosition, '', FSelection.ActiveMode);
LTextEndPosition := LTextBeginPosition;
LTextEndPosition.Char := LTextEndPosition.Char + Length(LEditText);
FUndoList.AddChange(crInsert, LTextCaretPosition, LTextBeginPosition, LTextEndPosition, LOldText, FSelection.ActiveMode);
FLines.BeginUpdate;
FLines[LTextBeginPosition.Line] := Copy(FLines[LTextBeginPosition.Line], 1, LTextBeginPosition.Char - 1) + LEditText +
Copy(FLines[LTextBeginPosition.Line], LTextBeginPosition.Char + FSyncEdit.EditWidth, Length(FLines[LTextBeginPosition.Line]));
FLines.EndUpdate;
j := i + 1;
if j < FSyncEdit.SyncItems.Count then
begin
LTextSameLinePosition := PBCEditorTextPosition(FSyncEdit.SyncItems.Items[j])^;
while (j < FSyncEdit.SyncItems.Count) and (LTextSameLinePosition.Line = LTextBeginPosition.Line) do
begin
PBCEditorTextPosition(FSyncEdit.SyncItems.Items[j])^.Char := LTextSameLinePosition.Char + LDifference;
Inc(j);
if j < FSyncEdit.SyncItems.Count then
LTextSameLinePosition := PBCEditorTextPosition(FSyncEdit.SyncItems.Items[j])^;
end;
end;
end;
FSyncEdit.EditWidth := FSyncEdit.EditEndPosition.Char - FSyncEdit.EditBeginPosition.Char;
TextCaretPosition := LTextCaretPosition;
end;
procedure TBCBaseEditor.DoTabKey;
var
LTextCaretPosition: TBCEditorTextPosition;
LDisplayCaretPosition: TBCEditorDisplayPosition;
LTabText, LTextLine: string;
LCharCount, LLengthAfterLine, LPreviousLine, LPreviousLineCharCount: Integer;
LChangeScroll: Boolean;
begin
if SelectionAvailable and (FSelectionBeginPosition.Line <> FSelectionEndPosition.Line) and
(toSelectedBlockIndent in FTabs.Options) then
begin
DoBlockIndent;
Exit;
end;
FUndoList.BeginBlock(1);
try
LTextCaretPosition := TextCaretPosition;
if SelectionAvailable then
begin
FUndoList.AddChange(crDelete, LTextCaretPosition, SelectionBeginPosition, SelectionEndPosition, GetSelectedText,
FSelection.ActiveMode);
DoSelectedText('');
LTextCaretPosition := FSelectionBeginPosition;
end;
LTextLine := FLines[LTextCaretPosition.Line];
LDisplayCaretPosition := DisplayCaretPosition;
LLengthAfterLine := Max(LDisplayCaretPosition.Column - FLines.ExpandedStringLengths[LTextCaretPosition.Line], 1);
if LLengthAfterLine > 1 then
LCharCount := LLengthAfterLine
else
LCharCount := FTabs.Width;
if toPreviousLineIndent in FTabs.Options then
if Trim(FLines[LTextCaretPosition.Line]) = '' then
begin
LPreviousLine := LTextCaretPosition.Line - 1;
while (LPreviousLine >= 0) and (FLines[LPreviousLine] = '') do
Dec(LPreviousLine);
LPreviousLineCharCount := LeftSpaceCount(FLines[LPreviousLine], True);
if LPreviousLineCharCount > LTextCaretPosition.Char then
LCharCount := LPreviousLineCharCount - LeftSpaceCount(FLines[LTextCaretPosition.Line], True)
end;
if LLengthAfterLine > 1 then
LTextCaretPosition.Char := Length(LTextLine) + 1;
if toTabsToSpaces in FTabs.Options then
LTabText := StringOfChar(BCEDITOR_SPACE_CHAR, LCharCount)
else
begin
LTabText := StringOfChar(BCEDITOR_TAB_CHAR, LCharCount div FTabs.Width);
LTabText := LTabText + StringOfChar(BCEDITOR_TAB_CHAR, LCharCount mod FTabs.Width);
end;
if InsertMode then
begin
Insert(LTabText, LTextLine, LTextCaretPosition.Char);
FLines[LTextCaretPosition.Line] := LTextLine;
end;
LChangeScroll := not (soPastEndOfLine in FScroll.Options);
try
FScroll.Options := FScroll.Options + [soPastEndOfLine];
if not InsertMode then
LTabText := StringReplace(LTabText, BCEDITOR_TAB_CHAR, StringOfChar(BCEDITOR_SPACE_CHAR, FTabs.Width), [rfReplaceAll]);
SetTextCaretX(LTextCaretPosition.Char + Length(LTabText));
finally
if LChangeScroll then
FScroll.Options := FScroll.Options - [soPastEndOfLine];
end;
EnsureCursorPositionVisible;
if FSelection.ActiveMode <> smColumn then
begin
if InsertMode then
FUndoList.AddChange(crInsert, LTextCaretPosition, LTextCaretPosition, TextCaretPosition, '', FSelection.ActiveMode)
else
FUndoList.AddChange(crCaret, LTextCaretPosition, LTextCaretPosition, LTextCaretPosition, '', FSelection.ActiveMode);
end
finally
FUndoList.EndBlock;
end;
end;
procedure TBCBaseEditor.DrawCursor(ACanvas: TCanvas);
var
LPoint: TPoint;
LCaretStyle: TBCEditorCaretStyle;
LCaretWidth, LCaretHeight, X, Y: Integer;
LTempBitmap: Vcl.Graphics.TBitmap;
LTextCaretPosition: TBCEditorTextPosition;
begin
if GetSelectionLength > 0 then
Exit;
LPoint := RowColumnToPixels(GetDisplayCaretPosition);
Y := 0;
X := 0;
LCaretHeight := 1;
LCaretWidth := FCharWidth;
if InsertMode then
LCaretStyle := FCaret.Styles.Insert
else
LCaretStyle := FCaret.Styles.Overwrite;
case LCaretStyle of
csHorizontalLine, csThinHorizontalLine:
begin
if LCaretStyle = csHorizontalLine then
LCaretHeight := 2;
Y := FLineHeight - LCaretHeight;
LPoint.Y := LPoint.Y + Y;
LPoint.X := LPoint.X + 1;
end;
csHalfBlock:
begin
LCaretHeight := FLineHeight div 2;
Y := FLineHeight div 2;
LPoint.Y := LPoint.Y + Y;
LPoint.X := LPoint.X + 1;
end;
csBlock:
begin
LCaretHeight := FLineHeight;
LPoint.X := LPoint.X + 1;
end;
csVerticalLine, csThinVerticalLine:
begin
LCaretWidth := 1;
if LCaretStyle = csVerticalLine then
LCaretWidth := 2;
LCaretHeight := FLineHeight;
X := 1;
end;
end;
LTempBitmap := Vcl.Graphics.TBitmap.Create;
try
{ Background }
LTempBitmap.Canvas.Pen.Color := FCaret.NonBlinking.Colors.Background;
LTempBitmap.Canvas.Brush.Color := FCaret.NonBlinking.Colors.Background;
{ Size }
LTempBitmap.Width := FCharWidth;
LTempBitmap.Height := FLineHeight;
{ Character }
LTempBitmap.Canvas.Brush.Style := bsClear;
LTempBitmap.Canvas.Font.Name := Font.Name;
LTempBitmap.Canvas.Font.Color := FCaret.NonBlinking.Colors.Foreground;
LTempBitmap.Canvas.Font.Style := Font.Style;
LTempBitmap.Canvas.Font.Height := Font.Height;
LTempBitmap.Canvas.Font.Size := Font.Size;
LTextCaretPosition := GetTextCaretPosition;
if LTextCaretPosition.Char <= FLines[LTextCaretPosition.Line].Length then
LTempBitmap.Canvas.TextOut(X, 0, FLines[LTextCaretPosition.Line][LTextCaretPosition.Char]);
{ Copy rect }
ACanvas.CopyRect(Rect(LPoint.X + FCaret.Offsets.X, LPoint.Y + FCaret.Offsets.Y, LPoint.X + FCaret.Offsets.X + LCaretWidth,
LPoint.Y + FCaret.Offsets.Y + LCaretHeight), LTempBitmap.Canvas, Rect(0, Y, LCaretWidth, Y + LCaretHeight));
finally
LTempBitmap.Free
end;
end;
procedure TBCBaseEditor.FindAll(const ASearchText: string = '');
var
LKeyword: string;
begin
FSearch.ClearLines;
if ASearchText = '' then
LKeyword := FSearch.SearchText
else
LKeyword := ASearchText;
if LKeyword = '' then
Exit;
FindWords(LKeyword, FSearch.Lines, soCaseSensitive in FSearch.Options, False);
end;
procedure TBCBaseEditor.FindWords(const AWord: string; AList: TList; ACaseSensitive: Boolean; AWholeWordsOnly: Boolean);
var
i: Integer;
LLine: string;
LTextPtr, LKeyWordPtr, LBookmarkTextPtr: PChar;
LPTextPosition: PBCEditorTextPosition;
function AreCharsSame(APChar1, APChar2: PChar): Boolean;
begin
if ACaseSensitive then
Result := APChar1^ = APChar2^
else
Result := UpCase(APChar1^) = UpCase(APChar2^)
end;
function IsWholeWord(FirstChar, LastChar: PChar): Boolean;
begin
Result := IsWordBreakChar(FirstChar^) and IsWordBreakChar(LastChar^);
end;
begin
for i := 0 to FLines.Count - 1 do
begin
LLine := FLines[i];
LTextPtr := PChar(LLine);
while LTextPtr^ <> BCEDITOR_NONE_CHAR do
begin
if AreCharsSame(LTextPtr, PChar(AWord)) then { if the first character is a match }
begin
LKeyWordPtr := PChar(AWord);
LBookmarkTextPtr := LTextPtr;
{ check if the keyword found }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and AreCharsSame(LTextPtr, LKeyWordPtr) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
if (LKeyWordPtr^ = BCEDITOR_NONE_CHAR) and
(not AWholeWordsOnly or AWholeWordsOnly and IsWholeWord(LBookmarkTextPtr - 1, LTextPtr)) then
begin
Dec(LTextPtr);
New(LPTextPosition);
LPTextPosition^.Char := LBookmarkTextPtr - PChar(LLine) + 1;
LPTextPosition^.Line := i;
AList.Add(LPTextPosition)
end
else
LTextPtr := LBookmarkTextPtr; { not found, return pointer back }
end;
Inc(LTextPtr);
end;
end;
end;
procedure TBCBaseEditor.FontChanged(Sender: TObject);
begin
RecalculateCharExtent;
SizeOrFontChanged(True);
end;
procedure TBCBaseEditor.GetMinimapLeftRight(var ALeft: Integer; var ARight: Integer);
begin
if FMinimap.Align = maRight then
begin
ALeft := ClientRect.Width - FMinimap.GetWidth;
ARight := ClientRect.Width;
end
else
begin
ALeft := 0;
ARight := FMinimap.GetWidth;
end;
if FSearch.Map.Align = saRight then
begin
Dec(ALeft, FSearch.Map.GetWidth);
Dec(ARight, FSearch.Map.GetWidth);
end
else
begin
Inc(ALeft, FSearch.Map.GetWidth);
Inc(ARight, FSearch.Map.GetWidth);
end;
end;
procedure TBCBaseEditor.LinesChanging(Sender: TObject);
begin
Include(FStateFlags, sfLinesChanging);
end;
procedure TBCBaseEditor.MinimapChanged(Sender: TObject);
var
i: Integer;
begin
FMinimapBufferBmp.Height := 0;
SizeOrFontChanged(True);
if FMinimap.Shadow.Visible then
begin
FMinimapShadowBlendFunction.SourceConstantAlpha := FMinimap.Shadow.AlphaBlending;
FMinimapShadowBitmap.Canvas.Brush.Color := FMinimap.Shadow.Color;
FMinimapShadowBitmap.Width := FMinimap.Shadow.Width;
SetLength(FMinimapShadowAlphaArray, FMinimapShadowBitmap.Width);
SetLength(FMinimapShadowAlphaByteArray, FMinimapShadowBitmap.Width);
for i := 0 to FMinimapShadowBitmap.Width - 1 do
begin
if FMinimap.Align = maLeft then
FMinimapShadowAlphaArray[i] := (FMinimapShadowBitmap.Width - i) / FMinimapShadowBitmap.Width
else
FMinimapShadowAlphaArray[i] := i / FMinimapShadowBitmap.Width;
FMinimapShadowAlphaByteArray[i] := Min(Round(Power(FMinimapShadowAlphaArray[i], 4) * 255.0), 255);
end;
end;
Invalidate;
end;
procedure TBCBaseEditor.MouseMoveScrollTimerHandler(Sender: TObject);
var
LCursorPoint: TPoint;
begin
IncPaintLock;
try
Winapi.Windows.GetCursorPos(LCursorPoint);
LCursorPoint := ScreenToClient(LCursorPoint);
if FScrollDeltaX <> 0 then
LeftChar := LeftChar + FScrollDeltaX;
if FScrollDeltaY <> 0 then
begin
if GetKeyState(VK_SHIFT) < 0 then
TopLine := TopLine + FScrollDeltaY * VisibleLines
else
TopLine := TopLine + FScrollDeltaY;
end;
finally
DecPaintLock;
Invalidate;
end;
ComputeScroll(LCursorPoint.X, LCursorPoint.Y);
end;
procedure TBCBaseEditor.MoveCaretAndSelection(const ABeforeTextPosition, AAfterTextPosition: TBCEditorTextPosition;
ASelectionCommand: Boolean);
var
LReason: TBCEditorChangeReason;
begin
if not (uoGroupUndo in FUndo.Options) and UndoList.CanUndo then
FUndoList.AddGroupBreak;
if not ASelectionCommand then
begin
if SelectionAvailable then
LReason := crSelection
else
LReason := crCaret;
FUndoList.AddChange(LReason, TextCaretPosition, SelectionBeginPosition, SelectionEndPosition, '',
FSelection.ActiveMode);
end;
IncPaintLock;
if ASelectionCommand then
begin
if not SelectionAvailable then
SetSelectionBeginPosition(ABeforeTextPosition);
SetSelectionEndPosition(AAfterTextPosition);
end
else
SetSelectionBeginPosition(AAfterTextPosition);
TextCaretPosition := AAfterTextPosition;
//if GetVisibleChars > FVisibleChars then
EnsureCursorPositionVisible;
DecPaintLock;
end;
procedure TBCBaseEditor.MoveCaretHorizontally(const X: Integer; ASelectionCommand: Boolean);
var
LZeroPosition, LDestinationPosition, LTextCaretPosition: TBCEditorTextPosition;
LCurrentLineLength: Integer;
LChangeY: Boolean;
LCaretRowColumn: TBCEditorDisplayPosition;
begin
LTextCaretPosition := TextCaretPosition;
if not SelectionAvailable then
begin
FSelectionBeginPosition := LTextCaretPosition;
FSelectionEndPosition := LTextCaretPosition;
end;
LZeroPosition := LTextCaretPosition;
LDestinationPosition := LZeroPosition;
LCurrentLineLength := FLines.StringLength(LTextCaretPosition.Line);
LChangeY := not (soPastEndOfLine in FScroll.Options);
if LChangeY and (X = -1) and (LZeroPosition.Char = 1) and (LZeroPosition.Line > 1) then
with LDestinationPosition do
begin
Line := Line - 1;
Char := FLines.StringLength(Line) + 1;
end
else
if LChangeY and (X = 1) and (LZeroPosition.Char > LCurrentLineLength) and (LZeroPosition.Line < FLines.Count) then
with LDestinationPosition do
begin
Line := LDestinationPosition.Line + 1;
Char := 1;
end
else
begin
LDestinationPosition.Char := Max(1, LDestinationPosition.Char + X);
if (X > 0) and LChangeY then
LDestinationPosition.Char := Min(LDestinationPosition.Char, LCurrentLineLength + 1);
end;
if not ASelectionCommand and (LDestinationPosition.Line <> LZeroPosition.Line) then
begin
DoTrimTrailingSpaces(LZeroPosition.Line);
DoTrimTrailingSpaces(LDestinationPosition.Line);
end;
MoveCaretAndSelection(FSelectionBeginPosition, LDestinationPosition, ASelectionCommand);
if FWordWrap.Enabled and (X > 0) and (DisplayCaretX < FLines.ExpandedStringLengths[LTextCaretPosition.Line]) then
begin
LCaretRowColumn := DisplayCaretPosition;
if (FWordWrapLineLengths[LCaretRowColumn.Row] = 0) and (LCaretRowColumn.Column - 1 > GetVisibleChars) or
(FWordWrapLineLengths[LCaretRowColumn.Row] <> 0) and (LCaretRowColumn.Column - 1 > FWordWrapLineLengths[LCaretRowColumn.Row]) then
begin
Inc(LCaretRowColumn.Row);
LCaretRowColumn.Column := 1;
DisplayCaretPosition := LCaretRowColumn;
end;
end;
end;
procedure TBCBaseEditor.MoveCaretVertically(const Y: Integer; ASelectionCommand: Boolean);
var
LDestinationPosition: TBCEditorDisplayPosition;
LDestinationLineChar: TBCEditorTextPosition;
begin
LDestinationPosition := DisplayCaretPosition;
Inc(LDestinationPosition.Row, Y);
if Y >= 0 then
begin
if LDestinationPosition.Row > FLineNumbersCount then
LDestinationPosition.Row := Max(1, FLineNumbersCount);
end
else
if LDestinationPosition.Row < 1 then
LDestinationPosition.Row := 1;
LDestinationLineChar := DisplayToTextPosition(LDestinationPosition);
if not ASelectionCommand and (LDestinationLineChar.Line <> FSelectionBeginPosition.Line) then
begin
DoTrimTrailingSpaces(FSelectionBeginPosition.Line);
DoTrimTrailingSpaces(LDestinationLineChar.Line);
end;
if not SelectionAvailable then
FSelectionBeginPosition := TextCaretPosition;
MoveCaretAndSelection(FSelectionBeginPosition, LDestinationLineChar, ASelectionCommand);
end;
function TBCBaseEditor.NextSelectedWordPosition: Boolean;
var
LSelectedText: string;
LPreviousTextCaretPosition, LTextCaretPosition: TBCEditorTextPosition;
begin
Result := False;
if not SelectionAvailable then
Exit;
LSelectedText := SelectedText;
LTextCaretPosition := NextWordPosition;
while LSelectedText <> GetWordAtTextPosition(LTextCaretPosition) do
begin
LPreviousTextCaretPosition := LTextCaretPosition;
LTextCaretPosition := NextWordPosition(LTextCaretPosition);
if (LTextCaretPosition.Line = LPreviousTextCaretPosition.Line) and (LTextCaretPosition.Char = LPreviousTextCaretPosition.Char) then
Exit;
end;
TextCaretPosition := LTextCaretPosition;
SelectionBeginPosition := LTextCaretPosition;
SelectionEndPosition := GetTextPosition(LTextCaretPosition.Char + Length(LSelectedText), LTextCaretPosition.Line);
Result := True;
end;
procedure TBCBaseEditor.OpenLink(AURI: string; ARangeType: TBCEditorRangeType);
begin
case TBCEditorRangeType(ARangeType) of
ttMailtoLink:
if (Pos(BCEDITOR_MAILTO, AURI) <> 1) then
AURI := BCEDITOR_MAILTO + AURI;
ttWebLink:
AURI := BCEDITOR_HTTP + AURI;
end;
ShellExecute(0, nil, PChar(AURI), nil, nil, SW_SHOWNORMAL);
end;
procedure TBCBaseEditor.PreviousSelectedWordPosition;
var
LSelectedText: string;
LPreviousTextCaretPosition, LTextCaretPosition: TBCEditorTextPosition;
LLength: Integer;
begin
if not SelectionAvailable then
Exit;
LSelectedText := SelectedText;
LLength := Length(LSelectedText);
LTextCaretPosition := PreviousWordPosition;
Dec(LTextCaretPosition.Char, LLength);
while LSelectedText <> GetWordAtTextPosition(LTextCaretPosition) do
begin
LPreviousTextCaretPosition := LTextCaretPosition;
LTextCaretPosition := PreviousWordPosition(LTextCaretPosition);
if (LTextCaretPosition.Line = LPreviousTextCaretPosition.Line) and (LTextCaretPosition.Char = LPreviousTextCaretPosition.Char) then
Exit;
Dec(LTextCaretPosition.Char, LLength);
end;
TextCaretPosition := LTextCaretPosition;
SelectionBeginPosition := LTextCaretPosition;
SelectionEndPosition := GetTextPosition(LTextCaretPosition.Char + Length(LSelectedText), LTextCaretPosition.Line);
end;
procedure TBCBaseEditor.SetLineWithRightTrim(ALine: Integer; const ALineText: string);
begin
if eoTrimTrailingSpaces in Options then
FLines[ALine] := TrimRight(ALineText)
else
FLines[ALine] := ALineText;
end;
procedure TBCBaseEditor.RefreshFind;
begin
if FSearch.Enabled then
if soHighlightResults in FSearch.Options then
if FSearch.SearchText <> '' then
FindAll;
end;
procedure TBCBaseEditor.RightMarginChanged(Sender: TObject);
begin
if FWordWrap.Enabled then
if FWordWrap.Style = wwsRightMargin then
FResetLineNumbersCache := True;
if not (csLoading in ComponentState) then
Invalidate;
end;
procedure TBCBaseEditor.ScanCodeFoldingRanges;
const
DEFAULT_CODE_FOLDING_RANGE_INDEX = 0;
var
LLine, LFoldCount: Integer;
LTextPtr: PChar;
LBeginningOfLine, LIsOneCharFolds: Boolean;
LKeyWordPtr, LBookmarkTextPtr, LBookmarkTextPtr2: PChar;
LLastFoldRange: TBCEditorCodeFoldingRange;
LOpenTokenSkipFoldRangeList: TList;
LOpenTokenFoldRangeList: TList;
LCodeFoldingRangeIndexList: TList;
LFoldRanges: TBCEditorCodeFoldingRanges;
LCurrentCodeFoldingRegion: TBCEditorCodeFoldingRegion;
function IsValidChar(Character: PChar): Boolean;
begin
Result := Character^.IsLower or Character^.IsUpper or Character^.IsNumber or
CharInSet(Character^, BCEDITOR_CODE_FOLDING_VALID_CHARACTERS);
end;
function IsWholeWord(FirstChar, LastChar: PChar): Boolean;
begin
Result := not IsValidChar(FirstChar) and not IsValidChar(LastChar);
end;
procedure SkipEmptySpace;
begin
while (LTextPtr^ < BCEDITOR_EXCLAMATION_MARK) and (LTextPtr^ <> BCEDITOR_NONE_CHAR) do
Inc(LTextPtr);
end;
function CountCharsBefore(TextPtr: PChar; Character: Char): Integer;
var
TempPtr: PChar;
begin
Result := 0;
TempPtr := TextPtr - 1;
while TempPtr^ = Character do
begin
Inc(Result);
Dec(TempPtr);
end;
end;
function OddCountOfStringEscapeChars(ATextPtr: PChar): Boolean;
begin
Result := False;
if LCurrentCodeFoldingRegion.StringEscapeChar <> BCEDITOR_NONE_CHAR then
Result := Odd(CountCharsBefore(ATextPtr, LCurrentCodeFoldingRegion.StringEscapeChar));
end;
function EscapeChar(ATextPtr: PChar): Boolean;
begin
Result := False;
if LCurrentCodeFoldingRegion.EscapeChar <> BCEDITOR_NONE_CHAR then
Result := ATextPtr^ = LCurrentCodeFoldingRegion.EscapeChar;
end;
function IsNextSkipChar(ATextPtr: PChar; ASkipRegionItem: TBCEditorSkipRegionItem): Boolean;
begin
Result := False;
if ASkipRegionItem.SkipIfNextCharIsNot <> BCEDITOR_NONE_CHAR then
Result := (ATextPtr + 1)^ = ASkipRegionItem.SkipIfNextCharIsNot;
end;
function IsPreviousCharStringEscape(ATextPtr: PChar): Boolean;
begin
Result := False;
if LCurrentCodeFoldingRegion.StringEscapeChar <> BCEDITOR_NONE_CHAR then
Result := (ATextPtr - 1)^ = LCurrentCodeFoldingRegion.StringEscapeChar;
end;
function IsNextCharStringEscape(ATextPtr: PChar): Boolean;
begin
Result := False;
if LCurrentCodeFoldingRegion.StringEscapeChar <> BCEDITOR_NONE_CHAR then
Result := (ATextPtr + 1)^ = LCurrentCodeFoldingRegion.StringEscapeChar;
end;
function SkipRegionsClose: Boolean;
var
LSkipRegionItem: TBCEditorSkipRegionItem;
begin
Result := False;
{ Note! Check Close before Open because close and open keys might be same. }
if (LOpenTokenSkipFoldRangeList.Count > 0) and
CharInSet(LTextPtr^, FHighlighter.SkipCloseKeyChars) and not OddCountOfStringEscapeChars(LTextPtr) then
begin
LSkipRegionItem := LOpenTokenSkipFoldRangeList.Last;
LKeyWordPtr := PChar(LSkipRegionItem.CloseToken);
LBookmarkTextPtr := LTextPtr;
{ check if the close keyword found }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and
((LTextPtr^ = LKeyWordPtr^) or
(LSkipRegionItem.SkipEmptyChars and (LTextPtr^ < BCEDITOR_EXCLAMATION_MARK) )) do
begin
if (LTextPtr^ <> BCEDITOR_SPACE_CHAR) and (LTextPtr^ <> BCEDITOR_TAB_CHAR) then
Inc(LKeyWordPtr);
Inc(LTextPtr);
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then { if found, pop skip region from the stack }
begin
LOpenTokenSkipFoldRangeList.Delete(LOpenTokenSkipFoldRangeList.Count - 1);
Result := True;
end
else
LTextPtr := LBookmarkTextPtr; { skip region close not found, return pointer back }
end;
end;
function SkipRegionsOpen: Boolean;
var
i, j: Integer;
LSkipRegionItem: TBCEditorSkipRegionItem;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
Result := False;
if CharInSet(LTextPtr^, FHighlighter.SkipOpenKeyChars) then
if LOpenTokenSkipFoldRangeList.Count = 0 then
begin
LCodeFoldingRange := nil;
if LOpenTokenFoldRangeList.Count > 0 then
LCodeFoldingRange := LOpenTokenFoldRangeList.Last;
if Assigned(LCodeFoldingRange) and LCodeFoldingRange.RegionItem.NoSubs then
Exit;
j := LCurrentCodeFoldingRegion.SkipRegions.Count - 1;
for i := 0 to j do
begin
LSkipRegionItem := LCurrentCodeFoldingRegion.SkipRegions[i];
if (LTextPtr^ = PChar(LSkipRegionItem.OpenToken)^) and not OddCountOfStringEscapeChars(LTextPtr) and
not IsNextSkipChar(LTextPtr, LSkipRegionItem) then
begin
LKeyWordPtr := PChar(LSkipRegionItem.OpenToken);
LBookmarkTextPtr := LTextPtr;
{ check, if the open keyword found }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and
((LTextPtr^ = LKeyWordPtr^) or
(LSkipRegionItem.SkipEmptyChars and (LTextPtr^ < BCEDITOR_EXCLAMATION_MARK) )) do
begin
if not LSkipRegionItem.SkipEmptyChars or
(LSkipRegionItem.SkipEmptyChars and (LTextPtr^ <> BCEDITOR_SPACE_CHAR) and (LTextPtr^ <> BCEDITOR_TAB_CHAR)) then
Inc(LKeyWordPtr);
Inc(LTextPtr);
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then { if found, skip single line comment or push skip region into stack }
begin
if LSkipRegionItem.RegionType = ritSingleLineComment then
{ single line comment skip until next line }
Exit(True)
else
LOpenTokenSkipFoldRangeList.Add(LSkipRegionItem);
Dec(LTextPtr); { the end of the while loop will increase }
Break;
end
else
LTextPtr := LBookmarkTextPtr; { skip region open not found, return pointer back }
end;
end;
end;
end;
function RegionItemsClose: Boolean;
var
i, j, LIndexDecrease: Integer;
LCodeFoldingRange, LCodeFoldingRangeLast: TBCEditorCodeFoldingRange;
LRegionItem: TBCEditorCodeFoldingRegionItem;
procedure SetCodeFoldingRangeToLine(ACodeFoldingRange: TBCEditorCodeFoldingRange);
var
i: Integer;
begin
if ACodeFoldingRange.RegionItem.TokenEndIsPreviousLine then
begin
i := LLine - 1;
while (i > 0) and (FLines[i - 1] = '') do
Dec(i);
ACodeFoldingRange.ToLine := i
end
else
ACodeFoldingRange.ToLine := LLine;
end;
begin
Result := False;
if LOpenTokenSkipFoldRangeList.Count <> 0 then
Exit;
if LOpenTokenFoldRangeList.Count > 0 then
if (not IsValidChar(LTextPtr - 1) or LIsOneCharFolds) and CharInSet(UpCase(LTextPtr^), FHighlighter.FoldCloseKeyChars) then
begin
{$IFDEF WIN32}
LCodeFoldingRange := nil;
{$ENDIF}
LIndexDecrease := 1;
repeat
if LOpenTokenFoldRangeList.Count - LIndexDecrease < 0 then
Break;
LCodeFoldingRange := LOpenTokenFoldRangeList.Items[LOpenTokenFoldRangeList.Count - LIndexDecrease];
if LCodeFoldingRange.RegionItem.CloseTokenBeginningOfLine and not LBeginningOfLine then
Exit;
LKeyWordPtr := PChar(LCodeFoldingRange.RegionItem.CloseToken);
LBookmarkTextPtr := LTextPtr;
{ check if the close keyword found }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (UpCase(LTextPtr^) = LKeyWordPtr^) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then { if found, pop skip region from the stack }
begin
if (LCodeFoldingRange.RegionItem.CloseTokenLength = 1) or IsWholeWord(LBookmarkTextPtr - 1, LTextPtr) then { not interested in partial hits }
begin
LOpenTokenFoldRangeList.Remove(LCodeFoldingRange);
Dec(LFoldCount);
if LCodeFoldingRange.RegionItem.BreakIfNotFoundBeforeNextRegion <> '' then
if not LCodeFoldingRange.IsExtraTokenFound then
begin
LTextPtr := LBookmarkTextPtr;
Exit(True);
end;
SetCodeFoldingRangeToLine(LCodeFoldingRange);
{ Check if the code folding ranges have shared close }
if LOpenTokenFoldRangeList.Count > 0 then
for i := LOpenTokenFoldRangeList.Count - 1 downto 0 do
begin
LCodeFoldingRangeLast := LOpenTokenFoldRangeList.Items[i];
if Assigned(LCodeFoldingRangeLast.RegionItem) and LCodeFoldingRangeLast.RegionItem.SharedClose then
begin
LKeyWordPtr := PChar(LCodeFoldingRangeLast.RegionItem.CloseToken);
LTextPtr := LBookmarkTextPtr;
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (UpCase(LTextPtr^) = LKeyWordPtr^) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then
begin
SetCodeFoldingRangeToLine(LCodeFoldingRangeLast);
LOpenTokenFoldRangeList.Remove(LCodeFoldingRangeLast);
Dec(LFoldCount);
end;
end;
end;
{ Check if the close token is one of the open tokens }
LBookmarkTextPtr2 := LBookmarkTextPtr; { save Bookmark }
LBookmarkTextPtr := LTextPtr; { set the Bookmark into current position }
LTextPtr := LBookmarkTextPtr2; { go back to saved Bookmark }
j := LCurrentCodeFoldingRegion.Count - 1;
for i := 0 to j do
begin
LRegionItem := LCurrentCodeFoldingRegion[i];
if LRegionItem.OpenIsClose then { optimizing... }
begin
if UpCase(LTextPtr^) = PChar(LRegionItem.OpenToken)^ then { if first character match }
begin
LKeyWordPtr := PChar(LRegionItem.OpenToken);
{ check if open keyword found }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (UpCase(LTextPtr^) = LKeyWordPtr^) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then
begin
if (LRegionItem.OpenTokenLength = 1) or IsWholeWord(LBookmarkTextPtr2 - 1, LTextPtr) then { not interested in partial hits }
begin
if LOpenTokenFoldRangeList.Count > 0 then
LFoldRanges := TBCEditorCodeFoldingRange(LOpenTokenFoldRangeList.Last).SubCodeFoldingRanges
else
LFoldRanges := FAllCodeFoldingRanges;
LCodeFoldingRange := LFoldRanges.Add(FAllCodeFoldingRanges, LLine, GetLineIndentLevel(LLine - 1), LFoldCount,
LRegionItem, LLine);
{ open keyword found }
LOpenTokenFoldRangeList.Add(LCodeFoldingRange);
Inc(LFoldCount);
Break;
end
else
LTextPtr := LBookmarkTextPtr2; { skip region close not found, return pointer back }
end
else
LTextPtr := LBookmarkTextPtr2; { skip region close not found, return pointer back }
end;
LTextPtr := LBookmarkTextPtr; { go back where we were }
end;
end;
LTextPtr := LBookmarkTextPtr; { go back where we were }
Result := True;
end
else
LTextPtr := LBookmarkTextPtr; { region close not found, return pointer back }
end
else
LTextPtr := LBookmarkTextPtr; { region close not found, return pointer back }
Inc(LIndexDecrease);
until Assigned(LCodeFoldingRange) and ( (LCodeFoldingRange.RegionItem.BreakIfNotFoundBeforeNextRegion = '') or (LOpenTokenFoldRangeList.Count - LIndexDecrease < 0) );
end;
end;
procedure RegionItemsOpen;
var
i, j, k: Integer;
LSkipIfFoundAfterOpenToken: Boolean;
LRegionItem: TBCEditorCodeFoldingRegionItem;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
LTempTextPtr, LTempKeyWordPtr: PChar;
begin
if LOpenTokenSkipFoldRangeList.Count <> 0 then
Exit;
if (not IsValidChar(LTextPtr - 1) or LIsOneCharFolds) and CharInSet(UpCase(LTextPtr^), FHighlighter.FoldOpenKeyChars) then
begin
LCodeFoldingRange := nil;
if LOpenTokenFoldRangeList.Count > 0 then
LCodeFoldingRange := LOpenTokenFoldRangeList.Last;
if Assigned(LCodeFoldingRange) and LCodeFoldingRange.RegionItem.NoSubs then
Exit;
j := LCurrentCodeFoldingRegion.Count - 1;
for i := 0 to j do
begin
LRegionItem := LCurrentCodeFoldingRegion[i];
if (LRegionItem.OpenTokenBeginningOfLine and LBeginningOfLine) or (not LRegionItem.OpenTokenBeginningOfLine) then
begin
{ check if extra token found }
if Assigned(LCodeFoldingRange) then
begin
if LCodeFoldingRange.RegionItem.BreakIfNotFoundBeforeNextRegion <> '' then
if LTextPtr^ = PChar(LCodeFoldingRange.RegionItem.BreakIfNotFoundBeforeNextRegion)^ then { if first character match }
begin
LKeyWordPtr := PChar(LCodeFoldingRange.RegionItem.BreakIfNotFoundBeforeNextRegion);
LBookmarkTextPtr := LTextPtr;
{ check if open keyword found }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and
((UpCase(LTextPtr^) = LKeyWordPtr^) or (LTextPtr^ = BCEDITOR_SPACE_CHAR) or (LTextPtr^ = BCEDITOR_TAB_CHAR)) do
begin
if ((LKeyWordPtr^ = BCEDITOR_SPACE_CHAR) or (LKeyWordPtr^ = BCEDITOR_TAB_CHAR)) or
(LTextPtr^ <> BCEDITOR_SPACE_CHAR) and (LTextPtr^ <> BCEDITOR_TAB_CHAR) then
Inc(LKeyWordPtr);
Inc(LTextPtr);
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then
begin
LCodeFoldingRange.IsExtraTokenFound := True;
Continue;
end
else
LTextPtr := LBookmarkTextPtr; { region not found, return pointer back }
end;
end;
{ First word after newline }
if UpCase(LTextPtr^) = PChar(LRegionItem.OpenToken)^ then { if first character match }
begin
LKeyWordPtr := PChar(LRegionItem.OpenToken);
LBookmarkTextPtr := LTextPtr;
{ check if open keyword found }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (UpCase(LTextPtr^) = LKeyWordPtr^) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
if LRegionItem.OpenTokenCanBeFollowedBy <> '' then
if UpCase(LTextPtr^) = PChar(LRegionItem.OpenTokenCanBeFollowedBy)^ then
begin
LTempTextPtr := LTextPtr;
LTempKeyWordPtr := PChar(LRegionItem.OpenTokenCanBeFollowedBy);
while (LTempTextPtr^ <> BCEDITOR_NONE_CHAR) and (LTempKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (UpCase(LTempTextPtr^) = LTempKeyWordPtr^) do
begin
Inc(LTempTextPtr);
Inc(LTempKeyWordPtr);
end;
if LTempKeyWordPtr^ = BCEDITOR_NONE_CHAR then
LTextPtr := LTempTextPtr;
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then
begin
if ((LRegionItem.OpenTokenLength = 1) or IsWholeWord(LBookmarkTextPtr - 1, LTextPtr)) and
not EscapeChar(LBookmarkTextPtr - 1) then { not interested in partial hits }
begin
{ check if special rule found }
LSkipIfFoundAfterOpenToken := False;
if LRegionItem.SkipIfFoundAfterOpenTokenArrayCount > 0 then
begin
while LTextPtr^ <> BCEDITOR_NONE_CHAR do
begin
for k := 0 to LRegionItem.SkipIfFoundAfterOpenTokenArrayCount - 1 do
begin
LKeyWordPtr := PChar(LRegionItem.SkipIfFoundAfterOpenTokenArray[k]);
LBookmarkTextPtr2 := LTextPtr;
if UpCase(LTextPtr^) = LKeyWordPtr^ then { if first character match }
begin
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (UpCase(LTextPtr^) = LKeyWordPtr^) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then
begin
LSkipIfFoundAfterOpenToken := True;
Break; { for }
end
else
LTextPtr := LBookmarkTextPtr2; { region not found, return pointer back }
end;
end;
if LSkipIfFoundAfterOpenToken then
Break; { while }
Inc(LTextPtr);
end;
end;
if LSkipIfFoundAfterOpenToken then
begin
LTextPtr := LBookmarkTextPtr; { skip found, return pointer back }
Continue;
end;
if Assigned(LCodeFoldingRange) and (LCodeFoldingRange.RegionItem.BreakIfNotFoundBeforeNextRegion <> '') and not LCodeFoldingRange.IsExtraTokenFound then
begin
LOpenTokenFoldRangeList.Remove(LCodeFoldingRange);
Dec(LFoldCount);
end;
if LOpenTokenFoldRangeList.Count > 0 then
LFoldRanges := TBCEditorCodeFoldingRange(LOpenTokenFoldRangeList.Last).SubCodeFoldingRanges
else
LFoldRanges := FAllCodeFoldingRanges;
LCodeFoldingRange := LFoldRanges.Add(FAllCodeFoldingRanges, LLine, GetLineIndentLevel(LLine - 1), LFoldCount,
LRegionItem, LLine);
{ open keyword found }
LOpenTokenFoldRangeList.Add(LCodeFoldingRange);
Inc(LFoldCount);
Dec(LTextPtr); { the end of the while loop will increase }
Break;
end
else
LTextPtr := LBookmarkTextPtr; { region not found, return pointer back }
end
else
LTextPtr := LBookmarkTextPtr; { region not found, return pointer back }
end;
end;
end;
end;
end;
function MultiHighlighterOpen: Boolean;
var
i, j: Integer;
LCodeFoldingRegion: TBCEditorCodeFoldingRegion;
begin
Result := False;
if LOpenTokenSkipFoldRangeList.Count <> 0 then
Exit;
j := Highlighter.CodeFoldingRangeCount - 1;
for i := 1 to j do { First (0) is the default range }
begin
LCodeFoldingRegion := Highlighter.CodeFoldingRegions[i];
if UpCase(LTextPtr^) = PChar(LCodeFoldingRegion.OpenToken)^ then { if first character match }
begin
LKeyWordPtr := PChar(LCodeFoldingRegion.OpenToken);
LBookmarkTextPtr := LTextPtr;
{ check if open keyword found }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (UpCase(LTextPtr^) = LKeyWordPtr^) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
LTextPtr := LBookmarkTextPtr; { return pointer always back }
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then
begin
LCodeFoldingRangeIndexList.Add(Pointer(i));
LCurrentCodeFoldingRegion := Highlighter.CodeFoldingRegions[i];
Result := True;
Exit;
end
end;
end;
end;
procedure MultiHighlighterClose;
var
i, j: Integer;
LCodeFoldingRegion: TBCEditorCodeFoldingRegion;
begin
if LOpenTokenSkipFoldRangeList.Count <> 0 then
Exit;
j := Highlighter.CodeFoldingRangeCount - 1;
for i := 1 to j do { First (0) is the default range }
begin
LCodeFoldingRegion := Highlighter.CodeFoldingRegions[i];
if UpCase(LTextPtr^) = PChar(LCodeFoldingRegion.CloseToken)^ then { if first character match }
begin
LKeyWordPtr := PChar(LCodeFoldingRegion.CloseToken);
LBookmarkTextPtr := LTextPtr;
{ check if close keyword found }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (UpCase(LTextPtr^) = LKeyWordPtr^) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
LTextPtr := LBookmarkTextPtr; { return pointer always back }
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then
begin
if LCodeFoldingRangeIndexList.Count > 0 then
LCodeFoldingRangeIndexList.Delete(LCodeFoldingRangeIndexList.Count - 1);
if LCodeFoldingRangeIndexList.Count > 0 then
LCurrentCodeFoldingRegion := Highlighter.CodeFoldingRegions[Integer(LCodeFoldingRangeIndexList.Last)]
else
LCurrentCodeFoldingRegion := Highlighter.CodeFoldingRegions[DEFAULT_CODE_FOLDING_RANGE_INDEX];
Exit;
end
end;
end;
end;
var
i, j, LPreviousLine: Integer;
LRegion: TBCEditorCodeFoldingRegion;
LRegionItem: TBCEditorCodeFoldingRegionItem;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
if not Assigned(FLineNumbersCache) then
Exit;
LFoldCount := 0;
LOpenTokenSkipFoldRangeList := TList.Create;
LOpenTokenFoldRangeList := TList.Create;
LCodeFoldingRangeIndexList := TList.Create;
try
LIsOneCharFolds := False;
{ Check, if one char folds }
for i := 0 to Highlighter.CodeFoldingRangeCount - 1 do
begin
LRegion := Highlighter.CodeFoldingRegions[i];
for j := 0 to LRegion.Count - 1 do
begin
LRegionItem := LRegion.Items[j];
if (LRegionItem.OpenTokenLength = 1) and (LRegionItem.CloseTokenLength = 1) then
begin
LIsOneCharFolds := True;
Break;
end;
end;
end;
{ Go through the text line by line, character by character }
LPreviousLine := -1;
LCodeFoldingRangeIndexList.Add(Pointer(DEFAULT_CODE_FOLDING_RANGE_INDEX));
if Highlighter.CodeFoldingRangeCount > 0 then
LCurrentCodeFoldingRegion := Highlighter.CodeFoldingRegions[DEFAULT_CODE_FOLDING_RANGE_INDEX];
for i := 1 to Length(FLineNumbersCache) - 1 do
begin
LLine := FLineNumbersCache[i];
LCodeFoldingRange := nil;
if LLine < Length(FCodeFoldingRangeFromLine) then
LCodeFoldingRange := FCodeFoldingRangeFromLine[LLine];
if Assigned(LCodeFoldingRange) and LCodeFoldingRange.Collapsed then
begin
LPreviousLine := LLine;
Continue;
end;
if LPreviousLine <> LLine then
begin
LTextPtr := PChar(FLines[LLine - 1]); { 0-based }
LBeginningOfLine := True;
while LTextPtr^ <> BCEDITOR_NONE_CHAR do
begin
SkipEmptySpace;
if Highlighter.MultiHighlighter then
if not MultiHighlighterOpen then
MultiHighlighterClose;
if SkipRegionsClose then
Continue; { while TextPtr^ <> BCEDITOR_NONE_CHAR do }
if SkipRegionsOpen then
Break; { line comment breaks }
SkipEmptySpace;
if LOpenTokenSkipFoldRangeList.Count = 0 then
begin
if RegionItemsClose then
Continue; { while TextPtr^ <> BCEDITOR_NONE_CHAR do }
RegionItemsOpen;
end;
if LTextPtr^ <> BCEDITOR_NONE_CHAR then
Inc(LTextPtr);
LBeginningOfLine := False; { not in the beginning of the line anymore }
end;
end;
LPreviousLine := LLine;
end;
{ Check the last not empty line }
LLine := FLines.Count - 1;
while (LLine >= 0) and (Trim(FLines[LLine]) = '') do
Dec(LLine);
if LLine >= 0 then
begin
LTextPtr := PChar(FLines[LLine]);
while LOpenTokenFoldRangeList.Count > 0 do
begin
LLastFoldRange := LOpenTokenFoldRangeList.Last;
if Assigned(LLastFoldRange) then
begin
Inc(LLine);
LLine := Min(LLine, FLines.Count);
if LLastFoldRange.RegionItem.OpenIsClose then
LLastFoldRange.ToLine := LLine;
LOpenTokenFoldRangeList.Remove(LLastFoldRange);
Dec(LFoldCount);
RegionItemsClose;
end;
end;
end;
finally
LCodeFoldingRangeIndexList.Free;
LOpenTokenSkipFoldRangeList.Free;
LOpenTokenFoldRangeList.Free;
end;
end;
procedure TBCBaseEditor.ScrollChanged(Sender: TObject);
begin
UpdateScrollBars;
Invalidate;
end;
procedure TBCBaseEditor.ScrollTimerHandler(Sender: TObject);
var
X, Y: Integer;
LCursorPoint: TPoint;
LDisplayPosition: TBCEditorDisplayPosition;
LTextPosition: TBCEditorTextPosition;
begin
IncPaintLock;
try
Winapi.Windows.GetCursorPos(LCursorPoint);
LCursorPoint := ScreenToClient(LCursorPoint);
LDisplayPosition := PixelsToRowColumn(LCursorPoint.X, LCursorPoint.Y);
LDisplayPosition.Row := MinMax(LDisplayPosition.Row, 1, FLineNumbersCount);
if FScrollDeltaX <> 0 then
begin
LeftChar := LeftChar + FScrollDeltaX;
X := LeftChar;
LDisplayPosition.Column := X;
end;
if FScrollDeltaY <> 0 then
begin
if GetKeyState(VK_SHIFT) < 0 then
TopLine := TopLine + FScrollDeltaY * VisibleLines
else
TopLine := TopLine + FScrollDeltaY;
Y := TopLine;
if FScrollDeltaY > 0 then
Inc(Y, VisibleLines - 1);
LDisplayPosition.Row := MinMax(Y, 1, FLineNumbersCount);
end;
if not FMouseMoveScrolling then
begin
LTextPosition := DisplayToTextPosition(LDisplayPosition);
if (DisplayCaretX <> LTextPosition.Char) or (GetTextCaretY <> LTextPosition.Line) then
begin
TextCaretPosition := LTextPosition;
if MouseCapture then
SetSelectionEndPosition(TextCaretPosition);
end;
end;
finally
DecPaintLock;
Invalidate;
end;
ComputeScroll(LCursorPoint.X, LCursorPoint.Y);
end;
procedure TBCBaseEditor.SearchChanged(AEvent: TBCEditorSearchChanges);
begin
if AEvent = scEngineUpdate then
CaretZero;
case AEvent of
scEngineUpdate:
AssignSearchEngine;
scSearch:
begin
FindAll; { for search map and search count }
if Assigned(FSearchEngine) and FSearch.Enabled then
begin
if soBackwards in FSearch.Options then
FindPrevious
else
FindNext(True);
end;
end;
end;
Invalidate;
end;
procedure TBCBaseEditor.SelectionChanged(Sender: TObject);
begin
InvalidateSelection;
end;
procedure TBCBaseEditor.SetActiveLine(const AValue: TBCEditorActiveLine);
begin
FActiveLine.Assign(AValue);
end;
procedure TBCBaseEditor.SetBackgroundColor(const AValue: TColor);
begin
if FBackgroundColor <> AValue then
begin
FBackgroundColor := AValue;
Color := AValue;
Invalidate;
end;
end;
procedure TBCBaseEditor.SetBorderStyle(AValue: TBorderStyle);
begin
if FBorderStyle <> AValue then
begin
FBorderStyle := AValue;
RecreateWnd;
end;
end;
procedure TBCBaseEditor.SetDisplayCaretX(AValue: Integer);
var
LDisplayPosition: TBCEditorDisplayPosition;
begin
LDisplayPosition.Column := AValue;
LDisplayPosition.Row := DisplayCaretY;
SetDisplayCaretPosition(LDisplayPosition);
end;
procedure TBCBaseEditor.SetDisplayCaretY(AValue: Integer);
var
LDisplayPosition: TBCEditorDisplayPosition;
begin
LDisplayPosition.Column := DisplayCaretX;
LDisplayPosition.Row := AValue;
SetDisplayCaretPosition(LDisplayPosition);
end;
procedure TBCBaseEditor.SetClipboardText(const AText: string);
var
LGlobalMem: HGLOBAL;
LPGlobalLock: PByte;
LLength: Integer;
begin
if AText = '' then
Exit;
LLength := Length(AText);
if not OpenClipboard then
Exit;
try
Clipboard.Clear;
{ set ANSI text only on Win9X, WinNT automatically creates ANSI from Unicode }
if Win32Platform <> VER_PLATFORM_WIN32_NT then
begin
LGlobalMem := GlobalAlloc(GMEM_MOVEABLE or GMEM_DDESHARE, LLength + 1);
if LGlobalMem <> 0 then
begin
LPGlobalLock := GlobalLock(LGlobalMem);
try
if Assigned(LPGlobalLock) then
begin
Move(PAnsiChar(AnsiString(AText))^, LPGlobalLock^, LLength + 1);
Clipboard.SetAsHandle(CF_TEXT, LGlobalMem);
end;
finally
GlobalUnlock(LGlobalMem);
end;
end;
end;
{ Set unicode text, this also works on Win9X, even if the clipboard-viewer
can't show it, Word 2000+ can paste it including the unicode only characters }
LGlobalMem := GlobalAlloc(GMEM_MOVEABLE or GMEM_DDESHARE, (LLength + 1) * SizeOf(Char));
if LGlobalMem <> 0 then
begin
LPGlobalLock := GlobalLock(LGlobalMem);
try
if Assigned(LPGlobalLock) then
begin
Move(PChar(AText)^, LPGlobalLock^, (LLength + 1) * SizeOf(Char));
Clipboard.SetAsHandle(CF_UNICODETEXT, LGlobalMem);
end;
finally
GlobalUnlock(LGlobalMem);
end;
end;
finally
Clipboard.Close;
end;
end;
procedure TBCBaseEditor.SetCodeFolding(AValue: TBCEditorCodeFolding);
begin
FCodeFolding.Assign(AValue);
if AValue.Visible then
InitCodeFolding;
end;
procedure TBCBaseEditor.SetDefaultKeyCommands;
begin
FKeyCommands.ResetDefaults;
end;
procedure TBCBaseEditor.SetForegroundColor(const AValue: TColor);
begin
if FForegroundColor <> AValue then
begin
FForegroundColor := AValue;
Font.Color := AValue;
Invalidate;
end;
end;
procedure TBCBaseEditor.SetInsertMode(const AValue: Boolean);
begin
if FInsertMode <> AValue then
begin
FInsertMode := AValue;
if not (csDesigning in ComponentState) then
ResetCaret;
end;
end;
procedure TBCBaseEditor.SetTextCaretX(AValue: Integer);
var
LTextPosition: TBCEditorTextPosition;
begin
LTextPosition.Char := AValue;
LTextPosition.Line := TextCaretPosition.Line;
TextCaretPosition := LTextPosition;
end;
procedure TBCBaseEditor.SetTextCaretY(AValue: Integer);
var
LTextPosition: TBCEditorTextPosition;
begin
LTextPosition.Char := TextCaretPosition.Char;
LTextPosition.Line := AValue;
TextCaretPosition := LTextPosition;
end;
procedure TBCBaseEditor.SetKeyCommands(const AValue: TBCEditorKeyCommands);
begin
if not Assigned(AValue) then
FKeyCommands.Clear
else
FKeyCommands.Assign(AValue);
end;
procedure TBCBaseEditor.SetLeftChar(AValue: Integer);
var
LMaxLineWidth: Integer;
// LWrapAtColumn: Integer;
begin
// LWrapAtColumn := GetVisibleChars;
if FWordWrap.Enabled {and (LWrapAtColumn <= FVisibleChars)} then
AValue := 1;
if soPastEndOfLine in FScroll.Options then
begin
if soAutoSizeMaxWidth in FScroll.Options then
LMaxLineWidth := MaxInt - VisibleChars
else
LMaxLineWidth := FScroll.MaxWidth - VisibleChars + 1
end
else
begin
if FWordWrap.Enabled then
LMaxLineWidth := VisibleChars
else
LMaxLineWidth := FLines.GetLengthOfLongestLine;
if LMaxLineWidth > FVisibleChars then
LMaxLineWidth := LMaxLineWidth - FVisibleChars + 1
else
LMaxLineWidth := 1;
end;
AValue := MinMax(AValue, 1, LMaxLineWidth);
if FLeftChar <> AValue then
begin
FLeftChar := AValue;
FTextOffset := GetTextOffset;
if ((soAutoSizeMaxWidth in FScroll.Options) or (soPastEndOfLine in FScroll.Options)) and
(FScroll.MaxWidth < LeftChar + FVisibleChars) then
FScroll.MaxWidth := LeftChar + FVisibleChars - 1
else
UpdateScrollBars;
InvalidateLines(DisplayCaretY, DisplayCaretY);
end;
end;
procedure TBCBaseEditor.SetLeftMargin(const AValue: TBCEditorLeftMargin);
begin
FLeftMargin.Assign(AValue);
end;
procedure TBCBaseEditor.SetLeftMarginWidth(AValue: Integer);
begin
AValue := Max(AValue, 0);
if FLeftMargin.Width <> AValue then
begin
FLeftMargin.Width := AValue;
FTextOffset := GetTextOffset;
if HandleAllocated then
begin
FVisibleChars := Max(ClientWidth - FLeftMargin.GetWidth - FCodeFolding.GetWidth - 2 - FMinimap.GetWidth -
FSearch.Map.GetWidth, 0) div FCharWidth;
if FWordWrap.Enabled then
FResetLineNumbersCache := True;
UpdateScrollBars;
Invalidate;
end;
end;
end;
procedure TBCBaseEditor.SetLines(AValue: TBCEditorLines);
begin
ClearBookmarks;
ClearCodeFolding;
FLines.Assign(AValue);
CreateLineNumbersCache;
SizeOrFontChanged(True);
InitCodeFolding;
end;
procedure TBCBaseEditor.SetModified(AValue: Boolean);
var
i: Integer;
LPLineAttribute: PBCEditorLineAttribute;
begin
if FModified <> AValue then
begin
FModified := AValue;
if (uoGroupUndo in FUndo.Options) and (not AValue) and UndoList.CanUndo then
FUndoList.AddGroupBreak;
if not FModified then
begin
for i := 0 to FLines.Count - 1 do
begin
LPLineAttribute := FLines.Attributes[i];
if LPLineAttribute.LineState = lsModified then
LPLineAttribute.LineState := lsNormal;
end;
InvalidateLeftMargin;
end;
end;
end;
procedure TBCBaseEditor.SetMouseMoveScrollCursors(AIndex: Integer; AValue: HCURSOR);
begin
if (AIndex >= Low(FMouseMoveScrollCursors)) and (AIndex <= High(FMouseMoveScrollCursors)) then
FMouseMoveScrollCursors[AIndex] := AValue;
end;
procedure TBCBaseEditor.SetOptions(AValue: TBCEditorOptions);
begin
if FOptions <> AValue then
begin
FOptions := AValue;
if (eoDropFiles in FOptions) <> (eoDropFiles in AValue) and not (csDesigning in ComponentState) and HandleAllocated then
DragAcceptFiles(Handle, eoDropFiles in FOptions);
Invalidate;
end;
end;
procedure TBCBaseEditor.SetTextCaretPosition(AValue: TBCEditorTextPosition);
begin
SetDisplayCaretPosition(TextToDisplayPosition(AValue));
end;
procedure TBCBaseEditor.SetRightMargin(const AValue: TBCEditorRightMargin);
begin
FRightMargin.Assign(AValue);
end;
procedure TBCBaseEditor.SetScroll(const AValue: TBCEditorScroll);
begin
FScroll.Assign(AValue);
end;
procedure TBCBaseEditor.SetSearch(const AValue: TBCEditorSearch);
begin
FSearch.Assign(AValue);
end;
procedure TBCBaseEditor.SetSelectedText(const AValue: string);
var
LTextCaretPosition, LBlockStartPosition, LBlockEndPosition: TBCEditorTextPosition;
begin
ClearCodeFolding;
try
if sfDragging in FStateFlags then
LTextCaretPosition := FDragBeginTextCaretPosition
else
LTextCaretPosition := TextCaretPosition;
LBlockStartPosition := SelectionBeginPosition;
LBlockEndPosition := SelectionEndPosition;
if SelectionAvailable then
FUndoList.AddChange(crDelete, LTextCaretPosition, LBlockStartPosition, LBlockEndPosition, GetSelectedText,
FSelection.ActiveMode)
else
FSelection.ActiveMode := FSelection.Mode;
DoSelectedText(AValue);
if (AValue <> '') and (FSelection.ActiveMode <> smColumn) then
FUndoList.AddChange(crInsert, LTextCaretPosition, LBlockStartPosition, SelectionEndPosition, '', FSelection.ActiveMode);
finally
InitCodeFolding;
end;
end;
procedure TBCBaseEditor.SetSelectedWord;
begin
SetWordBlock(TextCaretPosition);
end;
procedure TBCBaseEditor.SetSelection(const AValue: TBCEditorSelection);
begin
FSelection.Assign(AValue);
end;
procedure TBCBaseEditor.SetSelectionBeginPosition(AValue: TBCEditorTextPosition);
var
LFirstLine, LLastLine: Integer;
begin
FSelection.ActiveMode := Selection.Mode;
if (soPastEndOfLine in FScroll.Options) and not FWordWrap.Enabled then
AValue.Char := MinMax(AValue.Char, 1, FScroll.MaxWidth + 1)
else
AValue.Char := Max(AValue.Char, 1);
AValue.Line := MinMax(AValue.Line, 0, FLines.Count - 1);
if SelectionAvailable then
begin
if FSelectionBeginPosition.Line < FSelectionEndPosition.Line then
begin
LFirstLine := Min(AValue.Line, FSelectionBeginPosition.Line);
LLastLine := Max(AValue.Line, FSelectionEndPosition.Line);
end
else
begin
LFirstLine := Min(AValue.Line, FSelectionEndPosition.Line);
LLastLine := Max(AValue.Line, FSelectionBeginPosition.Line);
end;
FSelectionBeginPosition := AValue;
FSelectionEndPosition := AValue;
InvalidateLines(LFirstLine, LLastLine);
if FMinimap.Visible then
InvalidateMinimap;
end
else
begin
FSelectionBeginPosition := AValue;
FSelectionEndPosition := AValue;
end;
end;
procedure TBCBaseEditor.SetSelectionEndPosition(AValue: TBCEditorTextPosition);
var
LCurrentLine: Integer;
begin
FSelection.ActiveMode := Selection.Mode;
if FSelection.Visible then
begin
if (soPastEndOfLine in FScroll.Options) and not FWordWrap.Enabled then
AValue.Char := MinMax(AValue.Char, 1, FScroll.MaxWidth + 1)
else
AValue.Char := Max(AValue.Char, 1);
AValue.Line := MinMax(AValue.Line, 0, FLines.Count - 1);
if (AValue.Char <> FSelectionEndPosition.Char) or (AValue.Line <> FSelectionEndPosition.Line) then
begin
if (FSelection.ActiveMode = smColumn) and (AValue.Char <> FSelectionEndPosition.Char) then
begin
InvalidateLines(Min(FSelectionBeginPosition.Line, Min(FSelectionEndPosition.Line, AValue.Line)),
Max(FSelectionBeginPosition.Line, Max(FSelectionEndPosition.Line, AValue.Line)));
FSelectionEndPosition := AValue;
end
else
begin
LCurrentLine := FSelectionEndPosition.Line;
FSelectionEndPosition := AValue;
if (FSelection.ActiveMode <> smColumn) or (FSelectionBeginPosition.Char <> FSelectionEndPosition.Char) then
InvalidateLines(LCurrentLine, FSelectionEndPosition.Line);
end;
end;
if Assigned(FOnSelectionChanged) then
FOnSelectionChanged(Self);
end;
end;
procedure TBCBaseEditor.SetSpecialChars(const AValue: TBCEditorSpecialChars);
begin
FSpecialChars.Assign(AValue);
end;
procedure TBCBaseEditor.SetSyncEdit(const AValue: TBCEditorSyncEdit);
begin
FSyncEdit.Assign(AValue);
end;
procedure TBCBaseEditor.SetTabs(const AValue: TBCEditorTabs);
begin
FTabs.Assign(AValue);
end;
procedure TBCBaseEditor.SetText(const AValue: string);
begin
IncPaintLock;
BeginUndoBlock;
SelectAll;
SelectedText := AValue;
EndUndoBlock;
DecPaintLock;
end;
procedure TBCBaseEditor.SetTextBetween(ATextBeginPosition: TBCEditorTextPosition; ATextEndPosition: TBCEditorTextPosition; const AValue: string);
var
LSelectionMode: TBCEditorSelectionMode;
begin
LSelectionMode := FSelection.Mode;
FSelection.Mode := smNormal;
FUndoList.BeginBlock;
FUndoList.AddChange(crCaret, TextCaretPosition, FSelectionBeginPosition, FSelectionBeginPosition, '',
FSelection.ActiveMode);
FSelectionBeginPosition := ATextBeginPosition;
FSelectionEndPosition := ATextEndPosition;
SelectedText := AValue;
FUndoList.EndBlock;
FSelection.Mode := LSelectionMode;
end;
procedure TBCBaseEditor.SetTopLine(AValue: Integer);
var
LDisplayLineCount: Integer;
begin
LDisplayLineCount := FLineNumbersCount;
if LDisplayLineCount = 0 then
LDisplayLineCount := 1;
if (soPastEndOfFileMarker in FScroll.Options) and
(not (sfInSelection in FStateFlags) or (sfInSelection in FStateFlags) and (AValue = FTopLine)) then
AValue := Min(AValue, LDisplayLineCount)
else
AValue := Min(AValue, LDisplayLineCount - FVisibleLines + 1);
AValue := Max(AValue, 1);
if TopLine <> AValue then
begin
FTopLine := AValue;
if FMinimap.Visible and not FMinimap.Dragging then
FMinimap.TopLine := Max(FTopLine - Abs(Trunc((FMinimap.VisibleLines - FVisibleLines) * (FTopLine / Max(LDisplayLineCount - FVisibleLines, 1)))), 1);
UpdateScrollBars;
end;
end;
procedure TBCBaseEditor.SetUndo(const AValue: TBCEditorUndo);
begin
FUndo.Assign(AValue);
end;
procedure TBCBaseEditor.SetWordBlock(ATextPosition: TBCEditorTextPosition);
var
LBlockBeginPosition: TBCEditorTextPosition;
LBlockEndPosition: TBCEditorTextPosition;
LTempString: string;
procedure CharScan;
var
i: Integer;
begin
LBlockEndPosition.Char := Length(LTempString);
for i := ATextPosition.Char to Length(LTempString) do
if IsWordBreakChar(LTempString[i]) then
begin
LBlockEndPosition.Char := i;
Break;
end;
LBlockBeginPosition.Char := 1;
for i := ATextPosition.Char - 1 downto 1 do
if IsWordBreakChar(LTempString[i]) then
begin
LBlockBeginPosition.Char := i + 1;
Break;
end;
end;
begin
if (soPastEndOfLine in FScroll.Options) and not FWordWrap.Enabled then
ATextPosition.Char := MinMax(ATextPosition.Char, 1, FScroll.MaxWidth + 1)
else
ATextPosition.Char := Max(ATextPosition.Char, 1);
ATextPosition.Line := MinMax(ATextPosition.Line, 0, FLines.Count - 1);
LTempString := FLines[ATextPosition.Line] + BCEDITOR_NONE_CHAR;
if ATextPosition.Char > Length(LTempString) then
begin
TextCaretPosition := GetTextPosition(Length(LTempString), ATextPosition.Line);
Exit;
end;
CharScan;
LBlockBeginPosition.Line := ATextPosition.Line;
LBlockEndPosition.Line := ATextPosition.Line;
SetCaretAndSelection(LBlockEndPosition, LBlockBeginPosition, LBlockEndPosition);
InvalidateLine(ATextPosition.Line);
end;
procedure TBCBaseEditor.SetWordWrap(const AValue: TBCEditorWordWrap);
begin
FWordWrap.Assign(AValue);
end;
procedure TBCBaseEditor.SizeOrFontChanged(const AFontChanged: Boolean);
var
LOldTextCaretPosition: TBCEditorTextPosition;
begin
if Visible and HandleAllocated and (FCharWidth <> 0) then
begin
FVisibleChars := Max(ClientWidth - FLeftMargin.GetWidth - FCodeFolding.GetWidth - 2 - FMinimap.GetWidth -
FSearch.Map.GetWidth, 0) div FCharWidth;
FVisibleLines := ClientHeight div FLineHeight;
if FMinimap.Visible and (FLineNumbersCount > 0) then
begin
FTextDrawer.SetBaseFont(FMinimap.Font);
FMinimap.CharHeight := FTextDrawer.CharHeight - 1;
FMinimap.VisibleLines := ClientHeight div FMinimap.CharHeight;
FMinimap.TopLine := Max(FTopLine - Abs(Trunc((FMinimap.VisibleLines - FVisibleLines) * (FTopLine / Max(FLineNumbersCount - FVisibleLines, 1)))), 1);
end;
if FWordWrap.Enabled then
begin
LOldTextCaretPosition := TextCaretPosition;
CreateLineNumbersCache(True);
TextCaretPosition := LOldTextCaretPosition;
Invalidate;
end;
if AFontChanged then
begin
if LeftMargin.LineNumbers.Visible then
LeftMarginChanged(Self)
else
UpdateScrollBars;
ResetCaret;
Exclude(FStateFlags, sfCaretChanged);
Invalidate;
end
else
UpdateScrollBars;
Exclude(FStateFlags, sfScrollbarChanged);
FBufferBmp.Width := ClientRect.Width;
FBufferBmp.Height := ClientRect.Height;
end;
end;
procedure TBCBaseEditor.SpecialCharsChanged(Sender: TObject);
begin
Invalidate;
end;
procedure TBCBaseEditor.SyncEditChanged(Sender: TObject);
var
i: Integer;
LTextPosition: TBCEditorTextPosition;
LIsWordSelected: Boolean;
LSelectionAvailable: Boolean;
begin
FSyncEdit.ClearSyncItems;
if FSyncEdit.Active then
begin
FWordWrap.Enabled := False;
LSelectionAvailable := SelectionAvailable;
LIsWordSelected := IsWordSelected;
if LSelectionAvailable and LIsWordSelected then
begin
FUndoList.BeginBlock;
FSyncEdit.InEditor := True;
FSyncEdit.EditBeginPosition := SelectionBeginPosition;
FSyncEdit.EditEndPosition := SelectionEndPosition;
FSyncEdit.EditWidth := FSyncEdit.EditEndPosition.Char - FSyncEdit.EditBeginPosition.Char;
FindWords(SelectedText, FSyncEdit.SyncItems, seCaseSensitive in FSyncEdit.Options, True);
i := 0;
while i < FSyncEdit.SyncItems.Count do
begin
LTextPosition := PBCEditorTextPosition(FSyncEdit.SyncItems.Items[i])^;
if (LTextPosition.Line = FSyncEdit.EditBeginPosition.Line) and (LTextPosition.Char = FSyncEdit.EditBeginPosition.Char) or
FSyncEdit.BlockSelected and not FSyncEdit.IsTextPositionInBlock(LTextPosition) then
begin
Dispose(PBCEditorTextPosition(FSyncEdit.SyncItems.Items[i]));
FSyncEdit.SyncItems.Delete(i);
end
else
Inc(i);
end;
end
else
if LSelectionAvailable and not LIsWordSelected then
begin
FSyncEdit.BlockSelected := True;
FSyncEdit.BlockBeginPosition := SelectionBeginPosition;
FSyncEdit.BlockEndPosition := SelectionEndPosition;
FSyncEdit.Abort;
FSelectionBeginPosition := TextCaretPosition;
FSelectionEndPosition := FSelectionBeginPosition;
end
else
FSyncEdit.Abort;
end
else
begin
FSyncEdit.BlockSelected := False;
if FSyncEdit.InEditor then
begin
FSyncEdit.InEditor := False;
FUndoList.EndBlock;
end;
end;
Invalidate;
end;
procedure TBCBaseEditor.SwapInt(var ALeft, ARight: Integer);
var
LTemp: Integer;
begin
LTemp := ARight;
ARight := ALeft;
ALeft := LTemp;
end;
procedure TBCBaseEditor.TabsChanged(Sender: TObject);
begin
FLines.TabWidth := FTabs.Width;
FLines.Columns := toColumns in FTabs.Options;
Invalidate;
if FWordWrap.Enabled then
begin
if FWordWrap.Enabled then
FResetLineNumbersCache := True;
InvalidateLeftMargin;
end;
end;
procedure TBCBaseEditor.UndoRedoAdded(Sender: TObject);
var
LUndoItem: TBCEditorUndoItem;
begin
LUndoItem := nil;
if Sender = FUndoList then
LUndoItem := FUndoList.PeekItem;
UpdateModifiedStatus;
if not FUndoList.InsideRedo and Assigned(LUndoItem) and not (LUndoItem.ChangeReason in [crCaret, crGroupBreak]) then
FRedoList.Clear;
end;
procedure TBCBaseEditor.UpdateFoldRanges(ACurrentLine, ALineCount: Integer);
var
i, LPosition: Integer;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
for i := 0 to FAllCodeFoldingRanges.AllCount - 1 do
begin
LCodeFoldingRange := FAllCodeFoldingRanges[i];
if not LCodeFoldingRange.ParentCollapsed then
begin
if LCodeFoldingRange.FromLine > ACurrentLine then
begin
LCodeFoldingRange.MoveBy(ALineCount);
if LCodeFoldingRange.Collapsed then
UpdateFoldRanges(LCodeFoldingRange.SubCodeFoldingRanges, ALineCount);
Continue;
end
else
if LCodeFoldingRange.FromLine = ACurrentLine then
begin
LPosition := Pos(LCodeFoldingRange.RegionItem.OpenToken, AnsiUpperCase(Lines[LCodeFoldingRange.FromLine]));
if LPosition > 0 then
begin
LCodeFoldingRange.MoveBy(ALineCount);
Continue;
end;
end;
if not LCodeFoldingRange.Collapsed then
if LCodeFoldingRange.ToLine >= ACurrentLine then
LCodeFoldingRange.Widen(ALineCount)
end;
end;
end;
procedure TBCBaseEditor.UpdateFoldRanges(AFoldRanges: TBCEditorCodeFoldingRanges; ALineCount: Integer);
var
i: Integer;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
if Assigned(AFoldRanges) then
for i := 0 to AFoldRanges.Count - 1 do
begin
LCodeFoldingRange := AFoldRanges[i];
UpdateFoldRanges(LCodeFoldingRange.SubCodeFoldingRanges, ALineCount);
LCodeFoldingRange.MoveBy(ALineCount);
end;
end;
procedure TBCBaseEditor.UpdateModifiedStatus;
begin
Modified := UndoList.ChangeCount > 0;
end;
procedure TBCBaseEditor.UpdateScrollBars;
var
LMaxScroll: Integer;
LScrollInfo: TScrollInfo;
LRightChar: Integer;
procedure UpdateVerticalScrollBar;
begin
if FScroll.Bars in [ssBoth, ssVertical] then
begin
LMaxScroll := FLineNumbersCount;
if soPastEndOfFileMarker in FScroll.Options then
Inc(LMaxScroll, VisibleLines - 1);
LScrollInfo.nMin := 1;
if LMaxScroll <= BCEDITOR_MAX_SCROLL_RANGE then
begin
LScrollInfo.nMax := Max(1, LMaxScroll);
LScrollInfo.nPage := VisibleLines;
LScrollInfo.nPos := TopLine;
end
else
begin
LScrollInfo.nMax := BCEDITOR_MAX_SCROLL_RANGE;
LScrollInfo.nPage := MulDiv(BCEDITOR_MAX_SCROLL_RANGE, VisibleLines, LMaxScroll);
LScrollInfo.nPos := MulDiv(BCEDITOR_MAX_SCROLL_RANGE, TopLine, LMaxScroll);
end;
ShowScrollBar(Handle, SB_VERT, (LScrollInfo.nMin = 0) or (LScrollInfo.nMax > VisibleLines));
SetScrollInfo(Handle, SB_VERT, LScrollInfo, True);
if LMaxScroll <= VisibleLines then
begin
if (TopLine <= 1) and (LMaxScroll <= VisibleLines) then
EnableScrollBar(Handle, SB_VERT, ESB_DISABLE_BOTH)
else
begin
EnableScrollBar(Handle, SB_VERT, ESB_ENABLE_BOTH);
if TopLine <= 1 then
EnableScrollBar(Handle, SB_VERT, ESB_DISABLE_UP)
else
if FLineNumbersCount - TopLine - VisibleLines + 1 = 0 then
EnableScrollBar(Handle, SB_VERT, ESB_DISABLE_DOWN);
end;
end
else
EnableScrollBar(Handle, SB_VERT, ESB_ENABLE_BOTH);
end
else
ShowScrollBar(Handle, SB_VERT, False);
end;
procedure UpdateHorizontalScrollBar;
begin
if (FScroll.Bars in [ssBoth, ssHorizontal]) and
not FWordWrap.Enabled then
begin
if soPastEndOfLine in FScroll.Options then
LMaxScroll := FScroll.MaxWidth
else
if FWordWrap.Enabled then
LMaxScroll := VisibleChars
else
LMaxScroll := Max(FLines.GetLengthOfLongestLine, 1);
if LMaxScroll <= BCEDITOR_MAX_SCROLL_RANGE then
begin
LScrollInfo.nMin := 1;
LScrollInfo.nMax := LMaxScroll;
LScrollInfo.nPage := FVisibleChars;
LScrollInfo.nPos := LeftChar;
end
else
begin
LScrollInfo.nMin := 0;
LScrollInfo.nMax := BCEDITOR_MAX_SCROLL_RANGE;
LScrollInfo.nPage := MulDiv(BCEDITOR_MAX_SCROLL_RANGE, FVisibleChars, LMaxScroll);
LScrollInfo.nPos := MulDiv(BCEDITOR_MAX_SCROLL_RANGE, LeftChar, LMaxScroll);
end;
ShowScrollBar(Handle, SB_HORZ, (LScrollInfo.nMin = 0) or (LScrollInfo.nMax > FVisibleChars));
SetScrollInfo(Handle, SB_HORZ, LScrollInfo, True);
if LMaxScroll <= FVisibleChars then
begin
LRightChar := LeftChar + FVisibleChars - 1;
if (LeftChar <= 1) and (LRightChar >= LMaxScroll) then
EnableScrollBar(Handle, SB_HORZ, ESB_DISABLE_BOTH)
else
begin
EnableScrollBar(Handle, SB_HORZ, ESB_ENABLE_BOTH);
if (LeftChar <= 1) then
EnableScrollBar(Handle, SB_HORZ, ESB_DISABLE_LEFT)
else
if LRightChar >= LMaxScroll then
EnableScrollBar(Handle, SB_HORZ, ESB_DISABLE_RIGHT)
end;
end
else
EnableScrollBar(Handle, SB_HORZ, ESB_ENABLE_BOTH);
end
else
ShowScrollBar(Handle, SB_HORZ, False);
end;
begin
if not HandleAllocated or (PaintLock <> 0) then
Include(FStateFlags, sfScrollbarChanged)
else
begin
Exclude(FStateFlags, sfScrollbarChanged);
if FScroll.Bars <> ssNone then
begin
LScrollInfo.cbSize := SizeOf(ScrollInfo);
LScrollInfo.fMask := SIF_ALL;
LScrollInfo.fMask := LScrollInfo.fMask or SIF_DISABLENOSCROLL;
if Visible then
SendMessage(Handle, WM_SETREDRAW, 0, 0);
UpdateHorizontalScrollBar;
UpdateVerticalScrollBar;
if FScroll.Bars <> ssNone then
begin
if Visible then
SendMessage(Handle, WM_SETREDRAW, -1, 0);
if FPaintLock = 0 then
Invalidate;
end;
end
else
ShowScrollBar(Handle, SB_BOTH, False);
{$IFDEF USE_VCL_STYLES}
Perform(CM_UPDATE_VCLSTYLE_SCROLLBARS, 0, 0);
{$ENDIF}
end;
end;
procedure TBCBaseEditor.UpdateWordWrap(const AValue: Boolean);
var
LOldTopLine: Integer;
LShowCaret: Boolean;
begin
if FWordWrap.Enabled <> AValue then
begin
Invalidate;
LShowCaret := CaretInView;
LOldTopLine := TopLine;
if AValue then
begin
LeftChar := 1;
if FWordWrap.Style = wwsRightMargin then
FRightMargin.Visible := True;
end;
TopLine := LOldTopLine;
UpdateScrollBars;
if soPastEndOfLine in FScroll.Options then
begin
SetSelectionBeginPosition(SelectionBeginPosition);
SetSelectionEndPosition(SelectionEndPosition);
end;
if LShowCaret then
EnsureCursorPositionVisible;
end;
end;
procedure TBCBaseEditor.WMCaptureChanged(var AMessage: TMessage);
begin
FScrollTimer.Enabled := False;
inherited;
end;
procedure TBCBaseEditor.WMChar(var AMessage: TWMChar);
begin
DoKeyPressW(AMessage);
end;
procedure TBCBaseEditor.WMClear(var AMessage: TMessage);
begin
if not ReadOnly then
SelectedText := '';
end;
procedure TBCBaseEditor.WMCopy(var AMessage: TMessage);
begin
CopyToClipboard;
AMessage.Result := Ord(True);
end;
procedure TBCBaseEditor.WMCut(var AMessage: TMessage);
begin
if not ReadOnly then
CutToClipboard;
AMessage.Result := Ord(True);
end;
procedure TBCBaseEditor.WMDropFiles(var AMessage: TMessage);
var
i, LNumberDropped: Integer;
LFileName: array [0 .. MAX_PATH - 1] of Char;
LPoint: TPoint;
LFilesList: TStringList;
begin
try
if Assigned(FOnDropFiles) then
begin
LFilesList := TStringList.Create;
try
LNumberDropped := DragQueryFile(THandle(AMessage.wParam), Cardinal(-1), nil, 0);
DragQueryPoint(THandle(AMessage.wParam), LPoint);
for i := 0 to LNumberDropped - 1 do
begin
DragQueryFileW(THandle(AMessage.wParam), i, LFileName, SizeOf(LFileName) div 2);
LFilesList.Add(LFileName)
end;
FOnDropFiles(Self, LPoint, LFilesList);
finally
LFilesList.Free;
end;
end;
finally
AMessage.Result := 0;
DragFinish(THandle(AMessage.wParam));
end;
end;
procedure TBCBaseEditor.WMEraseBkgnd(var AMessage: TMessage);
begin
AMessage.Result := 1;
end;
procedure TBCBaseEditor.WMGetDlgCode(var AMessage: TWMGetDlgCode);
begin
inherited;
AMessage.Result := AMessage.Result or DLGC_WANTARROWS or DLGC_WANTCHARS;
if FTabs.WantTabs then
AMessage.Result := AMessage.Result or DLGC_WANTTAB;
if FWantReturns then
AMessage.Result := AMessage.Result or DLGC_WANTALLKEYS;
end;
procedure TBCBaseEditor.WMGetText(var AMessage: TWMGetText);
begin
StrLCopy(PChar(AMessage.Text), PChar(Text), AMessage.TextMax - 1);
AMessage.Result := StrLen(PChar(AMessage.Text));
end;
procedure TBCBaseEditor.WMGetTextLength(var AMessage: TWMGetTextLength);
begin
if csDocking in ControlState then
AMessage.Result := 0
else
AMessage.Result := Length(Text);
end;
procedure TBCBaseEditor.WMHScroll(var AMessage: TWMScroll);
var
LMaxWidth: Integer;
begin
AMessage.Result := 0;
FreeCompletionProposalPopupWindow;
inherited;
case AMessage.ScrollCode of
SB_LEFT:
LeftChar := 1;
SB_RIGHT:
begin
if soPastEndOfLine in FScroll.Options then
LeftChar := FScroll.MaxWidth - VisibleChars + 1
else
LeftChar := FLines.GetLengthOfLongestLine;
end;
SB_LINERIGHT:
LeftChar := LeftChar + 1;
SB_LINELEFT:
LeftChar := LeftChar - 1;
SB_PAGERIGHT:
LeftChar := LeftChar + VisibleChars;
SB_PAGELEFT:
LeftChar := LeftChar - VisibleChars;
SB_THUMBPOSITION, SB_THUMBTRACK:
begin
FIsScrolling := True;
if soPastEndOfLine in FScroll.Options then
LMaxWidth := FScroll.MaxWidth
else
LMaxWidth := Max(FLines.GetLengthOfLongestLine, 1);
if LMaxWidth > BCEDITOR_MAX_SCROLL_RANGE then
LeftChar := MulDiv(LMaxWidth, AMessage.Pos, BCEDITOR_MAX_SCROLL_RANGE)
else
LeftChar := AMessage.Pos;
end;
SB_ENDSCROLL:
FIsScrolling := False;
end;
Update;
if Assigned(OnScroll) then
OnScroll(Self, sbHorizontal);
end;
procedure TBCBaseEditor.WMIMEChar(var AMessage: TMessage);
begin //FI:W519 FixInsight ignore
{ Do nothing here, the IME string is retrieved in WMIMEComposition
Handling the WM_IME_CHAR message stops Windows from sending WM_CHAR messages while using the IME }
end;
procedure TBCBaseEditor.WMIMEComposition(var AMessage: TMessage);
var
LImc: HIMC;
LPBuffer: PChar;
LImeCount: Integer;
begin
if (AMessage.LParam and GCS_RESULTSTR) <> 0 then
begin
LImc := ImmGetContext(Handle);
try
LImeCount := ImmGetCompositionStringW(LImc, GCS_RESULTSTR, nil, 0);
{ ImeCount is always the size in bytes, also for Unicode }
GetMem(LPBuffer, LImeCount + SizeOf(Char));
try
ImmGetCompositionStringW(LImc, GCS_RESULTSTR, LPBuffer, LImeCount);
LPBuffer[LImeCount div SizeOf(Char)] := BCEDITOR_NONE_CHAR;
CommandProcessor(ecImeStr, BCEDITOR_NONE_CHAR, LPBuffer);
finally
FreeMem(LPBuffer);
end;
finally
ImmReleaseContext(Handle, LImc);
end;
end;
inherited;
end;
procedure TBCBaseEditor.WMIMENotify(var AMessage: TMessage);
var
LImc: HIMC;
LLogFontW: TLogFontW;
begin
with AMessage do
begin
case wParam of
IMN_SETOPENSTATUS:
begin
LImc := ImmGetContext(Handle);
if LImc <> 0 then
begin
GetObjectW(Font.Handle, SizeOf(TLogFontW), @LLogFontW);
ImmSetCompositionFontW(LImc, @LLogFontW);
ImmReleaseContext(Handle, LImc);
end;
end;
end;
end;
inherited;
end;
procedure TBCBaseEditor.WMKillFocus(var AMessage: TWMKillFocus);
begin
inherited;
FreeCompletionProposalPopupWindow;
CommandProcessor(ecLostFocus, BCEDITOR_NONE_CHAR, nil);
if Focused or FAlwaysShowCaret then
Exit;
HideCaret;
Winapi.Windows.DestroyCaret;
if not Selection.Visible and SelectionAvailable then
InvalidateSelection;
end;
{$IFDEF USE_VCL_STYLES}
procedure TBCBaseEditor.WMNCPaint(var AMessage: TMessage);
var
LRect: TRect;
LExStyle: Integer;
LTempRgn: HRGN;
LBorderWidth, LBorderHeight: Integer;
begin
if StyleServices.Enabled then
begin
LExStyle := GetWindowLong(Handle, GWL_EXSTYLE);
if (LExStyle and WS_EX_CLIENTEDGE) <> 0 then
begin
GetWindowRect(Handle, LRect);
LBorderWidth := GetSystemMetrics(SM_CXEDGE);
LBorderHeight := GetSystemMetrics(SM_CYEDGE);
InflateRect(LRect, -LBorderWidth, -LBorderHeight);
LTempRgn := CreateRectRgnIndirect(LRect);
DefWindowProc(Handle, AMessage.Msg, wParam(LTempRgn), 0);
DeleteObject(LTempRgn);
end
else
DefaultHandler(AMessage);
end
else
DefaultHandler(AMessage);
if StyleServices.Enabled then
StyleServices.PaintBorder(Self, False);
end;
{$ENDIF}
procedure TBCBaseEditor.WMPaste(var AMessage: TMessage);
begin
if not ReadOnly then
PasteFromClipboard;
AMessage.Result := Ord(True);
end;
procedure TBCBaseEditor.WMSetCursor(var AMessage: TWMSetCursor);
begin
if (AMessage.HitTest = HTCLIENT) and (AMessage.CursorWnd = Handle) and not (csDesigning in ComponentState) then
UpdateMouseCursor
else
inherited;
end;
procedure TBCBaseEditor.WMSetFocus(var AMessage: TWMSetFocus);
begin
CommandProcessor(ecGotFocus, BCEDITOR_NONE_CHAR, nil);
ResetCaret;
if not Selection.Visible and SelectionAvailable then
InvalidateSelection;
end;
procedure TBCBaseEditor.WMSetText(var AMessage: TWMSetText);
begin
AMessage.Result := 1;
try
if HandleAllocated and IsWindowUnicode(Handle) then
Text := PChar(AMessage.Text)
else
Text := string(PAnsiChar(AMessage.Text));
except
AMessage.Result := 0;
raise
end
end;
procedure TBCBaseEditor.WMSize(var AMessage: TWMSize);
begin
inherited;
SizeOrFontChanged(False);
end;
procedure TBCBaseEditor.WMUndo(var AMessage: TMessage);
begin
DoUndo;
end;
procedure TBCBaseEditor.WMVScroll(var AMessage: TWMScroll);
var
LScrollHint: string;
LScrollHintRect: TRect;
LScrollHintPoint: TPoint;
LScrollHintWindow: THintWindow;
LScrollButtonHeight: Integer;
LScrollInfo: TScrollInfo;
begin
Invalidate;
AMessage.Result := 0;
FreeCompletionProposalPopupWindow;
case AMessage.ScrollCode of
SB_TOP:
TopLine := 1;
SB_BOTTOM:
TopLine := FLineNumbersCount;
SB_LINEDOWN:
TopLine := TopLine + 1;
SB_LINEUP:
TopLine := TopLine - 1;
SB_PAGEDOWN:
TopLine := TopLine + FVisibleLines;
SB_PAGEUP:
TopLine := TopLine - FVisibleLines;
SB_THUMBPOSITION, SB_THUMBTRACK:
begin
FIsScrolling := True;
if FLineNumbersCount > BCEDITOR_MAX_SCROLL_RANGE then
TopLine := MulDiv(VisibleLines + FLineNumbersCount - 1, AMessage.Pos, BCEDITOR_MAX_SCROLL_RANGE)
else
TopLine := AMessage.Pos;
if soShowHint in FScroll.Options then
begin
LScrollHintWindow := GetScrollHint;
if FScroll.Hint.Format = shFTopLineOnly then
LScrollHint := Format(SBCEditorScrollInfoTopLine, [TopLine])
else
LScrollHint := Format(SBCEditorScrollInfo, [TopLine, TopLine + Min(VisibleLines, FLineNumbersCount - TopLine)]);
LScrollHintRect := LScrollHintWindow.CalcHintRect(200, LScrollHint, nil);
if soHintFollows in FScroll.Options then
begin
LScrollButtonHeight := GetSystemMetrics(SM_CYVSCROLL);
FillChar(LScrollInfo, SizeOf(LScrollInfo), 0);
LScrollInfo.cbSize := SizeOf(LScrollInfo);
LScrollInfo.fMask := SIF_ALL;
GetScrollInfo(Handle, SB_VERT, LScrollInfo);
LScrollHintPoint := ClientToScreen(Point(ClientWidth - LScrollHintRect.Right - 4, ((LScrollHintRect.Bottom - LScrollHintRect.Top) shr 1) +
Round((LScrollInfo.nTrackPos / LScrollInfo.nMax) * (ClientHeight - LScrollButtonHeight * 2)) - 2));
end
else
LScrollHintPoint := ClientToScreen(Point(ClientWidth - LScrollHintRect.Right - 4, 4));
OffsetRect(LScrollHintRect, LScrollHintPoint.X, LScrollHintPoint.Y);
LScrollHintWindow.ActivateHint(LScrollHintRect, LScrollHint);
LScrollHintWindow.Update;
end;
end;
SB_ENDSCROLL:
begin
FIsScrolling := False;
if soShowHint in FScroll.Options then
ShowWindow(GetScrollHint.Handle, SW_HIDE);
end;
end;
Update;
if Assigned(OnScroll) then
OnScroll(Self, sbVertical);
end;
procedure TBCBaseEditor.WordWrapChanged(Sender: TObject);
var
LOldTextCaretPosition: TBCEditorTextPosition;
begin
if not Visible then
Exit;
LOldTextCaretPosition := TextCaretPosition;
CreateLineNumbersCache(True);
TextCaretPosition := LOldTextCaretPosition;
if not (csLoading in ComponentState) then
Invalidate;
end;
{ Protected declarations }
function TBCBaseEditor.DoMouseWheel(AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint): Boolean;
var
LWheelClicks: Integer;
LLinesToScroll: Integer;
begin
Result := inherited DoMouseWheel(AShift, AWheelDelta, AMousePos);
if Result then
Exit;
if GetKeyState(VK_CONTROL) < 0 then
LLinesToScroll := VisibleLines shr Ord(soHalfPage in FScroll.Options)
else
LLinesToScroll := 3;
Inc(FMouseWheelAccumulator, AWheelDelta);
LWheelClicks := FMouseWheelAccumulator div BCEDITOR_WHEEL_DIVISOR;
FMouseWheelAccumulator := FMouseWheelAccumulator mod BCEDITOR_WHEEL_DIVISOR;
TopLine := TopLine - LWheelClicks * LLinesToScroll;
Update;
if Assigned(OnScroll) then
OnScroll(Self, sbVertical);
Result := True;
end;
function TBCBaseEditor.DoOnReplaceText(const ASearch, AReplace: string; ALine, AColumn: Integer; DeleteLine: Boolean): TBCEditorReplaceAction;
begin
Result := raCancel;
if Assigned(FOnReplaceText) then
FOnReplaceText(Self, ASearch, AReplace, ALine, AColumn, DeleteLine, Result);
end;
function TBCBaseEditor.DoSearchMatchNotFoundWraparoundDialog: Boolean;
begin
Result := MessageDialog(Format(SBCEditorSearchMatchNotFound, [SLineBreak + SLineBreak]), mtConfirmation, [mbYes, mbNo]) = mrYes; //FI:W510 FixInsight ignore
end;
function TBCBaseEditor.GetReadOnly: Boolean;
begin
Result := FReadOnly;
end;
function TBCBaseEditor.GetSelectionLength: Integer;
begin
if SelectionAvailable then
Result := RowColumnToCharIndex(SelectionEndPosition) - RowColumnToCharIndex(SelectionBeginPosition)
else
Result := 0;
end;
function TBCBaseEditor.TranslateKeyCode(ACode: Word; AShift: TShiftState; var AData: pointer): TBCEditorCommand;
var
i: Integer;
begin
i := KeyCommands.FindKeycodes(FLastKey, FLastShiftState, ACode, AShift);
if i >= 0 then
Result := KeyCommands[i].Command
else
begin
i := KeyCommands.FindKeycode(ACode, AShift);
if i >= 0 then
Result := KeyCommands[i].Command
else
Result := ecNone;
end;
if (Result = ecNone) and (ACode >= VK_ACCEPT) and (ACode <= VK_SCROLL) then
begin
FLastKey := ACode;
FLastShiftState := AShift;
end
else
begin
FLastKey := 0;
FLastShiftState := [];
end;
end;
procedure TBCBaseEditor.ChainLinesChanged(Sender: TObject);
begin
if Assigned(FOnChainLinesChanged) then
FOnChainLinesChanged(Sender);
FOriginalLines.OnChange(Sender);
end;
procedure TBCBaseEditor.ChainLinesChanging(Sender: TObject);
begin
if Assigned(FOnChainLinesChanging) then
FOnChainLinesChanging(Sender);
FOriginalLines.OnChanging(Sender);
end;
procedure TBCBaseEditor.ChainLinesCleared(Sender: TObject);
begin
if Assigned(FOnChainLinesCleared) then
FOnChainLinesCleared(Sender);
FOriginalLines.OnCleared(Sender);
end;
procedure TBCBaseEditor.ChainLinesDeleted(Sender: TObject; AIndex: Integer; ACount: Integer);
begin
if Assigned(FOnChainLinesDeleted) then
FOnChainLinesDeleted(Sender, AIndex, ACount);
FOriginalLines.OnDeleted(Sender, AIndex, ACount);
end;
procedure TBCBaseEditor.ChainLinesInserted(Sender: TObject; AIndex: Integer; ACount: Integer);
begin
if Assigned(FOnChainLinesInserted) then
FOnChainLinesInserted(Sender, AIndex, ACount);
FOriginalLines.OnInserted(Sender, AIndex, ACount);
end;
procedure TBCBaseEditor.ChainLinesPutted(Sender: TObject; AIndex: Integer; ACount: Integer);
begin
if Assigned(FOnChainLinesPutted) then
FOnChainLinesPutted(Sender, AIndex, ACount);
FOriginalLines.OnPutted(Sender, AIndex, ACount);
end;
procedure TBCBaseEditor.ChainUndoRedoAdded(Sender: TObject);
var
LUndoList: TBCEditorUndoList;
LNotifyEvent: TNotifyEvent;
begin
if Sender = FUndoList then
begin
LUndoList := FOriginalUndoList;
LNotifyEvent := FOnChainUndoAdded;
end
else
begin
LUndoList := FOriginalRedoList;
LNotifyEvent := FOnChainRedoAdded;
end;
if Assigned(LNotifyEvent) then
LNotifyEvent(Sender);
LUndoList.OnAddedUndo(Sender);
end;
procedure TBCBaseEditor.CreateParams(var AParams: TCreateParams);
const
LBorderStyles: array [TBorderStyle] of DWORD = (0, WS_BORDER);
LClassStylesOff = CS_VREDRAW or CS_HREDRAW;
begin
StrDispose(WindowText);
WindowText := nil;
inherited CreateParams(AParams);
with AParams do
begin
WindowClass.Style := WindowClass.Style and not LClassStylesOff;
Style := Style or LBorderStyles[FBorderStyle] or WS_CLIPCHILDREN;
if NewStyleControls and Ctl3D and (FBorderStyle = bsSingle) then
begin
Style := Style and not WS_BORDER;
ExStyle := ExStyle or WS_EX_CLIENTEDGE;
end;
end;
end;
procedure TBCBaseEditor.CreateWnd;
begin
inherited;
if (eoDropFiles in FOptions) and not (csDesigning in ComponentState) then
DragAcceptFiles(Handle, True);
UpdateScrollBars;
end;
procedure TBCBaseEditor.DblClick;
var
LCursorPoint: TPoint;
LTextLinesLeft, LTextLinesRight: Integer;
begin
Winapi.Windows.GetCursorPos(LCursorPoint);
LCursorPoint := ScreenToClient(LCursorPoint);
LTextLinesLeft := FLeftMargin.GetWidth + FCodeFolding.GetWidth;
LTextLinesRight := ClientRect.Width;
if FMinimap.Align = maLeft then
Inc(LTextLinesLeft, FMinimap.GetWidth)
else
Dec(LTextLinesRight, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LTextLinesLeft, FSearch.Map.GetWidth)
else
Dec(LTextLinesRight, FSearch.Map.GetWidth);
if (LCursorPoint.X >= LTextLinesLeft) and (LCursorPoint.X < LTextLinesRight) then
begin
if FSelection.Visible then
SetWordBlock(TextCaretPosition);
inherited;
Include(FStateFlags, sfDblClicked);
MouseCapture := False;
end
else
inherited;
end;
procedure TBCBaseEditor.DecPaintLock;
begin
Assert(FPaintLock > 0);
Dec(FPaintLock);
if (FPaintLock = 0) and HandleAllocated then
begin
if sfScrollbarChanged in FStateFlags then
UpdateScrollBars;
if sfCaretChanged in FStateFlags then
UpdateCaret;
end;
end;
procedure TBCBaseEditor.DestroyWnd;
begin
if (eoDropFiles in FOptions) and not (csDesigning in ComponentState) then
DragAcceptFiles(Handle, False);
inherited;
end;
procedure TBCBaseEditor.DoBlockIndent;
var
LOldCaretPosition: TBCEditorTextPosition;
LBlockBeginPosition, LBlockEndPosition: TBCEditorTextPosition;
LStringToInsert: string;
LEndOfLine, LCaretPositionX, i: Integer;
LSpaces: string;
LOldSelectionMode: TBCEditorSelectionMode;
LInsertionPosition: TBCEditorTextPosition;
begin
LOldSelectionMode := FSelection.ActiveMode;
LOldCaretPosition := TextCaretPosition;
LStringToInsert := '';
if SelectionAvailable then
try
LBlockBeginPosition := SelectionBeginPosition;
LBlockEndPosition := SelectionEndPosition;
LEndOfLine := LBlockEndPosition.Line;
if LBlockEndPosition.Char = 1 then
begin
LCaretPositionX := 1;
Dec(LEndOfLine);
end
else
begin
if toTabsToSpaces in FTabs.Options then
LCaretPositionX := LOldCaretPosition.Char + FTabs.Width
else
LCaretPositionX := LOldCaretPosition.Char + 1;
end;
if toTabsToSpaces in FTabs.Options then
LSpaces := StringOfChar(BCEDITOR_SPACE_CHAR, FTabs.Width)
else
LSpaces := BCEDITOR_TAB_CHAR;
for i := LBlockBeginPosition.Line to LEndOfLine - 1 do //FI:W528 FixInsight ignore
LStringToInsert := LStringToInsert + LSpaces + BCEDITOR_CARRIAGE_RETURN + BCEDITOR_LINEFEED;
LStringToInsert := LStringToInsert + LSpaces;
FUndoList.BeginBlock(1);
try
FUndoList.AddChange(crSelection, LOldCaretPosition, LBlockBeginPosition, LBlockEndPosition, '', LOldSelectionMode);
LInsertionPosition.Line := LBlockBeginPosition.Line;
if FSelection.ActiveMode = smColumn then
LInsertionPosition.Char := LBlockBeginPosition.Char
else
LInsertionPosition.Char := 1;
InsertBlock(LInsertionPosition, LInsertionPosition, PChar(LStringToInsert), True);
FUndoList.AddChange(crIndent, LOldCaretPosition, LBlockBeginPosition, LBlockEndPosition, '', smColumn);
finally
FUndoList.EndBlock;
end;
LOldCaretPosition.Char := LCaretPositionX;
if LCaretPositionX <> 1 then
LBlockEndPosition := GetTextPosition(LBlockEndPosition.Char + Length(LSpaces), LBlockEndPosition.Line);
finally
SetCaretAndSelection(LOldCaretPosition, GetTextPosition(LBlockBeginPosition.Char + Length(LSpaces),
LBlockBeginPosition.Line), LBlockEndPosition);
FSelection.ActiveMode := LOldSelectionMode;
end;
end;
procedure TBCBaseEditor.DoBlockUnindent;
var
LOldCaretPosition: TBCEditorTextPosition;
LBlockBeginPosition, LBlockEndPosition: TBCEditorTextPosition;
LLine: PChar;
LFullStringToDelete: string;
LStringToDelete: TBCEditorArrayOfString;
LLength, LCaretPositionX, LDeleteIndex, i, j, LDeletionLength, LFirstIndent, LLastIndent, LLastLine: Integer;
LLineText: string;
LOldSelectionMode: TBCEditorSelectionMode;
LSomethingToDelete: Boolean;
function GetDeletionLength: Integer;
var
Run: PChar;
begin
Result := 0;
Run := LLine;
if Run[0] = BCEDITOR_TAB_CHAR then
begin
Result := 1;
LSomethingToDelete := True;
Exit;
end;
while (Run[0] = BCEDITOR_SPACE_CHAR) and (Result < FTabs.Width) do
begin
Inc(Result);
Inc(Run);
LSomethingToDelete := True;
end;
if (Run[0] = BCEDITOR_TAB_CHAR) and (Result < FTabs.Width) then
Inc(Result);
end;
begin
LOldSelectionMode := FSelection.ActiveMode;
LLength := 0;
LLastIndent := 0;
if SelectionAvailable then
begin
LBlockBeginPosition := SelectionBeginPosition;
LBlockEndPosition := SelectionEndPosition;
LOldCaretPosition := TextCaretPosition;
LCaretPositionX := LOldCaretPosition.Char;
if SelectionEndPosition.Char = 1 then
LLastLine := LBlockEndPosition.Line - 1
else
LLastLine := LBlockEndPosition.Line;
LSomethingToDelete := False;
j := 0;
SetLength(LStringToDelete, LLastLine - LBlockBeginPosition.Line + 1);
for i := LBlockBeginPosition.Line to LLastLine do
begin
LLine := PChar(Lines[i]);
if FSelection.ActiveMode = smColumn then
Inc(LLine, MinIntValue([LBlockBeginPosition.Char - 1, LBlockEndPosition.Char - 1, Length(Lines[i])]));
LDeletionLength := GetDeletionLength;
LStringToDelete[j] := Copy(LLine, 1, LDeletionLength);
Inc(j);
if (LOldCaretPosition.Line = i) and (LCaretPositionX <> 1) then
LCaretPositionX := LCaretPositionX - LDeletionLength;
end;
LFirstIndent := -1;
LFullStringToDelete := '';
if LSomethingToDelete then
begin
for i := 0 to Length(LStringToDelete) - 2 do
LFullStringToDelete := LFullStringToDelete + LStringToDelete[i] + BCEDITOR_CARRIAGE_RETURN + BCEDITOR_LINEFEED;
LFullStringToDelete := LFullStringToDelete + LStringToDelete[Length(LStringToDelete) - 1];
SetTextCaretY(LBlockBeginPosition.Line);
if FSelection.ActiveMode <> smColumn then
LDeleteIndex := 1
else
LDeleteIndex := Min(LBlockBeginPosition.Char, LBlockEndPosition.Char);
j := 0;
for i := LBlockBeginPosition.Line to LLastLine do
begin
LLength := Length(LStringToDelete[j]);
Inc(j);
if LFirstIndent = -1 then
LFirstIndent := LLength;
LLineText := FLines[i];
Delete(LLineText, LDeleteIndex, LLength);
FLines[i] := LLineText;
end;
LLastIndent := LLength;
FUndoList.BeginBlock(2);
try
FUndoList.AddChange(crSelection, LOldCaretPosition, LBlockBeginPosition, LBlockEndPosition, '', LOldSelectionMode);
FUndoList.AddChange(crUnindent, LOldCaretPosition, LBlockBeginPosition, LBlockEndPosition, LFullStringToDelete,
FSelection.ActiveMode);
finally
FUndoList.EndBlock;
end;
end;
if LFirstIndent = -1 then
LFirstIndent := 0;
if FSelection.ActiveMode = smColumn then
SetCaretAndSelection(LOldCaretPosition, LBlockBeginPosition, LBlockEndPosition)
else
begin
LOldCaretPosition.Char := LCaretPositionX;
Dec(LBlockBeginPosition.Char, LFirstIndent);
Dec(LBlockEndPosition.Char, LLastIndent);
SetCaretAndSelection(LOldCaretPosition, LBlockBeginPosition, LBlockEndPosition);
end;
FSelection.ActiveMode := LOldSelectionMode;
end;
end;
procedure TBCBaseEditor.DoChange;
begin
FUndoList.Changed := False;
FRedoList.Changed := False;
if Assigned(FOnChange) then
FOnChange(Self);
end;
procedure TBCBaseEditor.DoCopyToClipboard(const AText: string);
begin
if AText = '' then
Exit;
SetClipboardText(AText);
end;
procedure TBCBaseEditor.DoExecuteCompletionProposal;
var
LPoint: TPoint;
begin
Assert(FCompletionProposal.CompletionColumnIndex < FCompletionProposal.Columns.Count);
LPoint := ClientToScreen(RowColumnToPixels(DisplayCaretPosition));
Inc(LPoint.Y, FLineHeight);
FreeCompletionProposalPopupWindow;
FCompletionProposalPopupWindow := TBCEditorCompletionProposalPopupWindow.Create(Self);
with FCompletionProposalPopupWindow do
begin
Parent := Self;
Assign(FCompletionProposal);
if cpoParseItemsFromText in FCompletionProposal.Options then
SplitTextIntoWords(ItemList, False);
Execute(GetCurrentInput, LPoint.X, LPoint.Y);
end;
end;
procedure TBCBaseEditor.DoUndo;
begin
CommandProcessor(ecUndo, BCEDITOR_NONE_CHAR, nil);
end;
procedure TBCBaseEditor.DoInternalUndo;
procedure RemoveGroupBreak;
var
LUndoItem: TBCEditorUndoItem;
begin
if FUndoList.LastChangeReason = crGroupBreak then
begin
LUndoItem := FUndoList.PopItem;
LUndoItem.Free;
FRedoList.AddGroupBreak;
end;
end;
var
LUndoItem: TBCEditorUndoItem;
LLastChangeBlockNumber: Integer;
LLastChangeReason: TBCEditorChangeReason;
LLastChangeString: string;
LIsPasteAction: Boolean;
LIsKeepGoing: Boolean;
begin
if ReadOnly then
Exit;
RemoveGroupBreak;
LLastChangeBlockNumber := FUndoList.LastChangeBlockNumber;
LLastChangeReason := FUndoList.LastChangeReason;
LLastChangeString := FUndoList.LastChangeString;
LIsPasteAction := LLastChangeReason = crPaste;
LUndoItem := FUndoList.PeekItem;
if Assigned(LUndoItem) then
repeat
UndoItem;
LUndoItem := FUndoList.PeekItem;
LIsKeepGoing := False;
if Assigned(LUndoItem) then
begin
if uoGroupUndo in FUndo.Options then
LIsKeepGoing := LIsPasteAction and (FUndoList.LastChangeString = LLastChangeString) or
(LLastChangeReason = LUndoItem.ChangeReason) and (LUndoItem.ChangeBlockNumber = LLastChangeBlockNumber) or
(LUndoItem.ChangeBlockNumber <> 0) and (LUndoItem.ChangeBlockNumber = LLastChangeBlockNumber);
LLastChangeReason := LUndoItem.ChangeReason;
LIsPasteAction := LLastChangeReason = crPaste;
end;
until not LIsKeepGoing;
end;
procedure TBCBaseEditor.DoKeyPressW(var AMessage: TWMKey);
var
LForm: TCustomForm;
LKey: Char;
begin
LKey := Char(AMessage.CharCode);
if FCompletionProposal.Enabled and FCompletionProposal.Trigger.Enabled then
begin
if Pos(LKey, FCompletionProposal.Trigger.Chars) > 0 then
begin
FCompletionProposalTimer.Interval := FCompletionProposal.Trigger.Interval;
FCompletionProposalTimer.Enabled := True;
end
else
FCompletionProposalTimer.Enabled := False;
end;
LForm := GetParentForm(Self);
if Assigned(LForm) and (LForm <> TWinControl(Self)) and LForm.KeyPreview and (LKey <= High(AnsiChar)) and
TBCEditorAccessWinControl(LForm).DoKeyPress(AMessage) then
Exit;
if csNoStdEvents in ControlStyle then
Exit;
if Assigned(FOnKeyPressW) then
FOnKeyPressW(Self, LKey);
if LKey <> BCEDITOR_NONE_CHAR then
KeyPressW(LKey);
end;
procedure TBCBaseEditor.DoOnAfterBookmarkPlaced;
begin
if Assigned(FOnAfterBookmarkPlaced) then
FOnAfterBookmarkPlaced(Self);
end;
procedure TBCBaseEditor.DoOnAfterClearBookmark;
begin
if Assigned(FOnAfterClearBookmark) then
FOnAfterClearBookmark(Self);
end;
procedure TBCBaseEditor.DoOnBeforeClearBookmark(var ABookmark: TBCEditorBookmark);
begin
if Assigned(FOnBeforeClearBookmark) then
FOnBeforeClearBookmark(Self, ABookmark);
end;
procedure TBCBaseEditor.DoOnCommandProcessed(ACommand: TBCEditorCommand; AChar: Char; AData: pointer);
var
LTextCaretPosition: TBCEditorTextPosition;
function IsPreviousFoldTokenEndPreviousLine(const ALine: Integer): Boolean;
var
i: Integer;
begin
i := ALine;
while (i > 0) and not Assigned(FCodeFoldingRangeToLine[i]) do
begin
if Assigned(FCodeFoldingRangeFromLine[i]) then
Exit(False);
Dec(i);
end;
Result := Assigned(FCodeFoldingRangeToLine[i]) and FCodeFoldingRangeToLine[i].RegionItem.TokenEndIsPreviousLine
end;
begin
if FCodeFolding.Visible then
begin
LTextCaretPosition := TextCaretPosition;
if FRescanCodeFolding or
((ACommand = ecChar) or (ACommand = ecBackspace) or (ACommand = ecDeleteChar) or (ACommand = ecLineBreak)) and
IsKeywordAtCaretPositionOrAfter(TextCaretPosition) or (ACommand = ecUndo) or (ACommand = ecRedo) then
RescanCodeFoldingRanges;
end;
if FMatchingPair.Enabled and not FSyncEdit.Active then
case ACommand of
ecPaste, ecUndo, ecRedo, ecBackspace, ecTab, ecLeft, ecRight, ecUp, ecDown, ecPageUp, ecPageDown, ecPageTop,
ecPageBottom, ecEditorTop, ecEditorBottom, ecGotoXY, ecBlockIndent, ecBlockUnindent, ecShiftTab, ecInsertLine, ecChar,
ecString, ecLineBreak, ecDeleteChar, ecDeleteWord, ecDeleteLastWord, ecDeleteBeginningOfLine, ecDeleteEndOfLine,
ecDeleteLine, ecClear, ecWordLeft, ecWordRight:
ScanMatchingPair;
end;
if cfoShowIndentGuides in CodeFolding.Options then
case ACommand of
ecCut, ecPaste, ecUndo, ecRedo, ecBackspace, ecDeleteChar:
CheckIfAtMatchingKeywords;
end;
if Assigned(FOnCommandProcessed) then
FOnCommandProcessed(Self, ACommand, AChar, AData);
if FCodeFolding.Visible then
if ((ACommand = ecChar) or (ACommand = ecLineBreak)) and IsPreviousFoldTokenEndPreviousLine(LTextCaretPosition.Line) then
RescanCodeFoldingRanges;
end;
procedure TBCBaseEditor.DoOnLeftMarginClick(AButton: TMouseButton; AShift: TShiftState; X, Y: Integer);
var
i: Integer;
LOffset: Integer;
LLine: Integer;
LMarks: TBCEditorBookmarks;
LMark: TBCEditorBookmark;
LFoldRange: TBCEditorCodeFoldingRange;
LCodeFoldingRegion: Boolean;
LTextCaretPosition: TBCEditorTextPosition;
LWidth: Integer;
begin
LTextCaretPosition := DisplayToTextPosition(GetDisplayPosition(1, PixelsToRowColumn(X, Y).Row));
TextCaretPosition := LTextCaretPosition;
{ Clear selection }
if ssShift in AShift then
SelectionEndPosition := LTextCaretPosition
else
begin
SelectionBeginPosition := LTextCaretPosition;
SelectionEndPosition := FSelectionBeginPosition;
end;
if (X < LeftMargin.Bookmarks.Panel.Width) and (Y div FLineHeight <= DisplayCaretY - TopLine) and
LeftMargin.Bookmarks.Visible and
(bpoToggleBookmarkByClick in LeftMargin.Bookmarks.Panel.Options) then
ToggleBookmark;
LWidth := 0;
if FMinimap.Align = maLeft then
Inc(LWidth, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LWidth, FSearch.Map.GetWidth);
LCodeFoldingRegion := (X >= FLeftMargin.GetWidth + LWidth) and (X <= FLeftMargin.GetWidth + FCodeFolding.GetWidth + LWidth);
if FCodeFolding.Visible and LCodeFoldingRegion and (Lines.Count > 0) then
begin
LLine := GetDisplayTextLineNumber(PixelsToRowColumn(X, Y).Row);
LFoldRange := CodeFoldingCollapsableFoldRangeForLine(LLine);
if Assigned(LFoldRange) then
begin
if LFoldRange.Collapsed then
CodeFoldingUncollapse(LFoldRange)
else
CodeFoldingCollapse(LFoldRange);
Refresh;
Exit;
end;
end;
if Assigned(FOnLeftMarginClick) then
begin
LLine := DisplayToTextPosition(PixelsToRowColumn(X, Y)).Line;
if LLine <= FLines.Count then
begin
Marks.GetMarksForLine(LLine, LMarks);
LOffset := 0;
for i := 1 to BCEDITOR_MAX_BOOKMARKS do
begin
LMark := LMarks[i];
if Assigned(LMark) then
begin
Inc(LOffset, FLeftMargin.Bookmarks.Panel.OtherMarkXOffset);
if X < LOffset then
Break;
end;
end;
FOnLeftMarginClick(Self, AButton, X, Y, LLine, LMark);
end;
end;
end;
procedure TBCBaseEditor.DoOnMinimapClick(AButton: TMouseButton; X, Y: Integer);
var
LNewLine, LPreviousLine, LStep: Integer;
begin
FMinimap.Clicked := True;
LPreviousLine := -1;
LNewLine := Max(1, FMinimap.TopLine + Y div FMinimap.CharHeight);
if (LNewLine >= TopLine) and (LNewLine <= TopLine + VisibleLines) then
DisplayCaretY := LNewLine
else
begin
LNewLine := LNewLine - VisibleLines div 2;
LStep := Abs(LNewLine - TopLine) div 5;
if LNewLine < TopLine then
while LNewLine < TopLine - LStep do
begin
TopLine := TopLine - LStep;
if TopLine <> LPreviousLine then
LPreviousLine := TopLine
else
Break;
Paint;
end
else
while LNewLine > TopLine + LStep do
begin
TopLine := TopLine + LStep;
if TopLine <> LPreviousLine then
LPreviousLine := TopLine
else
Break;
Paint;
end;
TopLine := LNewLine;
end;
FMinimapClickOffsetY := LNewLine - TopLine;
end;
procedure TBCBaseEditor.DoOnSearchMapClick(AButton: TMouseButton; X, Y: Integer);
var
LHeight: Double;
begin
LHeight := ClientRect.Height / Max(Lines.Count, 1);
GotoLineAndCenter(Round(Y / LHeight));
end;
procedure TBCBaseEditor.DoOnPaint;
begin
if Assigned(FOnPaint) then
begin
Canvas.Font.Assign(Font);
Canvas.Brush.Color := FBackgroundColor;
FOnPaint(Self, Canvas);
end;
end;
procedure TBCBaseEditor.DoOnBeforeBookmarkPlaced(var ABookmark: TBCEditorBookmark);
begin
if Assigned(FOnBeforeBookmarkPlaced) then
FOnBeforeBookmarkPlaced(Self, ABookmark);
end;
procedure TBCBaseEditor.DoOnProcessCommand(var ACommand: TBCEditorCommand; var AChar: Char; AData: pointer);
begin
if ACommand < ecUserFirst then
begin
if Assigned(FOnProcessCommand) then
FOnProcessCommand(Self, ACommand, AChar, AData);
end
else
if Assigned(FOnProcessUserCommand) then
FOnProcessUserCommand(Self, ACommand, AChar, AData);
end;
procedure TBCBaseEditor.DoSearchStringNotFoundDialog;
begin
MessageDialog(Format(SBCEditorSearchStringNotFound, [FSearch.SearchText]), mtInformation, [mbOK]);
end;
procedure TBCBaseEditor.DoTripleClick;
var
LTextCaretY: Integer;
begin
LTextCaretY := GetTextCaretY;
SelectionBeginPosition := GetTextPosition(1, LTextCaretY);
SelectionEndPosition := GetTextPosition(FLines.StringLength(LTextCaretY) + 1, LTextCaretY);
FLastDblClick := 0;
end;
procedure TBCBaseEditor.DragCanceled;
begin
FScrollTimer.Enabled := False;
Exclude(FStateFlags, sfDragging);
inherited;
end;
procedure TBCBaseEditor.DragOver(ASource: TObject; X, Y: Integer; AState: TDragState; var AAccept: Boolean);
var
LDisplayPosition: TBCEditorDisplayPosition;
LOldTextCaretPosition: TBCEditorTextPosition;
begin
inherited;
if (ASource is TBCBaseEditor) and not ReadOnly then
begin
AAccept := True;
if Dragging then
begin
if AState = dsDragLeave then
ComputeCaret(FMouseDownX, FMouseDownY)
else
begin
LOldTextCaretPosition := TextCaretPosition;
LDisplayPosition := PixelsToNearestRowColumn(X, Y);
LDisplayPosition.Column := MinMax(LDisplayPosition.Column, LeftChar, LeftChar + VisibleChars - 1);
LDisplayPosition.Row := MinMax(LDisplayPosition.Row, TopLine, TopLine + VisibleLines - 1);
TextCaretPosition := DisplayToTextPosition(LDisplayPosition);
ComputeScroll(X, Y);
if (LOldTextCaretPosition.Line <> TextCaretPosition.Line) or
(LOldTextCaretPosition.Char <> TextCaretPosition.Char) then
Refresh;
end;
end
else
ComputeCaret(X, Y);
end;
end;
procedure TBCBaseEditor.FreeHintForm(var AForm: TBCEditorCodeFoldingHintForm);
var
LRect: TRect;
LDisplayPosition: TBCEditorDisplayPosition;
LFoldRange: TBCEditorCodeFoldingRange;
LPoint: TPoint;
begin
LDisplayPosition := PixelsToNearestRowColumn(Mouse.CursorPos.X, Mouse.CursorPos.Y);
LFoldRange := CodeFoldingCollapsableFoldRangeForLine(LDisplayPosition.Row);
if Assigned(LFoldRange) and LFoldRange.Collapsed then
begin
LPoint := Point(Mouse.CursorPos.X, Mouse.CursorPos.Y);
LRect := LFoldRange.CollapseMarkRect;
end;
if Assigned(AForm) then
begin
AForm.Hide;
AForm.ItemList.Clear;
AForm.Free;
AForm := nil;
end;
FCodeFolding.MouseOverHint := False;
UpdateMouseCursor;
end;
procedure TBCBaseEditor.FreeCompletionProposalPopupWindow;
begin
if Assigned(FCompletionProposalPopupWindow) then
begin
FCompletionProposalPopupWindow.Free;
FCompletionProposalPopupWindow := nil;
end;
end;
procedure TBCBaseEditor.HideCaret;
begin
if sfCaretVisible in FStateFlags then
if Winapi.Windows.HideCaret(Handle) then
Exclude(FStateFlags, sfCaretVisible);
end;
procedure TBCBaseEditor.IncPaintLock;
begin
Inc(FPaintLock);
end;
procedure TBCBaseEditor.InvalidateRect(const ARect: TRect);
begin
Winapi.Windows.InvalidateRect(Handle, ARect, False);
end;
procedure TBCBaseEditor.KeyDown(var AKey: Word; AShift: TShiftState);
var
LData: Pointer;
LChar: Char;
LEditorCommand: TBCEditorCommand;
LRangeType: TBCEditorRangeType;
LStart: Integer;
LToken: string;
LHighlighterAttribute: TBCEditorHighlighterAttribute;
LCursorPoint: TPoint;
LTextPosition: TBCEditorTextPosition;
LShortCutKey: Word;
LShortCutShift: TShiftState;
begin
inherited;
if AKey = 0 then
begin
Include(FStateFlags, sfIgnoreNextChar);
Exit;
end;
if FSyncEdit.Enabled then
begin
if FSyncEdit.Active then
if (AKey = BCEDITOR_CARRIAGE_RETURN_KEY) or (AKey = BCEDITOR_ESCAPE_KEY) then
begin
FSyncEdit.Active := False;
AKey := 0;
Exit;
end;
ShortCutToKey(FSyncEdit.ShortCut, LShortCutKey, LShortCutShift);
if (AShift = LShortCutShift) and (AKey = LShortCutKey) then
begin
FSyncEdit.Active := not FSyncEdit.Active;
AKey := 0;
Exit;
end;
end;
FKeyboardHandler.ExecuteKeyDown(Self, AKey, AShift);
{ URI mouse over }
if (ssCtrl in AShift) and URIOpener then
begin
Winapi.Windows.GetCursorPos(LCursorPoint);
LCursorPoint := ScreenToClient(LCursorPoint);
LTextPosition := DisplayToTextPosition(PixelsToRowColumn(LCursorPoint.X, LCursorPoint.Y));
GetHighlighterAttributeAtRowColumn(LTextPosition, LToken, LRangeType, LStart, LHighlighterAttribute);
FMouseOverURI := LRangeType in [ttWebLink, ttMailtoLink];
end;
LData := nil;
LChar := BCEDITOR_NONE_CHAR;
try
LEditorCommand := TranslateKeyCode(AKey, AShift, LData);
if FSyncEdit.Active then
begin
case LEditorCommand of
ecChar, ecBackspace, ecCopy, ecCut, ecLeft, ecSelectionLeft, ecRight, ecSelectionRight:
;
ecPaste:
if Pos(BCEDITOR_CARRIAGE_RETURN, GetClipboardText) <> 0 then
LEditorCommand := ecNone;
ecLineBreak:
FSyncEdit.Active := False;
else
LEditorCommand := ecNone;
end;
end;
if LEditorCommand <> ecNone then
begin
AKey := 0;
Include(FStateFlags, sfIgnoreNextChar);
CommandProcessor(LEditorCommand, LChar, LData);
end
else
Exclude(FStateFlags, sfIgnoreNextChar);
finally
if Assigned(LData) then
FreeMem(LData);
end;
if Assigned(FCompletionProposalPopupWindow) and not FCompletionProposalPopupWindow.Visible then
FreeCompletionProposalPopupWindow;
if FCompletionProposal.Enabled and not Assigned(FCompletionProposalPopupWindow) then
begin
ShortCutToKey(FCompletionProposal.ShortCut, LShortCutKey, LShortCutShift);
if (AShift = LShortCutShift) and (AKey = LShortCutKey) or
(AKey <> LShortCutKey) and (cpoAutoInvoke in FCompletionProposal.Options) and Chr(AKey).IsLetter then
begin
DoExecuteCompletionProposal;
if not (cpoAutoInvoke in FCompletionProposal.Options) then
begin
AKey := 0;
Include(FStateFlags, sfIgnoreNextChar);
Exit;
end;
end;
end;
end;
procedure TBCBaseEditor.KeyPressW(var AKey: Char);
begin
if not (sfIgnoreNextChar in FStateFlags) then
begin
FKeyboardHandler.ExecuteKeyPress(Self, AKey);
CommandProcessor(ecChar, AKey, nil);
end
else
Exclude(FStateFlags, sfIgnoreNextChar);
end;
procedure TBCBaseEditor.KeyUp(var AKey: Word; AShift: TShiftState);
begin
inherited;
if FMouseOverURI then
FMouseOverURI := False;
if FCodeFolding.Visible then
CheckIfAtMatchingKeywords;
FKeyboardHandler.ExecuteKeyUp(Self, AKey, AShift);
end;
procedure TBCBaseEditor.LinesChanged(Sender: TObject);
var
LOldMode: TBCEditorSelectionMode;
begin
Exclude(FStateFlags, sfLinesChanging);
if Visible and HandleAllocated then
begin
UpdateScrollBars;
LOldMode := FSelection.ActiveMode;
SetSelectionBeginPosition(TextCaretPosition);
FSelection.ActiveMode := LOldMode;
InvalidateRect(FInvalidateRect);
FillChar(FInvalidateRect, SizeOf(TRect), 0);
if FLeftMargin.LineNumbers.Visible and FLeftMargin.Autosize then
FLeftMargin.AutosizeDigitCount(Lines.Count);
end;
end;
procedure TBCBaseEditor.LinesHookChanged;
var
LLongestLineLength: Integer;
begin
Invalidate;
if soAutoSizeMaxWidth in FScroll.Options then
begin
LLongestLineLength := FLines.GetLengthOfLongestLine;
if LLongestLineLength <> FScroll.MaxWidth then
FScroll.MaxWidth := LLongestLineLength;
end;
UpdateScrollBars;
end;
procedure TBCBaseEditor.LinesBeforeDeleted(Sender: TObject; AIndex: Integer; ACount: Integer);
begin //FI:W519 FixInsight ignore
{ Do nothing }
end;
procedure TBCBaseEditor.LinesBeforeInserted(Sender: TObject; AIndex: Integer; ACount: Integer);
begin //FI:W519 FixInsight ignore
{ Do nothing }
end;
procedure TBCBaseEditor.LinesBeforePutted(Sender: TObject; AIndex: Integer; ACount: Integer);
begin //FI:W519 FixInsight ignore
{ Do nothing }
end;
procedure TBCBaseEditor.LinesCleared(Sender: TObject);
begin
CaretZero;
ClearCodeFolding;
ClearMatchingPair;
ClearSelection;
FMarkList.Clear;
FillChar(FBookmarks, SizeOf(FBookmarks), 0);
FUndoList.Clear;
FRedoList.Clear;
FResetLineNumbersCache := True;
Modified := False;
end;
procedure TBCBaseEditor.LinesDeleted(Sender: TObject; AIndex: Integer; ACount: Integer);
var
i, LNativeIndex, LRunner: Integer;
LMark: TBCEditorBookmark;
begin
for i := 0 to Marks.Count - 1 do
begin
LMark := Marks[i];
if LMark.Line >= AIndex + ACount then
LMark.Line := LMark.Line - ACount
else
if LMark.Line > AIndex then
LMark.Line := AIndex;
end;
if FCodeFolding.Visible then
CodeFoldingLinesDeleted(AIndex + 1, ACount);
if Assigned(FOnLinesDeleted) then
FOnLinesDeleted(Self, AIndex, ACount);
LNativeIndex := AIndex;
if Assigned(FHighlighter) then
begin
AIndex := Max(AIndex, 1);
if FLines.Count > 0 then
begin
LRunner := RescanHighlighterRangesFrom(AIndex - 1);
if LRunner = AIndex - 1 then
RescanHighlighterRangesFrom(AIndex - 1);
end;
end;
CreateLineNumbersCache(True);
CodeFoldingResetCaches;
RefreshFind;
InvalidateLines(LNativeIndex + 1, LNativeIndex + FVisibleLines + 1);
InvalidateLeftMarginLines(LNativeIndex + 1, LNativeIndex + FVisibleLines + 1);
end;
procedure TBCBaseEditor.LinesInserted(Sender: TObject; AIndex: Integer; ACount: Integer);
var
i, LLength: Integer;
LLastScan: Integer;
LMark: TBCEditorBookmark;
begin
if not FLines.Streaming then
begin
for i := 0 to Marks.Count - 1 do
begin
LMark := Marks[i];
if LMark.Line >= AIndex + 1 then
LMark.Line := LMark.Line + ACount;
end;
if FCodeFolding.Visible then
UpdateFoldRanges(AIndex + 1, ACount);
CreateLineNumbersCache(True);
CodeFoldingResetCaches;
RefreshFind;
end;
if Assigned(Parent) then
if Assigned(FHighlighter) and (FLines.Count > 0) then
begin
LLastScan := AIndex;
repeat
LLastScan := RescanHighlighterRangesFrom(LLastScan);
Inc(LLastScan);
until LLastScan >= AIndex + ACount;
end;
if FLeftMargin.LineNumbers.Visible and FLeftMargin.Autosize then
FLeftMargin.AutosizeDigitCount(Lines.Count);
LLength := FLeftMargin.RealLeftMarginWidth(FLeftMarginCharWidth);
if FLeftMargin.Autosize and (FLeftMargin.GetWidth <> LLength) then
SetLeftMarginWidth(LLength);
InvalidateLines(AIndex + 1, AIndex + FVisibleLines + 1);
InvalidateLeftMarginLines(AIndex + 1, AIndex + FVisibleLines + 1);
if soAutoSizeMaxWidth in FScroll.Options then
begin
LLength := FLines.ExpandedStringLengths[AIndex];
if LLength > FScroll.MaxWidth then
FScroll.MaxWidth := LLength;
end;
end;
procedure TBCBaseEditor.LinesPutted(Sender: TObject; AIndex: Integer; ACount: Integer);
var
LLength: Integer;
LLineEnd: Integer;
begin
LLineEnd := Min(AIndex + 1, FLines.Count);
if Assigned(FHighlighter) then
begin
LLineEnd := Max(LLineEnd, RescanHighlighterRangesFrom(AIndex) + 1);
if FLines <> FOriginalLines then
LLineEnd := MaxInt;
end;
if FWordWrap.Enabled then
FResetLineNumbersCache := True;
RefreshFind;
InvalidateLines(AIndex + 1, LLineEnd);
if Assigned(FOnLinesPutted) then
FOnLinesPutted(Self, AIndex, ACount);
if soAutoSizeMaxWidth in FScroll.Options then
begin
LLength := FLines.ExpandedStringLengths[AIndex];
if LLength > FScroll.MaxWidth then
FScroll.MaxWidth := LLength;
end;
end;
{$IFDEF USE_ALPHASKINS}
procedure TBCBaseEditor.AfterConstruction;
begin
inherited AfterConstruction;
UpdateData(FCommonData);
end;
{$ENDIF}
procedure TBCBaseEditor.Loaded;
begin
inherited Loaded;
{$IFDEF USE_ALPHASKINS}
FCommonData.Loaded;
{$ENDIF}
LeftMarginChanged(Self);
MinimapChanged(Self);
UpdateScrollBars;
end;
procedure TBCBaseEditor.MarkListChange(Sender: TObject);
begin
InvalidateLeftMargin;
end;
procedure TBCBaseEditor.MouseDown(AButton: TMouseButton; AShift: TShiftState; X, Y: Integer);
var
LSelectionAvailable: Boolean;
LLeftMarginWidth: Integer;
LDisplayPosition: TBCEditorDisplayPosition;
LRow, LRowCount: Integer;
LMinimapLeft, LMinimapRight: Integer;
begin
LLeftMarginWidth := FLeftMargin.GetWidth + FCodeFolding.GetWidth;
if FMinimap.Align = maLeft then
Inc(LLeftMarginWidth, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LLeftMarginWidth, FSearch.Map.GetWidth);
LSelectionAvailable := SelectionAvailable;
if AButton = mbLeft then
begin
FMouseDownX := X;
FMouseDownY := Y;
if FMinimap.Visible then
FMinimapBufferBmp.Height := 0;
FreeCompletionProposalPopupWindow;
end;
if FSearch.Map.Visible then
if (FSearch.Map.Align = saRight) and (X > ClientRect.Width - FSearch.Map.GetWidth) or
(FSearch.Map.Align = saLeft) and (X <= FSearch.Map.GetWidth) then
begin
DoOnSearchMapClick(AButton, X, Y);
Exit;
end;
if FSyncEdit.Enabled and FSyncEdit.Activator.Visible and not FSyncEdit.Active and LSelectionAvailable then
begin
LDisplayPosition := TextToDisplayPosition(SelectionEndPosition);
if X < LeftMargin.Bookmarks.Panel.Width then
begin
LRowCount := Y div FLineHeight;
LRow := LDisplayPosition.Row - TopLine;
if (LRowCount <= LRow) and (LRowCount > LRow - 1) then
begin
FSyncEdit.Active := True;
Exit;
end;
end;
end;
if FSyncEdit.Enabled and FSyncEdit.BlockSelected then
if not FSyncEdit.IsTextPositionInBlock(DisplayToTextPosition(PixelsToRowColumn(X, Y))) then
FSyncEdit.Active := False;
if FSyncEdit.Enabled and FSyncEdit.Active then
begin
if not FSyncEdit.IsTextPositionInEdit(DisplayToTextPosition(PixelsToRowColumn(X, Y))) then
FSyncEdit.Active := False
else
begin
ComputeCaret(X, Y);
SelectionBeginPosition := TextCaretPosition;
Exit;
end;
end;
if not FMinimap.Dragging and FMinimap.Visible then
begin
GetMinimapLeftRight(LMinimapLeft, LMinimapRight);
if (X > LMinimapLeft) and (X < LMinimapRight) then
begin
DoOnMinimapClick(AButton, X, Y);
Exit;
end;
end;
inherited MouseDown(AButton, AShift, X, Y);
if (rmoMouseMove in FRightMargin.Options) and FRightMargin.Visible then
if (AButton = mbLeft) and (Abs(RowColumnToPixels(GetDisplayPosition(FRightMargin.Position + 1, 0)).X - X) < 3) then
begin
FRightMargin.Moving := True;
FRightMarginMovePosition := RowColumnToPixels(GetDisplayPosition(FRightMargin.Position, 0)).X;
Exit;
end;
if (AButton = mbLeft) and FCodeFolding.Visible and (Lines.Count > 0) and (cfoShowCollapsedCodeHint in FCodeFolding.Options) and
(cfoUncollapseByHintClick in FCodeFolding.Options) then
if DoOnCodeFoldingHintClick(X, Y) then
begin
Include(FStateFlags, sfCodeFoldingInfoClicked);
FCodeFolding.MouseOverHint := False;
UpdateMouseCursor;
Exit;
end;
FKeyboardHandler.ExecuteMouseDown(Self, AButton, AShift, X, Y);
if (AButton = mbLeft) and (ssDouble in AShift) and (X > LLeftMarginWidth) then
begin
FLastDblClick := GetTickCount;
FLastRow := PixelsToRowColumn(X, Y).Row;
Exit;
end
else
if (soTripleClickRowSelect in FSelection.Options) and (AShift = [ssLeft]) and (FLastDblClick > 0) then
begin
if ((GetTickCount - FLastDblClick) < FDoubleClickTime) and (FLastRow = PixelsToRowColumn(X, Y).Row) then
begin
DoTripleClick;
Invalidate;
Exit;
end;
FLastDblClick := 0;
end;
if (AButton in [mbLeft, mbRight]) and (X > LLeftMarginWidth) then
begin
if AButton = mbRight then
begin
if (coRightMouseClickMovesCaret in FCaret.Options) and
(LSelectionAvailable and not IsTextPositionInSelection(DisplayToTextPosition(PixelsToRowColumn(X, Y))) or
not LSelectionAvailable) then
begin
InvalidateSelection;
FSelectionEndPosition := FSelectionBeginPosition;
ComputeCaret(X, Y);
end
else
Exit;
end
else
begin
FUndoList.AddChange(crCaret, TextCaretPosition, SelectionBeginPosition, SelectionEndPosition, '',
FSelection.ActiveMode);
ComputeCaret(X, Y);
end;
end;
if (AButton = mbMiddle) and not FMouseMoveScrolling then
begin
FMouseMoveScrolling := True;
FMouseMoveScrollingPoint := Point(X, Y);
Invalidate;
Exit;
end
else
if FMouseMoveScrolling then
begin
FMouseMoveScrolling := False;
Invalidate;
Exit;
end;
if AButton = mbLeft then
begin
MouseCapture := True;
Exclude(FStateFlags, sfWaitForDragging);
if LSelectionAvailable and (eoDragDropEditing in FOptions) and (X > LLeftMarginWidth) and
(FSelection.Mode = smNormal) and IsTextPositionInSelection(DisplayToTextPosition(PixelsToRowColumn(X, Y))) then
Include(FStateFlags, sfWaitForDragging);
end;
if not (sfWaitForDragging in FStateFlags) then
if not (sfDblClicked in FStateFlags) then
begin
if ssShift in AShift then
SetSelectionEndPosition(TextCaretPosition)
else
begin
if soALTSetsColumnMode in FSelection.Options then
begin
if (ssAlt in AShift) and not FAltEnabled then
begin
FSaveSelectionMode := FSelection.Mode;
FSelection.Mode := smColumn;
FAltEnabled := True;
end
else
if not (ssAlt in AShift) and FAltEnabled then
begin
FSelection.Mode := FSaveSelectionMode;
FAltEnabled := False;
end;
end;
SelectionBeginPosition := TextCaretPosition;
end;
end;
if X <= LLeftMarginWidth then
DoOnLeftMarginClick(AButton, AShift, X, Y);
if FMatchingPair.Enabled then
ScanMatchingPair;
if CanFocus then
begin
SetFocus;
Winapi.Windows.SetFocus(Handle);
end;
end;
procedure TBCBaseEditor.DragMinimap(Y: Integer);
var
LTopLine, LTemp, LTemp2: Integer;
begin
LTemp := FLineNumbersCount - FMinimap.VisibleLines;
LTemp2 := Max(Y div FMinimap.CharHeight - FMinimapClickOffsetY, 0);
FMinimap.TopLine := Max(1, Trunc((LTemp / Max(FMinimap.VisibleLines - VisibleLines, 1)) * LTemp2));
if (FMinimap.TopLine > LTemp) and (LTemp > 0) then
FMinimap.TopLine := LTemp;
LTopLine := Max(1, FMinimap.TopLine + LTemp2);
if TopLine <> LTopLine then
begin
TopLine := LTopLine;
Paint;
end;
end;
procedure TBCBaseEditor.MouseMove(AShift: TShiftState; X, Y: Integer);
var
LDisplayPosition: TBCEditorDisplayPosition;
LFoldRange: TBCEditorCodeFoldingRange;
LPoint: TPoint;
i, j, LScrolledXBy: Integer;
LRect: TRect;
LHintWindow: THintWindow;
LPositionText: string;
LLine: Integer;
LWidth: Integer;
LMinimapLeft, LMinimapRight: Integer;
LTextCaretPosition: TBCEditorTextPosition;
begin
if FMouseMoveScrolling then
begin
ComputeScroll(X, Y);
Exit;
end;
if FMinimap.Visible then
begin
GetMinimapLeftRight(LMinimapLeft, LMinimapRight);
if (X > LMinimapLeft) and (X < LMinimapRight) then
if FMinimap.Clicked then
begin
if FMinimap.Dragging then
DragMinimap(Y);
if not FMinimap.Dragging then
if (ssLeft in AShift) and MouseCapture and (Abs(FMouseDownY - Y) >= GetSystemMetrics(SM_CYDRAG)) then
FMinimap.Dragging := True;
Exit;
end;
end;
if FMinimap.Clicked then
Exit;
if FSearch.Map.Visible then
if (FSearch.Map.Align = saRight) and (X > ClientRect.Width - FSearch.Map.GetWidth) or
(FSearch.Map.Align = saLeft) and (X <= FSearch.Map.GetWidth) then
Exit;
inherited MouseMove(AShift, X, Y);
if FMouseOverURI and not (ssCtrl in AShift) then
FMouseOverURI := False;
if (rmoMouseMove in FRightMargin.Options) and FRightMargin.Visible then
begin
FRightMargin.MouseOver := Abs(RowColumnToPixels(GetDisplayPosition(FRightMargin.Position + 1, 0)).X - X) < 3;
if FRightMargin.Moving then
begin
LWidth := 0;
if FMinimap.Align = maLeft then
Inc(LWidth, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LWidth, FSearch.Map.GetWidth);
if X > FLeftMargin.GetWidth + FCodeFolding.GetWidth + LWidth then
FRightMarginMovePosition := X;
if rmoShowMovingHint in FRightMargin.Options then
begin
LHintWindow := GetRightMarginHint;
LPositionText := Format(SBCEditorRightMarginPosition, [PixelsToRowColumn(FRightMarginMovePosition, Y).Column]);
LRect := LHintWindow.CalcHintRect(200, LPositionText, nil);
LPoint := ClientToScreen(Point(ClientWidth - LRect.Right - 4, 4));
OffsetRect(LRect, LPoint.X, LPoint.Y);
LHintWindow.ActivateHint(LRect, LPositionText);
LHintWindow.Invalidate;
end;
Invalidate;
Exit;
end;
end;
if FCodeFolding.Visible and (cfoShowCollapsedCodeHint in CodeFolding.Options) and FCodeFolding.Hint.Visible then
begin
LDisplayPosition := PixelsToNearestRowColumn(X, Y);
LLine := GetDisplayTextLineNumber(LDisplayPosition.Row);
LFoldRange := CodeFoldingCollapsableFoldRangeForLine(LLine);
if Assigned(LFoldRange) and LFoldRange.Collapsed then
begin
LScrolledXBy := (LeftChar - 1) * FCharWidth;
LPoint := Point(X, Y);
LRect := LFoldRange.CollapseMarkRect;
if LRect.Right - LScrolledXBy > 0 then
begin
OffsetRect(LRect, -LScrolledXBy, 0);
FCodeFolding.MouseOverHint := False;
if PtInRect(LRect, LPoint) then
begin
FCodeFolding.MouseOverHint := True;
LPoint := RowColumnToPixels(GetDisplayPosition(0, LDisplayPosition.Row + 1));
LPoint.X := Mouse.CursorPos.X - X + LPoint.X + 4 + LScrolledXBy;
LPoint.Y := Mouse.CursorPos.Y - Y + LPoint.Y + 2;
if not Assigned(FCodeFoldingHintForm) then
begin
FCodeFoldingHintForm := TBCEditorCodeFoldingHintForm.Create(Self);
with FCodeFoldingHintForm do
begin
BackgroundColor := FCodeFolding.Hint.Colors.Background;
BorderColor := FCodeFolding.Hint.Colors.Border;
Font := FCodeFolding.Hint.Font;
end;
j := LFoldRange.ToLine - LFoldRange.FromLine - 1;
if j > FCodeFolding.Hint.RowCount then
j := FCodeFolding.Hint.RowCount;
for i := LFoldRange.FromLine - 1 to LFoldRange.FromLine + j do
FCodeFoldingHintForm.ItemList.Add(FLines.ExpandedStrings[i]);
if j = FCodeFolding.Hint.RowCount then
FCodeFoldingHintForm.ItemList.Add('...');
FCodeFoldingHintForm.Execute('', LPoint.X, LPoint.Y);
end;
end
else
FreeHintForm(FCodeFoldingHintForm);
end
else
FreeHintForm(FCodeFoldingHintForm);
end
else
FreeHintForm(FCodeFoldingHintForm);
end;
{ Drag & Drop }
if MouseCapture and (sfWaitForDragging in FStateFlags) then
begin
if (Abs(FMouseDownX - X) >= GetSystemMetrics(SM_CXDRAG)) or (Abs(FMouseDownY - Y) >= GetSystemMetrics(SM_CYDRAG)) then
begin
Exclude(FStateFlags, sfWaitForDragging);
BeginDrag(False);
Include(FStateFlags, sfDragging);
FDragBeginTextCaretPosition := TextCaretPosition;
end;
end
else
if (ssLeft in AShift) and MouseCapture and ((X <> FOldMouseMovePoint.X) or (Y <> FOldMouseMovePoint.Y)) then
begin
FOldMouseMovePoint.X := X;
FOldMouseMovePoint.Y := Y;
ComputeScroll(X, Y);
LDisplayPosition := PixelsToNearestRowColumn(X, Y);
LDisplayPosition.Row := MinMax(LDisplayPosition.Row, 1, FLineNumbersCount);
if FScrollDeltaX <> 0 then
LDisplayPosition.Column := DisplayCaretX;
if FScrollDeltaY <> 0 then
LDisplayPosition.Row := DisplayCaretY;
if not (sfCodeFoldingInfoClicked in FStateFlags) then { no selection when info clicked }
begin
LTextCaretPosition := DisplayToTextPosition(LDisplayPosition);
TextCaretPosition := LTextCaretPosition;
SelectionEndPosition := LTextCaretPosition;
if (uoGroupUndo in FUndo.Options) and UndoList.CanUndo then
FUndoList.AddGroupBreak;
end;
FLastSortOrder := soDesc;
Include(FStateFlags, sfInSelection);
Exclude(FStateFlags, sfCodeFoldingInfoClicked);
end;
end;
procedure TBCBaseEditor.MouseUp(AButton: TMouseButton; AShift: TShiftState; X, Y: Integer);
var
LRangeType: TBCEditorRangeType;
LStart: Integer;
LToken: string;
LHighlighterAttribute: TBCEditorHighlighterAttribute;
LCursorPoint: TPoint;
LTextPosition: TBCEditorTextPosition;
LWidth: Integer;
begin
FMinimap.Clicked := False;
FMinimap.Dragging := False;
Exclude(FStateFlags, sfInSelection);
inherited MouseUp(AButton, AShift, X, Y);
FKeyboardHandler.ExecuteMouseUp(Self, AButton, AShift, X, Y);
if FCodeFolding.Visible then
CheckIfAtMatchingKeywords;
LWidth := 0;
if FMinimap.Align = maLeft then
Inc(LWidth, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LWidth, FSearch.Map.GetWidth);
if FMouseOverURI and (AButton = mbLeft) and (X > FLeftMargin.GetWidth + FCodeFolding.GetWidth + LWidth) then
begin
Winapi.Windows.GetCursorPos(LCursorPoint);
LCursorPoint := ScreenToClient(LCursorPoint);
LTextPosition := DisplayToTextPosition(PixelsToRowColumn(LCursorPoint.X, LCursorPoint.Y));
GetHighlighterAttributeAtRowColumn(LTextPosition, LToken, LRangeType, LStart, LHighlighterAttribute);
OpenLink(LToken, LRangeType);
Exit;
end;
if (rmoMouseMove in FRightMargin.Options) and FRightMargin.Visible then
if FRightMargin.Moving then
begin
FRightMargin.Moving := False;
if rmoShowMovingHint in FRightMargin.Options then
ShowWindow(GetRightMarginHint.Handle, SW_HIDE);
with PixelsToRowColumn(FRightMarginMovePosition, Y) do
FRightMargin.Position := Column;
if Assigned(FOnRightMarginMouseUp) then
FOnRightMarginMouseUp(Self);
Invalidate;
Exit;
end;
FMouseMoveScrollTimer.Enabled := False;
FScrollTimer.Enabled := False;
if (AButton = mbRight) and (AShift = [ssRight]) and Assigned(PopupMenu) then
Exit;
MouseCapture := False;
if FStateFlags * [sfDblClicked, sfWaitForDragging] = [sfWaitForDragging] then
begin
ComputeCaret(X, Y);
if not (ssShift in AShift) then
SetSelectionBeginPosition(TextCaretPosition);
SetSelectionEndPosition(TextCaretPosition);
Exclude(FStateFlags, sfWaitForDragging);
end;
Exclude(FStateFlags, sfDblClicked);
end;
procedure TBCBaseEditor.NotifyHookedCommandHandlers(AAfterProcessing: Boolean; var ACommand: TBCEditorCommand;
var AChar: Char; AData: Pointer);
var
LHandled: Boolean;
i: Integer;
LHookedCommandHandler: TBCEditorHookedCommandHandler;
begin
LHandled := False;
for i := 0 to GetHookedCommandHandlersCount - 1 do
begin
LHookedCommandHandler := TBCEditorHookedCommandHandler(FHookedCommandHandlers[i]);
LHookedCommandHandler.Event(Self, AAfterProcessing, LHandled, ACommand, AChar, AData, LHookedCommandHandler.Data);
end;
if LHandled then
ACommand := ecNone;
end;
procedure TBCBaseEditor.Paint;
var
LClipRect, DrawRect: TRect;
LLine1, LLine2, LLine3, LTemp: Integer;
LHandle: HDC;
LSelectionAvailable: Boolean;
LTextLinesLeft, LTextLinesRight: Integer;
begin
if PaintLock <> 0 then
Exit;
if FHighlighter.Loading then
Exit;
LClipRect := Canvas.ClipRect;
LLine1 := FTopLine;
LTemp := (LClipRect.Bottom + FLineHeight - 1) div FLineHeight;
LLine2 := MinMax(FTopLine + LTemp, 1, FLineNumbersCount);
LLine3 := FTopLine + LTemp;
LTextLinesLeft := FLeftMargin.GetWidth + FCodeFolding.GetWidth;
LTextLinesRight := ClientRect.Width;
if FMinimap.Align = maLeft then
Inc(LTextLinesLeft, FMinimap.GetWidth)
else
Dec(LTextLinesRight, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LTextLinesLeft, FSearch.Map.GetWidth)
else
Dec(LTextLinesRight, FSearch.Map.GetWidth);
HideCaret;
LHandle := Canvas.Handle;
Canvas.Handle := FBufferBmp.Canvas.Handle;
FBufferBmp.Canvas.Handle := LHandle;
LHandle := Canvas.Handle; { important, don't remove }
FTextDrawer.BeginDrawing(LHandle);
try
Canvas.Brush.Color := FBackgroundColor;
{ Text lines }
if LClipRect.Right > LTextLinesLeft then
begin
DrawRect := LClipRect;
DrawRect.Left := LTextLinesLeft;
DrawRect.Right := LTextLinesRight;
FTextDrawer.SetBaseFont(Font);
PaintTextLines(DrawRect, LLine1, LLine2, False);
if FCodeFolding.Visible and (cfoShowIndentGuides in CodeFolding.Options) then
PaintGuides(LLine1, LLine2, False);
if Minimap.Visible and FMinimap.Shadow.Visible and
((FMinimap.Align = maRight) or (FMinimap.Align = maLeft) and not FLeftMargin.Visible and not FCodeFolding.Visible) then
PaintMinimapShadow(DrawRect);
end;
if FCaret.NonBlinking.Enabled then
DrawCursor(Canvas);
DoOnPaint;
if LClipRect.Left < LTextLinesLeft then
begin
DrawRect := LClipRect;
DrawRect.Left := 0;
if FMinimap.Align = maLeft then
Inc(DrawRect.Left, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(DrawRect.Left, FSearch.Map.GetWidth);
{ Left margin }
if FLeftMargin.Visible then
begin
DrawRect.Right := DrawRect.Left + FLeftMargin.GetWidth;
PaintLeftMargin(DrawRect, LLine1, LLine2, LLine3);
if Minimap.Visible and FMinimap.Shadow.Visible and (FMinimap.Align = maLeft) then
PaintMinimapShadow(DrawRect);
end;
{ Code folding }
if FCodeFolding.Visible then
begin
Inc(DrawRect.Left, FLeftMargin.GetWidth);
DrawRect.Right := DrawRect.Left + FCodeFolding.GetWidth;
PaintCodeFolding(DrawRect, LLine1, LLine2);
if Minimap.Visible and FMinimap.Shadow.Visible and (FMinimap.Align = maLeft) and not FLeftMargin.Visible then
PaintMinimapShadow(DrawRect);
end;
end;
if soHighlightResults in FSearch.Options then
PaintSearchResults;
if FSyncEdit.Enabled and FSyncEdit.Active then
PaintSyncItems;
if FMouseMoveScrolling and (soWheelClickMove in FScroll.Options) then
PaintMouseMoveScrollPoint;
{ Minimap }
if FMinimap.Visible then
if (FMinimap.Align = maRight) and (LClipRect.Right > LTextLinesRight) or
(FMinimap.Align = maLeft) and (LClipRect.Left < LTextLinesLeft - FLeftMargin.GetWidth - FCodeFolding.GetWidth) then
begin
DrawRect := LClipRect;
if FMinimap.Align = maRight then
begin
DrawRect.Left := LTextLinesRight;
DrawRect.Right := ClientRect.Width;
if FSearch.Map.Align = saRight then
Dec(DrawRect.Right, FSearch.Map.GetWidth);
end
else
begin
DrawRect.Left := 0;
DrawRect.Right := FMinimap.GetWidth;
if FSearch.Map.Align = saLeft then
begin
Inc(DrawRect.Left, FSearch.Map.GetWidth);
Inc(DrawRect.Right, FSearch.Map.GetWidth);
end;
end;
FTextDrawer.SetBaseFont(FMinimap.Font);
LSelectionAvailable := SelectionAvailable;
if not FMinimap.Dragging and
(DrawRect.Height = FMinimapBufferBmp.Height) and (FLastTopLine = FTopLine) and
(FLastLineNumberCount = FLineNumbersCount) and (not LSelectionAvailable or
LSelectionAvailable and
(FSelectionBeginPosition.Line >= FTopLine) and (FSelectionEndPosition.Line <= FTopLine + FVisibleLines)) then
begin
LLine1 := FTopLine;
LLine2 := FTopLine + FVisibleLines;
BitBlt(Canvas.Handle, DrawRect.Left, DrawRect.Top, DrawRect.Width, DrawRect.Height,
FMinimapBufferBmp.Canvas.Handle, 0, 0, SRCCOPY);
end
else
begin
LLine1 := Max(FMinimap.TopLine, 1);
LLine2 := Min(FLineNumbersCount, LLine1 + LClipRect.Height div Max(FMinimap.CharHeight - 1, 1));
end;
PaintTextLines(DrawRect, LLine1, LLine2, True);
if FCodeFolding.Visible and (moShowIndentGuides in FMinimap.Options) then
PaintGuides(LLine1, LLine2, True);
if ioUseBlending in FMinimap.Indicator.Options then
PaintMinimapIndicator(DrawRect);
FMinimapBufferBmp.Width := DrawRect.Width;
FMinimapBufferBmp.Height := DrawRect.Height;
BitBlt(FMinimapBufferBmp.Canvas.Handle, 0, 0, DrawRect.Width, DrawRect.Height, Canvas.Handle, DrawRect.Left,
DrawRect.Top, SRCCOPY);
FTextDrawer.SetBaseFont(Font);
end;
{ Search map }
if FSearch.Map.Visible then
if (FSearch.Map.Align = saRight) and (LClipRect.Right > ClientRect.Width - FSearch.Map.GetWidth) or
(FSearch.Map.Align = saLeft) and (LClipRect.Left <= FSearch.Map.GetWidth) then
begin
DrawRect := LClipRect;
if FSearch.Map.Align = saRight then
DrawRect.Left := ClientRect.Width - FSearch.Map.GetWidth
else
begin
DrawRect.Left := 0;
DrawRect.Right := FSearch.Map.GetWidth;
end;
PaintSearchMap(DrawRect);
end;
if FRightMargin.Moving then
PaintRightMarginMove;
finally
FLastTopLine := FTopLine;
FLastLineNumberCount := FLineNumbersCount;
FTextDrawer.EndDrawing;
BitBlt(FBufferBmp.Canvas.Handle, 0, 0, ClientRect.Width, ClientRect.Height, Canvas.Handle, 0, 0, SRCCOPY);
FBufferBmp.Canvas.Handle := Canvas.Handle;
Canvas.Handle := LHandle;
UpdateCaret;
end;
end;
procedure TBCBaseEditor.PaintCodeFolding(AClipRect: TRect; AFirstRow, ALastRow: Integer);
var
i, LLine: Integer;
LFoldRange: TBCEditorCodeFoldingRange;
LOldBrushColor, LOldPenColor: TColor;
begin
LOldBrushColor := Canvas.Brush.Color;
LOldPenColor := Canvas.Pen.Color;
Canvas.Brush.Color := FCodeFolding.Colors.Background;
PatBlt(Canvas.Handle, AClipRect.Left, AClipRect.Top, AClipRect.Width, AClipRect.Height, PATCOPY); { fill code folding rect }
Canvas.Pen.Style := psSolid;
Canvas.Brush.Color := FCodeFolding.Colors.FoldingLine;
LFoldRange := nil;
if cfoHighlightFoldingLine in FCodeFolding.Options then
LFoldRange := CodeFoldingLineInsideRange(GetTextCaretY);
for i := AFirstRow to ALastRow do
begin
LLine := GetDisplayTextLineNumber(i);
AClipRect.Top := (i - FTopLine) * FLineHeight;
AClipRect.Bottom := AClipRect.Top + FLineHeight;
if (GetTextCaretY + 1 = LLine) and (FCodeFolding.Colors.ActiveLineBackground <> clNone) then
begin
Canvas.Brush.Color := FCodeFolding.Colors.ActiveLineBackground;
PatBlt(Canvas.Handle, AClipRect.Left, AClipRect.Top, AClipRect.Width, AClipRect.Height, PATCOPY); { active line background }
end;
if Assigned(LFoldRange) and (LLine >= LFoldRange.FromLine) and (LLine <= LFoldRange.ToLine) then
begin
Canvas.Brush.Color := CodeFolding.Colors.FoldingLineHighlight;
Canvas.Pen.Color := CodeFolding.Colors.FoldingLineHighlight;
end
else
begin
Canvas.Brush.Color := CodeFolding.Colors.FoldingLine;
Canvas.Pen.Color := CodeFolding.Colors.FoldingLine;
end;
PaintCodeFoldingLine(AClipRect, LLine);
end;
Canvas.Brush.Color := LOldBrushColor;
Canvas.Pen.Color := LOldPenColor;
end;
procedure TBCBaseEditor.PaintCodeFoldingLine(AClipRect: TRect; ALine: Integer);
var
X, Y, LHeight, LTemp: Integer;
LFoldRange: TBCEditorCodeFoldingRange;
begin
if CodeFolding.Padding > 0 then
InflateRect(AClipRect, -CodeFolding.Padding, 0);
LFoldRange := CodeFoldingCollapsableFoldRangeForLine(ALine);
if not Assigned(LFoldRange) then
begin
if CodeFoldingTreeLineForLine(ALine) then
begin
X := AClipRect.Left + ((AClipRect.Right - AClipRect.Left) div 2) - 1;
Canvas.MoveTo(X, AClipRect.Top);
Canvas.LineTo(X, AClipRect.Bottom);
end;
if CodeFoldingTreeEndForLine(ALine) then
begin
X := AClipRect.Left + ((AClipRect.Right - AClipRect.Left) div 2) - 1;
Canvas.MoveTo(X, AClipRect.Top);
Y := AClipRect.Top + ((AClipRect.Bottom - AClipRect.Top) - 4);
Canvas.LineTo(X, Y);
Canvas.LineTo(AClipRect.Right - 1, Y);
end
end
else
if LFoldRange.Collapsable then
begin
LHeight := AClipRect.Right - AClipRect.Left;
AClipRect.Top := AClipRect.Top + ((FLineHeight - LHeight) div 2);
AClipRect.Bottom := AClipRect.Top + LHeight - 1;
AClipRect.Right := AClipRect.Right - 1;
if CodeFolding.MarkStyle = msSquare then
Canvas.FrameRect(AClipRect)
else
if CodeFolding.MarkStyle = msCircle then
begin
Canvas.Brush.Color := FCodeFolding.Colors.Background;
Canvas.Ellipse(AClipRect);
end;
{ minus }
LTemp := AClipRect.Top + ((AClipRect.Bottom - AClipRect.Top) div 2);
Canvas.MoveTo(AClipRect.Left + 2, LTemp);
Canvas.LineTo(AClipRect.Right - 2, LTemp);
if LFoldRange.Collapsed then
begin
{ plus }
LTemp := (AClipRect.Right - AClipRect.Left) div 2;
Canvas.MoveTo(AClipRect.Left + LTemp, AClipRect.Top + 2);
Canvas.LineTo(AClipRect.Left + LTemp, AClipRect.Bottom - 2);
end;
end;
end;
procedure TBCBaseEditor.PaintCodeFoldingCollapsedLine(AFoldRange: TBCEditorCodeFoldingRange; ALineRect: TRect);
var
LOldPenColor: TColor;
begin
if FCodeFolding.Visible and (cfoShowCollapsedLine in CodeFolding.Options) and Assigned(AFoldRange) and
AFoldRange.Collapsed and not AFoldRange.ParentCollapsed then
begin
LOldPenColor := Canvas.Pen.Color;
Canvas.Pen.Color := CodeFolding.Colors.CollapsedLine;
Canvas.MoveTo(ALineRect.Left, ALineRect.Bottom - 1);
Canvas.LineTo(Width, ALineRect.Bottom - 1);
Canvas.Pen.Color := LOldPenColor;
end;
end;
procedure TBCBaseEditor.PaintCodeFoldingCollapseMark(AFoldRange: TBCEditorCodeFoldingRange; ATokenPosition, ATokenLength, ALine,
AScrolledXBy: Integer; ALineRect: TRect);
var
LOldPenColor: TColor;
LCollapseMarkRect: TRect;
i, X, Y: Integer;
LBrush: TBrush;
begin
LOldPenColor := Canvas.Pen.Color;
if FCodeFolding.Visible and (cfoShowCollapsedCodeHint in CodeFolding.Options) and Assigned(AFoldRange) and
AFoldRange.Collapsed and not AFoldRange.ParentCollapsed then
begin
LCollapseMarkRect.Left := (ATokenPosition + ATokenLength + 1) * FCharWidth + FLeftMargin.GetWidth + FCodeFolding.GetWidth;
if FMinimap.Align = maLeft then
Inc(LCollapseMarkRect.Left, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LCollapseMarkRect.Left, FSearch.Map.GetWidth);
LCollapseMarkRect.Top := ALineRect.Top + 2;
LCollapseMarkRect.Bottom := ALineRect.Bottom - 2;
LCollapseMarkRect.Right := LCollapseMarkRect.Left + FCharWidth * 4 - 2;
AFoldRange.CollapseMarkRect := LCollapseMarkRect;
if LCollapseMarkRect.Right - AScrolledXBy > 0 then
begin
OffsetRect(LCollapseMarkRect, -AScrolledXBy, 0);
LBrush := TBrush.Create;
try
LBrush.Color := FCodeFolding.Colors.FoldingLine;
Winapi.Windows.FrameRect(Canvas.Handle, LCollapseMarkRect, LBrush.Handle);
finally
LBrush.Free;
end;
Canvas.Pen.Color := FCodeFolding.Colors.FoldingLine;
{ paint [...] }
Y := LCollapseMarkRect.Top + (LCollapseMarkRect.Bottom - LCollapseMarkRect.Top) div 2;
X := LCollapseMarkRect.Left + FCharWidth - 1;
for i := 1 to 3 do //FI:W528 FixInsight ignore
begin
Canvas.Rectangle(X, Y, X + 2, Y + 2);
X := X + FCharWidth - 1;
end;
end;
end;
Canvas.Pen.Color := LOldPenColor;
end;
procedure TBCBaseEditor.PaintGuides(AFirstRow, ALastRow: Integer; AMinimap: Boolean);
var
i, j, k: Integer;
X, Y, Z: Integer;
LLine, LCurrentLine: Integer;
LOldColor: TColor;
LDeepestLevel: Integer;
LCodeFoldingRange, LCodeFoldingRangeTo: TBCEditorCodeFoldingRange;
LIncY: Boolean;
LScrolledXBy: Integer;
LTopLine, LBottomLine: Integer;
LCodeFoldingRanges: array of TBCEditorCodeFoldingRange;
function GetDeepestLevel: Integer;
var
LTempLine: Integer;
begin
Result := 0;
LTempLine := LCurrentLine;
if Length(FCodeFoldingRangeFromLine) > 1 then
begin
while LTempLine > 0 do
begin
LCodeFoldingRange := FCodeFoldingRangeFromLine[LTempLine];
LCodeFoldingRangeTo := FCodeFoldingRangeToLine[LTempLine];
if not Assigned(LCodeFoldingRange) and not Assigned(LCodeFoldingRangeTo) then
Dec(LTempLine)
else
if Assigned(LCodeFoldingRange) and (LCurrentLine >= LCodeFoldingRange.FromLine) and (LCurrentLine <= LCodeFoldingRange.ToLine) then
Break
else
if Assigned(LCodeFoldingRangeTo) and (LCurrentLine >= LCodeFoldingRangeTo.FromLine) and (LCurrentLine <= LCodeFoldingRangeTo.ToLine) then
begin
LCodeFoldingRange := LCodeFoldingRangeTo;
Break
end
else
Dec(LTempLine)
end;
if Assigned(LCodeFoldingRange) then
Result := LCodeFoldingRange.IndentLevel;
end;
end;
begin
LOldColor := Canvas.Pen.Color;
Y := 0;
LCurrentLine := GetDisplayTextLineNumber(DisplayCaretY);
LCodeFoldingRange := nil;
LScrolledXBy := (FLeftChar - 1) * FTextDrawer.CharWidth;
LDeepestLevel := GetDeepestLevel;
LTopLine := GetDisplayTextLineNumber(TopLine);
LBottomLine := GetDisplayTextLineNumber(TopLine + VisibleLines);
SetLength(LCodeFoldingRanges, FAllCodeFoldingRanges.AllCount);
k := 0;
for i := 0 to FAllCodeFoldingRanges.AllCount - 1 do
begin
LCodeFoldingRange := FAllCodeFoldingRanges[i];
if Assigned(LCodeFoldingRange) then
for j := AFirstRow to ALastRow do
begin
LLine := GetDisplayTextLineNumber(j);
if (LCodeFoldingRange.ToLine < LTopLine) or (LCodeFoldingRange.FromLine > LBottomLine) then
Break
else
if not LCodeFoldingRange.Collapsed and not LCodeFoldingRange.ParentCollapsed and
(LCodeFoldingRange.FromLine < LLine) and (LCodeFoldingRange.ToLine > LLine) then
begin
LCodeFoldingRanges[k] := LCodeFoldingRange;
Inc(k);
Break;
end
end;
end;
for i := AFirstRow to ALastRow do
begin
LLine := GetDisplayTextLineNumber(i);
LIncY := Odd(FLineHeight) and not Odd(LLine);
for j := 0 to k - 1 do
begin
LCodeFoldingRange := LCodeFoldingRanges[j];
if Assigned(LCodeFoldingRange) then
if not LCodeFoldingRange.Collapsed and not LCodeFoldingRange.ParentCollapsed and
(LCodeFoldingRange.FromLine < LLine) and (LCodeFoldingRange.ToLine > LLine) then
begin
if not LCodeFoldingRange.RegionItem.ShowGuideLine then
Continue;
X := GetLineIndentLevel(LCodeFoldingRange.ToLine - 1);
X := X * FTextDrawer.CharWidth;
if (X - LScrolledXBy > 0) and not AMinimap or AMinimap and (X > 0) then
begin
if FMinimap.Align = maRight then
begin
if AMinimap then
X := ClientRect.Width - FMinimap.GetWidth + X
else
X := FLeftMargin.GetWidth + FCodeFolding.GetWidth + X - LScrolledXBy;
end
else
if not AMinimap then
X := FMinimap.GetWidth + FLeftMargin.GetWidth + FCodeFolding.GetWidth + X - LScrolledXBy;
if FSearch.Map.Align = saLeft then
Inc(X, FSearch.Map.GetWidth);
if (LDeepestLevel = LCodeFoldingRange.IndentLevel) and
(LCurrentLine >= LCodeFoldingRange.FromLine) and (LCurrentLine <= LCodeFoldingRange.ToLine) and
(cfoHighlightIndentGuides in FCodeFolding.Options) then
begin
Canvas.Pen.Color := FCodeFolding.Colors.IndentHighlight;
Canvas.MoveTo(X, Y);
Canvas.LineTo(X, Y + FLineHeight);
end
else
begin
Canvas.Pen.Color := FCodeFolding.Colors.Indent;
Z := Y;
if LIncY then
Inc(Z);
while Z < Y + FLineHeight do
begin
Canvas.MoveTo(X, Z);
Inc(Z);
Canvas.LineTo(X, Z);
Inc(Z);
end;
end;
end;
end;
end;
Inc(Y, FLineHeight);
end;
SetLength(LCodeFoldingRanges, 0);
Canvas.Pen.Color := LOldColor;
end;
procedure TBCBaseEditor.PaintLeftMargin(const AClipRect: TRect; AFirstLine, ALastTextLine, ALastLine: Integer);
var
LLine, LPreviousLine: Integer;
LLineRect: TRect;
procedure DrawMark(ABookmark: TBCEditorBookmark; var ALeftMarginOffset: Integer; AMarkRow: Integer);
var
Y: Integer;
begin
if not ABookmark.InternalImage and Assigned(FLeftMargin.Bookmarks.Images) then
begin
if ABookmark.ImageIndex <= FLeftMargin.Bookmarks.Images.Count then
begin
ALeftMarginOffset := 0;
if FLineHeight > FLeftMargin.Bookmarks.Images.Height then
Y := FLineHeight shr 1 - FLeftMargin.Bookmarks.Images.Height shr 1
else
Y := 0;
with FLeftMargin.Bookmarks do
Images.Draw(Canvas, AClipRect.Left + Panel.LeftMargin + ALeftMarginOffset,
(AMarkRow - TopLine) * FLineHeight + Y, ABookmark.ImageIndex);
Inc(ALeftMarginOffset, FLeftMargin.Bookmarks.Panel.OtherMarkXOffset);
end;
end
else
begin
if ABookmark.ImageIndex in [0 .. 8] then
begin
if not Assigned(FInternalBookmarkImage) then
FInternalBookmarkImage := TBCEditorInternalImage.Create(HINSTANCE, BCEDITOR_BOOKMARK_IMAGES, 9);
if ALeftMarginOffset = 0 then
FInternalBookmarkImage.Draw(Canvas, ABookmark.ImageIndex,
AClipRect.Left + FLeftMargin.Bookmarks.Panel.LeftMargin + ALeftMarginOffset,
(AMarkRow - TopLine) * FLineHeight, FLineHeight, clFuchsia);
Inc(ALeftMarginOffset, FLeftMargin.Bookmarks.Panel.OtherMarkXOffset);
end;
end;
end;
procedure PaintLineNumbers;
var
i, LTop: Integer;
LLineNumber: string;
LTextSize: TSize;
LLeftMarginWidth: Integer;
LOldColor: TColor;
LLastTextLine: Integer;
begin
if FLeftMargin.LineNumbers.Visible then
begin
FTextDrawer.SetBaseFont(FLeftMargin.Font);
try
FTextDrawer.SetForegroundColor(FLeftMargin.Font.Color);
LLineRect := AClipRect;
LLastTextLine := ALastTextLine;
if lnoAfterLastLine in FLeftMargin.LineNumbers.Options then
LLastTextLine := ALastLine;
for i := AFirstLine to LLastTextLine do
begin
LLine := GetDisplayTextLineNumber(i);
FTextDrawer.SetBackgroundColor(FLeftMargin.Colors.Background);
if (GetTextCaretY + 1 = LLine) and (FLeftMargin.Colors.ActiveLineBackground <> clNone) then
FTextDrawer.SetBackgroundColor(FLeftMargin.Colors.ActiveLineBackground);
LLineRect.Top := (i - TopLine) * FLineHeight;
LLineRect.Bottom := LLineRect.Top + FLineHeight;
LLineNumber := '';
LPreviousLine := LLine;
if FWordWrap.Enabled then
LPreviousLine := GetDisplayTextLineNumber(i - 1);
if not FWordWrap.Enabled or FWordWrap.Enabled and (LPreviousLine <> LLine) then
begin
LLineNumber := FLeftMargin.FormatLineNumber(LLine);
if GetTextCaretY + 1 <> LLine then
if (lnoIntens in LeftMargin.LineNumbers.Options) and
(LLineNumber[Length(LLineNumber)] <> '0') and (i <> LeftMargin.LineNumbers.StartFrom) then
begin
LLeftMarginWidth := LLineRect.Left + FLeftMargin.GetWidth - FLeftMargin.LineState.Width - 1;
LOldColor := Canvas.Pen.Color;
Canvas.Pen.Color := LeftMargin.Colors.LineNumberLine;
LTop := LLineRect.Top + ((FLineHeight - 1) div 2);
if LLine mod 5 = 0 then
Canvas.MoveTo(LLeftMarginWidth - FLeftMarginCharWidth + ((FLeftMarginCharWidth - 9) div 2), LTop)
else
Canvas.MoveTo(LLeftMarginWidth - FLeftMarginCharWidth + ((FLeftMarginCharWidth - 2) div 2), LTop);
Canvas.LineTo(LLeftMarginWidth - ((FLeftMarginCharWidth - 1) div 2), LTop);
Canvas.Pen.Color := LOldColor;
Continue;
end;
end;
GetTextExtentPoint32(Canvas.Handle, PChar(LLineNumber), Length(LLineNumber), LTextSize);
Winapi.Windows.ExtTextOut(Canvas.Handle, LLineRect.Left + (FLeftMargin.GetWidth - FLeftMargin.LineState.Width - 2) - LTextSize.cx,
LLineRect.Top + ((FLineHeight - Integer(LTextSize.cy)) div 2), ETO_OPAQUE, @LLineRect, PChar(LLineNumber),
Length(LLineNumber), nil);
end;
FTextDrawer.SetBackgroundColor(FLeftMargin.Colors.Background);
{ erase the remaining area }
if AClipRect.Bottom > LLineRect.Bottom then
begin
LLineRect.Top := LLineRect.Bottom;
LLineRect.Bottom := AClipRect.Bottom;
with LLineRect do
FTextDrawer.ExtTextOut(Left, Top, ETO_OPAQUE, LLineRect, '', 0);
end;
finally
FTextDrawer.SetBaseFont(Self.Font);
end;
end;
end;
procedure PaintBookmarkPanel;
var
i: Integer;
LPanelRect: TRect;
LPanelActiveLineRect: TRect;
LOldColor: TColor;
begin
LOldColor := Canvas.Brush.Color;
if FLeftMargin.Bookmarks.Panel.Visible then
begin
LPanelRect := System.Types.Rect(AClipRect.Left, 0, AClipRect.Left + FLeftMargin.Bookmarks.Panel.Width, ClientHeight);
if FLeftMargin.Colors.BookmarkPanelBackground <> clNone then
begin
Canvas.Brush.Color := FLeftMargin.Colors.BookmarkPanelBackground;
PatBlt(Canvas.Handle, LPanelRect.Left, LPanelRect.Top, LPanelRect.Width, LPanelRect.Height, PATCOPY); { fill bookmark panel rect }
end;
if FLeftMargin.Colors.ActiveLineBackground <> clNone then
begin
for i := AFirstLine to ALastTextLine do
begin
LLine := GetDisplayTextLineNumber(i);
if LLine = GetTextCaretY + 1 then
begin
LPanelActiveLineRect := System.Types.Rect(AClipRect.Left, (i - TopLine) * FLineHeight, AClipRect.Left + FLeftMargin.Bookmarks.Panel.Width,
(i - TopLine + 1) * FLineHeight);
Canvas.Brush.Color := FLeftMargin.Colors.ActiveLineBackground;
PatBlt(Canvas.Handle, LPanelActiveLineRect.Left, LPanelActiveLineRect.Top, LPanelActiveLineRect.Width,
LPanelActiveLineRect.Height, PATCOPY); { fill bookmark panel active line rect}
end;
end;
end;
if Assigned(FOnBeforeBookmarkPanelPaint) then
FOnBeforeBookmarkPanelPaint(Self, Canvas, LPanelRect, AFirstLine, ALastLine);
end;
Canvas.Brush.Color := LOldColor;
end;
procedure PaintWordWrapIndicator;
var
i: Integer;
begin
if FWordWrap.Enabled and FWordWrap.Indicator.Visible then
for i := AFirstLine to ALastLine do
begin
LLine := GetDisplayTextLineNumber(i);
LPreviousLine := GetDisplayTextLineNumber(i - 1);
if LLine = LPreviousLine then
FWordWrap.Indicator.Draw(Canvas, AClipRect.Left + FWordWrap.Indicator.Left, (i - TopLine) * FLineHeight,
FLineHeight);
end;
end;
procedure PaintBorder;
begin
if (FLeftMargin.Border.Style <> mbsNone) and (AClipRect.Right >= AClipRect.Left + FLeftMargin.GetWidth - 2) then
with Canvas do
begin
Pen.Color := FLeftMargin.Colors.Border;
Pen.Width := 1;
if FLeftMargin.Border.Style = mbsMiddle then
begin
MoveTo(AClipRect.Left + FLeftMargin.GetWidth - 2, AClipRect.Top);
LineTo(AClipRect.Left + FLeftMargin.GetWidth - 2, AClipRect.Bottom);
Pen.Color := FLeftMargin.Colors.Background;
end;
MoveTo(AClipRect.Left + FLeftMargin.GetWidth - 1, AClipRect.Top);
LineTo(AClipRect.Left + FLeftMargin.GetWidth - 1, AClipRect.Bottom);
end;
end;
procedure PaintBookmarks;
var
i, j: Integer;
LLeftMarginOffsets: PIntegerArray;
LHasOtherMarks: Boolean;
LBookmark: TBCEditorBookmark;
LBookmarkLine: Integer;
begin
if FLeftMargin.Bookmarks.Visible and FLeftMargin.Bookmarks.Visible and (Marks.Count > 0) and
(ALastLine >= AFirstLine) then
begin
LLeftMarginOffsets := AllocMem((ALastLine - AFirstLine + 1) * SizeOf(Integer));
try
LHasOtherMarks := False;
for i := AFirstLine to ALastLine do
begin
LBookmarkLine := GetDisplayTextLineNumber(i);
for j := 0 to Marks.Count - 1 do
begin
LBookmark := Marks[j];
if LBookmark.Line + 1 = LBookmarkLine then
if LBookmark.Visible then
begin
if not LBookmark.IsBookmark then
LHasOtherMarks := True
else
if not FCodeFolding.Visible or FCodeFolding.Visible then
DrawMark(LBookmark, LLeftMarginOffsets[ALastLine - i], LBookmarkLine);
end;
end;
if LHasOtherMarks then
for j := 0 to Marks.Count - 1 do
begin
LBookmark := Marks[j];
if LBookmark.Line + 1 = LBookmarkLine then
if LBookmark.Visible and not LBookmark.IsBookmark then
if not FCodeFolding.Visible or FCodeFolding.Visible then
DrawMark(LBookmark, LLeftMarginOffsets[ALastLine - i], LBookmarkLine);
end;
end;
finally
FreeMem(LLeftMarginOffsets);
end;
end;
end;
procedure PaintActiveLineIndicator;
begin
if FActiveLine.Visible and FActiveLine.Indicator.Visible then
FActiveLine.Indicator.Draw(Canvas, AClipRect.Left + FActiveLine.Indicator.Left, (DisplayCaretY - 1) * FLineHeight,
FLineHeight);
end;
procedure PaintSyncEditIndicator;
var
LDisplayPosition: TBCEditorDisplayPosition;
begin
if FSyncEdit.Enabled and not FSyncEdit.Active and FSyncEdit.Activator.Visible and SelectionAvailable then
begin
LDisplayPosition := TextToDisplayPosition(SelectionEndPosition);
FSyncEdit.Activator.Draw(Canvas, AClipRect.Left + FActiveLine.Indicator.Left,
(LDisplayPosition.Row - TopLine) * FLineHeight, FLineHeight);
end;
end;
procedure PaintLineState;
var
i: Integer;
LLineStateRect: TRect;
LPEditorLineAttribute: PBCEditorLineAttribute;
LOldColor: TColor;
begin
if FLeftMargin.LineState.Enabled then
begin
LOldColor := Canvas.Brush.Color;
LLineStateRect.Left := AClipRect.Left + FLeftMargin.GetWidth - FLeftMargin.LineState.Width - 1;
LLineStateRect.Right := LLineStateRect.Left + FLeftMargin.LineState.Width;
for i := AFirstLine to ALastTextLine do
begin
LLine := GetDisplayTextLineNumber(i);
LPEditorLineAttribute := FLines.Attributes[LLine - 1];
if Assigned(LPEditorLineAttribute) and (LPEditorLineAttribute.LineState <> lsNone) then
begin
LLineStateRect.Top := (i - TopLine) * FLineHeight;
LLineStateRect.Bottom := LLineStateRect.Top + FLineHeight;
if LPEditorLineAttribute.LineState = lsNormal then
Canvas.Brush.Color := FLeftMargin.Colors.LineStateNormal
else
Canvas.Brush.Color := FLeftMargin.Colors.LineStateModified;
PatBlt(Canvas.Handle, LLineStateRect.Left, LLineStateRect.Top, LLineStateRect.Width, LLineStateRect.Height,
PATCOPY); { fill line state rect }
end;
end;
Canvas.Brush.Color := LOldColor;
end;
end;
procedure PaintBookmarkPanelLine;
var
i: Integer;
LPanelRect: TRect;
begin
if FLeftMargin.Bookmarks.Panel.Visible then
begin
if Assigned(FOnBookmarkPanelLinePaint) then
begin
LPanelRect.Left := AClipRect.Left;
LPanelRect.Top := 0;
LPanelRect.Right := FLeftMargin.Bookmarks.Panel.Width;
LPanelRect.Bottom := AClipRect.Bottom;
for i := AFirstLine to ALastLine do
begin
LLine := i;
if FCodeFolding.Visible then
LLine := GetDisplayTextLineNumber(LLine);
LLineRect.Left := LPanelRect.Left;
LLineRect.Right := LPanelRect.Right;
LLineRect.Top := (LLine - TopLine) * FLineHeight;
LLineRect.Bottom := LLineRect.Top + FLineHeight;
FOnBookmarkPanelLinePaint(Self, Canvas, LLineRect, LLine);
end;
end;
if Assigned(FOnAfterBookmarkPanelPaint) then
FOnAfterBookmarkPanelPaint(Self, Canvas, LPanelRect, AFirstLine, ALastLine);
end;
end;
begin
Canvas.Brush.Color := FLeftMargin.Colors.Background;
PatBlt(Canvas.Handle, AClipRect.Left, AClipRect.Top, AClipRect.Width, AClipRect.Height, PATCOPY); { fill left margin rect }
PaintLineNumbers;
PaintBookmarkPanel;
PaintWordWrapIndicator;
PaintBorder;
PaintBookmarks;
PaintActiveLineIndicator;
PaintSyncEditIndicator;
PaintLineState;
PaintBookmarkPanelLine;
end;
procedure TBCBaseEditor.PaintMinimapIndicator(AClipRect: TRect);
var
LTop: Integer;
begin
with FMinimapIndicatorBitmap do
begin
Height := 0;
Canvas.Brush.Color := FMinimap.Colors.VisibleLines;
Width := AClipRect.Width;
Height := FVisibleLines * FMinimap.CharHeight;
end;
FMinimapIndicatorBlendFunction.SourceConstantAlpha := FMinimap.Indicator.AlphaBlending;
LTop := (FTopLine - FMinimap.TopLine) * FMinimap.CharHeight;
if ioInvertBlending in FMinimap.Indicator.Options then
begin
if LTop > 0 then
with FMinimapIndicatorBitmap do
AlphaBlend(Self.Canvas.Handle, AClipRect.Left, 0, Width, LTop, Canvas.Handle, 0, 0, Width, Height,
FMinimapIndicatorBlendFunction);
with FMinimapIndicatorBitmap do
AlphaBlend(Self.Canvas.Handle, AClipRect.Left, LTop + Height, Width, AClipRect.Bottom, Canvas.Handle, 0, 0, Width, Height,
FMinimapIndicatorBlendFunction);
end
else
with FMinimapIndicatorBitmap do
AlphaBlend(Self.Canvas.Handle, AClipRect.Left, LTop, Width, Height, Canvas.Handle, 0, 0, Width, Height,
FMinimapIndicatorBlendFunction);
if ioShowBorder in FMinimap.Indicator.Options then
begin
Canvas.Pen.Color := FMinimap.Colors.VisibleLines;
Canvas.Brush.Style := bsClear;
Canvas.Rectangle(Rect(AClipRect.Left, LTop, AClipRect.Right, LTop + FMinimapIndicatorBitmap.Height));
end;
end;
procedure TBCBaseEditor.PaintMinimapShadow(AClipRect: TRect);
var
LRow, LColumn: Integer;
LPixel: PBCEditorQuadColor;
LAlpha: Single;
LLeft: Integer;
begin
FMinimapShadowBitmap.Height := 0;
FMinimapShadowBitmap.Height := AClipRect.Height; //FI:W508 FixInsight ignore
for LRow := 0 to FMinimapShadowBitmap.Height - 1 do
begin
LPixel := FMinimapShadowBitmap.Scanline[LRow];
for LColumn := 0 to FMinimapShadowBitmap.Width - 1 do
begin
LAlpha := FMinimapShadowAlphaArray[LColumn];
LPixel.Alpha := FMinimapShadowAlphaByteArray[LColumn];
LPixel.Red := Round(LPixel.Red * LAlpha);
LPixel.Green := Round(LPixel.Green * LAlpha);
LPixel.Blue := Round(LPixel.Blue * LAlpha);
Inc(LPixel);
end;
end;
if FMinimap.Align = maLeft then
LLeft := AClipRect.Left
else
LLeft := AClipRect.Right - FMinimapShadowBitmap.Width;
AlphaBlend(Canvas.Handle, LLeft, 0, FMinimapShadowBitmap.Width,
FMinimapShadowBitmap.Height, FMinimapShadowBitmap.Canvas.Handle, 0, 0, FMinimapShadowBitmap.Width,
FMinimapShadowBitmap.Height, FMinimapShadowBlendFunction);
end;
procedure TBCBaseEditor.PaintMouseMoveScrollPoint;
var
LHalfWidth: Integer;
begin
LHalfWidth := FScroll.Indicator.Width div 2;
FScroll.Indicator.Draw(Canvas, FMouseMoveScrollingPoint.X - LHalfWidth, FMouseMoveScrollingPoint.Y - LHalfWidth);
end;
procedure TBCBaseEditor.PaintRightMarginMove;
var
LRightMarginPosition: Integer;
LOldStyle: TBrushStyle;
begin
with Canvas do
begin
Pen.Width := 1;
Pen.Style := psDot;
Pen.Color := FRightMargin.Colors.MovingEdge;
LOldStyle := Brush.Style;
Brush.Style := bsClear;
MoveTo(FRightMarginMovePosition, 0);
LineTo(FRightMarginMovePosition, ClientHeight);
Brush.Style := LOldStyle;
LRightMarginPosition := RowColumnToPixels(GetDisplayPosition(FRightMargin.Position + 1, 0)).X;
Pen.Style := psSolid;
Pen.Color := FRightMargin.Colors.Edge;
MoveTo(LRightMarginPosition, 0);
LineTo(LRightMarginPosition, ClientHeight);
end;
end;
procedure TBCBaseEditor.PaintSearchMap(AClipRect: TRect);
var
i, j: Integer;
LHeight: Double;
{$IFDEF USE_VCL_STYLES}
LStyles: TCustomStyleServices;
{$ENDIF}
begin
if not Assigned(FSearch.Lines) then
Exit;
if not Assigned(FSearchEngine) then
Exit;
if (FSearchEngine.ResultCount = 0) and not (soHighlightSimilarTerms in FSelection.Options) then
Exit;
{$IFDEF USE_VCL_STYLES}
LStyles := StyleServices;
{$ENDIF}
{ Background }
if FSearch.Map.Colors.Background <> clNone then
Canvas.Brush.Color := FSearch.Map.Colors.Background
else
{$IFDEF USE_VCL_STYLES}
if LStyles.Enabled then
Canvas.Brush.Color := LStyles.GetStyleColor(scPanel)
else
{$ENDIF}
Canvas.Brush.Color := FBackgroundColor;
PatBlt(Canvas.Handle, AClipRect.Left, AClipRect.Top, AClipRect.Width, AClipRect.Height, PATCOPY); { fill search map rect }
{ Lines in window }
LHeight := ClientRect.Height / Max(Lines.Count, 1);
AClipRect.Top := Round((TopLine - 1) * LHeight);
AClipRect.Bottom := Max(Round((TopLine - 1 + VisibleLines) * LHeight), AClipRect.Top + 1);
Canvas.Brush.Color := FBackgroundColor;
PatBlt(Canvas.Handle, AClipRect.Left, AClipRect.Top, AClipRect.Width, AClipRect.Height, PATCOPY); { fill lines in window rect }
{ draw lines }
if FSearch.Map.Colors.Foreground <> clNone then
Canvas.Pen.Color := FSearch.Map.Colors.Foreground
else
{$IFDEF USE_VCL_STYLES}
if LStyles.Enabled then
Canvas.Pen.Color := LStyles.GetSystemColor(clHighlight)
else
{$ENDIF}
Canvas.Pen.Color := clHighlight;
Canvas.Pen.Width := 1;
Canvas.Pen.Style := psSolid;
for i := 0 to FSearch.Lines.Count - 1 do
begin
j := Round((PBCEditorTextPosition(FSearch.Lines.Items[i])^.Line - 1) * LHeight);
Canvas.MoveTo(AClipRect.Left, j);
Canvas.LineTo(AClipRect.Right, j);
Canvas.MoveTo(AClipRect.Left, j + 1);
Canvas.LineTo(AClipRect.Right, j + 1);
end;
{ draw active line }
if moShowActiveLine in FSearch.Map.Options then
begin
if FSearch.Map.Colors.ActiveLine <> clNone then
Canvas.Pen.Color := FSearch.Map.Colors.ActiveLine
else
Canvas.Pen.Color := FActiveLine.Color;
j := Round((DisplayCaretY - 1) * LHeight);
Canvas.MoveTo(AClipRect.Left, j);
Canvas.LineTo(AClipRect.Right, j);
Canvas.MoveTo(AClipRect.Left, j + 1);
Canvas.LineTo(AClipRect.Right, j + 1);
end;
end;
procedure TBCBaseEditor.PaintSearchResults;
var
i: Integer;
LTextPosition: TBCEditorTextPosition;
LDisplayPosition: TBCEditorDisplayPosition;
LRect: TRect;
LText: string;
LLength, LLeftMargin, LCharsOutside: Integer;
LSelectionBeginPosition, LSelectionEndPosition: TBCEditorTextPosition;
begin
if not Assigned(FSearch.Lines) then
Exit;
if not Assigned(FSearchEngine) then
Exit;
if FSearchEngine.ResultCount = 0 then
Exit;
if FSearch.Highlighter.Colors.Foreground <> clNone then
FTextDrawer.ForegroundColor := FSearch.Highlighter.Colors.Foreground;
FTextDrawer.BackgroundColor := FSearch.Highlighter.Colors.Background;
LLength := Length(FSearch.SearchText);
LLeftMargin := FLeftMargin.GetWidth + FCodeFolding.GetWidth;
if FMinimap.Align = maLeft then
Inc(LLeftMargin, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LLeftMargin, FSearch.Map.GetWidth);
for i := 0 to FSearch.Lines.Count - 1 do
begin
LTextPosition := PBCEditorTextPosition(FSearch.Lines.Items[i])^;
if LTextPosition.Line + 1 > TopLine + VisibleLines then
Exit
else
if LTextPosition.Line + 1 >= TopLine then
begin
LSelectionBeginPosition := SelectionBeginPosition;
LSelectionEndPosition := SelectionEndPosition;
if (LSelectionBeginPosition.Line = LTextPosition.Line) and
(LSelectionBeginPosition.Char >= LTextPosition.Char) and
(LSelectionBeginPosition.Char <= LTextPosition.Char + LLength) or
(LSelectionEndPosition.Line = LTextPosition.Line) and
(LSelectionEndPosition.Char >= LTextPosition.Char) and
(LSelectionEndPosition.Char <= LTextPosition.Char + LLength) then
Continue
else
begin
LText := Copy(FLines[LTextPosition.Line], LTextPosition.Char, LLength);
LRect.Top := (LTextPosition.Line - TopLine + 1) * LineHeight;
LRect.Bottom := LRect.Top + LineHeight;
LDisplayPosition := TextToDisplayPosition(LTextPosition);
LRect.Left := LLeftMargin + (LDisplayPosition.Column - FLeftChar) * FTextDrawer.CharWidth;
LCharsOutside := Max(0, (LLeftMargin - LRect.Left) div FTextDrawer.CharWidth);
LRect.Left := Max(LLeftMargin, LRect.Left) + 1;
if LLength - LCharsOutside > 0 then
begin
if LCharsOutside > 0 then
Delete(LText, 1, LCharsOutside);
LRect.Right := LRect.Left + (LLength - LCharsOutside) * FTextDrawer.CharWidth;
FTextDrawer.ExtTextOut(LRect.Left, LRect.Top, ETO_OPAQUE or ETO_CLIPPED, LRect, PChar(LText), (LLength - LCharsOutside));
end;
end;
end;
end;
end;
procedure TBCBaseEditor.PaintSpecialChars(ALine, AFirstColumn: Integer; ALineRect: TRect);
var
i: Integer;
LPLine: PChar;
LLineLength: Integer;
LCharWidth, LTextHeight: Integer;
LDisplayCharPosition, X, Y, LLeftMargin: Integer;
LCharRect: TRect;
LPilcrow: string;
LWidth: Integer;
LPenColor: TColor;
LVisibleChars: Integer;
begin
if FSpecialChars.Visible then
begin
LPLine := PChar(FLines[ALine - 1]);
LLineLength := Length(FLines[ALine - 1]);
if LLineLength - AFirstColumn < 0 then
Exit;
LDisplayCharPosition := 1;
while LDisplayCharPosition < AFirstColumn do
begin
if LPLine^ = BCEDITOR_TAB_CHAR then
begin
if toColumns in FTabs.Options then
Inc(LDisplayCharPosition, FTabs.Width - (LDisplayCharPosition - 1) mod FTabs.Width)
else
Inc(LDisplayCharPosition, FTabs.Width)
end
else
Inc(LDisplayCharPosition);
Inc(LPLine);
end;
LDisplayCharPosition := 1;
LCharWidth := FCharWidth;
if scoMiddleColor in FSpecialChars.Options then
LPenColor := MiddleColor(FHighlighter.MainRules.Attribute.Background, FHighlighter.MainRules.Attribute.Foreground)
else
if scoTextColor in FSpecialChars.Options then
LPenColor := FHighlighter.MainRules.Attribute.Foreground
else
LPenColor := FSpecialChars.Color;
Canvas.Pen.Color := LPenColor;
LTextHeight := Max(FLineHeight - 8, 0) shr 4;
with ALineRect do
X := Top + (Bottom - Top) shr 1 - 1;
LLeftMargin := FLeftMargin.GetWidth + FCodeFolding.GetWidth;
if FMinimap.Align = maLeft then
Inc(LLeftMargin, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LLeftMargin, FSearch.Map.GetWidth);
LVisibleChars := GetVisibleChars;
while (LPLine^ <> BCEDITOR_NONE_CHAR) and (LDisplayCharPosition <= LVisibleChars) do
begin
if LPLine^ = BCEDITOR_SPACE_CHAR then
begin
with LCharRect do
begin
Top := X - LTextHeight;
Bottom := X + 2 + LTextHeight;
Left := LLeftMargin + LDisplayCharPosition * LCharWidth - LCharWidth div 2 - 1;
Right := Left + 2;
end;
with Canvas, LCharRect do
Rectangle(Left, Top, Right, Bottom);
end;
if LPLine^ = BCEDITOR_TAB_CHAR then
begin
with LCharRect do
begin
Top := ALineRect.Top;
Bottom := ALineRect.Bottom;
Left := LLeftMargin + (LDisplayCharPosition - 1) * LCharWidth + LCharWidth div 2 + 1;
if toColumns in FTabs.Options then
Right := Left + (FTabs.Width - (LDisplayCharPosition - 1) mod FTabs.Width) * LCharWidth - 6
else
Right := Left + FTabs.Width * LCharWidth - 6;
end;
with Canvas do
begin
Y := (ALineRect.Bottom - ALineRect.Top) shr 1;
{ Line }
if FSpecialChars.Style = scsDot then
begin
i := LCharRect.Left - 2;
if (LDisplayCharPosition - 1) mod FTabs.Width = 0 then
Inc(i);
if Odd(FTabs.Width) then
Inc(i);
while i < LCharRect.Right do
begin
MoveTo(i, LCharRect.Top + Y);
LineTo(i + 1, LCharRect.Top + Y);
Inc(i, 2);
end;
end
else
if FSpecialChars.Style = scsSolid then
begin
MoveTo(LCharRect.Left - 2, LCharRect.Top + Y);
LineTo(LCharRect.Right + 1, LCharRect.Top + Y);
end;
{ Arrow }
i := LCharRect.Right + 1;
MoveTo(i, LCharRect.Top + Y);
LineTo(i - (Y shr 1), LCharRect.Top + Y - (Y shr 1));
MoveTo(i, LCharRect.Top + Y);
LineTo(i - (Y shr 1), LCharRect.Top + Y + (Y shr 1));
end;
if toColumns in FTabs.Options then
Inc(LDisplayCharPosition, FTabs.Width - (LDisplayCharPosition - 1) mod FTabs.Width)
else
Inc(LDisplayCharPosition, FTabs.Width);
end
else
Inc(LDisplayCharPosition, Length(LPLine^));
Inc(LPLine);
end;
if FSpecialChars.EndOfLine.Visible and (ALine <> FLineNumbersCount) and (LLineLength - AFirstColumn < LVisibleChars) then
with Canvas do
begin
Pen.Color := LPenColor;
LCharRect.Top := ALineRect.Top;
if FSpecialChars.EndOfLine.Style = eolPilcrow then
LCharRect.Bottom := ALineRect.Bottom
else
LCharRect.Bottom := ALineRect.Bottom - 3;
LCharRect.Left := LLeftMargin + (LDisplayCharPosition - 1) * LCharWidth;
if FSpecialChars.EndOfLine.Style = eolEnter then
LCharRect.Left := LCharRect.Left + 4;
if FSpecialChars.EndOfLine.Style = eolPilcrow then
begin
LCharRect.Left := LCharRect.Left + 2;
LCharRect.Right := LCharRect.Left + LCharWidth
end
else
LCharRect.Right := LCharRect.Left + FTabs.Width * LCharWidth - 3;
LWidth := 0;
if FMinimap.Align = maLeft then
Inc(LWidth, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LWidth, FSearch.Map.GetWidth);
if LCharRect.Left > FLeftMargin.GetWidth + FCodeFolding.GetWidth + LWidth then
begin
if FSpecialChars.EndOfLine.Style = eolPilcrow then
begin
if IsTextPositionInSelection(GetTextPosition(LDisplayCharPosition, ALine - 1)) then
FTextDrawer.BackgroundColor := FSelection.Colors.Background
else
if GetTextCaretY = ALine - 1 then
FTextDrawer.BackgroundColor := FActiveLine.Color
else
FTextDrawer.BackgroundColor := FBackgroundColor;
FTextDrawer.ForegroundColor := Canvas.Pen.Color;
FTextDrawer.Style := [];
LPilcrow := Char($00B6);
FTextDrawer.ExtTextOut(LCharRect.Left, LCharRect.Top, ETO_OPAQUE or ETO_CLIPPED, LCharRect, PChar(LPilcrow), 1);
end
else
if FSpecialChars.EndOfLine.Style = eolArrow then
begin
Y := LCharRect.Top + 2;
if FSpecialChars.Style = scsDot then
begin
while Y < LCharRect.Bottom do
begin
MoveTo(LCharRect.Left + 6, Y);
LineTo(LCharRect.Left + 6, Y + 1);
Inc(Y, 2);
end;
end;
{ Solid }
if FSpecialChars.Style = scsSolid then
begin
MoveTo(LCharRect.Left + 6, Y);
Y := LCharRect.Bottom;
LineTo(LCharRect.Left + 6, Y + 1);
end;
MoveTo(LCharRect.Left + 6, Y);
LineTo(LCharRect.Left + 3, Y - 3);
MoveTo(LCharRect.Left + 6, Y);
LineTo(LCharRect.Left + 9, Y - 3);
end
else
begin
Y := LCharRect.Top + FLineHeight div 2 - 1;
MoveTo(LCharRect.Left, Y);
LineTo(LCharRect.Left + 11, Y);
MoveTo(LCharRect.Left + 1, Y - 1);
LineTo(LCharRect.Left + 1, Y + 2);
MoveTo(LCharRect.Left + 2, Y - 2);
LineTo(LCharRect.Left + 2, Y + 3);
MoveTo(LCharRect.Left + 3, Y - 3);
LineTo(LCharRect.Left + 3, Y + 4);
MoveTo(LCharRect.Left + 10, Y - 3);
LineTo(LCharRect.Left + 10, Y);
end;
end;
end;
end;
end;
procedure TBCBaseEditor.PaintSyncItems;
var
i: Integer;
LTextPosition: TBCEditorTextPosition;
LLength, LLeftMargin: Integer;
procedure DrawRectangle(ATextPosition: TBCEditorTextPosition);
var
LRect: TRect;
LDisplayPosition: TBCEditorDisplayPosition;
LCharsOutside: Integer;
begin
LRect.Top := (ATextPosition.Line - TopLine + 1) * LineHeight;
LRect.Bottom := LRect.Top + LineHeight;
LDisplayPosition := TextToDisplayPosition(ATextPosition);
LRect.Left := LLeftMargin + (LDisplayPosition.Column - FLeftChar) * FTextDrawer.CharWidth;
LCharsOutside := Max(0, (LLeftMargin - LRect.Left) div FTextDrawer.CharWidth);
LRect.Left := Max(LLeftMargin, LRect.Left);
if LLength - LCharsOutside > 0 then
begin
LRect.Right := LRect.Left + (LLength - LCharsOutside) * FTextDrawer.CharWidth + 2;
Canvas.Rectangle(LRect);
end;
end;
begin
if not Assigned(FSyncEdit.SyncItems) then
Exit;
LLength := FSyncEdit.EditEndPosition.Char - FSyncEdit.EditBeginPosition.Char;
LLeftMargin := FLeftMargin.GetWidth + FCodeFolding.GetWidth;
if FMinimap.Align = maLeft then
Inc(LLeftMargin, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LLeftMargin, FSearch.Map.GetWidth);
Canvas.Brush.Style := bsClear;
Canvas.Pen.Color := FSyncEdit.Colors.EditBorder;
DrawRectangle(FSyncEdit.EditBeginPosition);
for i := 0 to FSyncEdit.SyncItems.Count - 1 do
begin
LTextPosition := PBCEditorTextPosition(FSyncEdit.SyncItems.Items[i])^;
if LTextPosition.Line + 1 > TopLine + VisibleLines then
Exit
else
if LTextPosition.Line + 1 >= TopLine then
begin
Canvas.Pen.Color := FSyncEdit.Colors.WordBorder;
DrawRectangle(LTextPosition);
end;
end;
end;
procedure TBCBaseEditor.PaintTextLines(AClipRect: TRect; AFirstRow, ALastRow: Integer; AMinimap: Boolean);
var
LAnySelection: Boolean;
LDisplayLine, LCurrentLine: Integer;
LFirstLine: Integer;
LForegroundColor, LBackgroundColor: TColor;
LIsSelectionInsideLine: Boolean;
LIsLineSelected, LIsCurrentLine, LIsSyncEditBlock: Boolean;
LLastLine: Integer;
LLineRect, LTokenRect: TRect;
LLineSelectionStart, LLineSelectionEnd: Integer;
LRightMarginPosition: Integer;
LSelectionEndPosition: TBCEditorDisplayPosition;
LSelectionBeginPosition: TBCEditorDisplayPosition;
LTokenHelper: TBCEditorTokenHelper;
LCustomLineColors: Boolean;
LCustomForegroundColor: TColor;
LCustomBackgroundColor: TColor;
LFirstChar, LLastChar: Integer;
LBookmarkOnCurrentLine: Boolean;
LVisibleChars: Integer;
function IsBookmarkOnCurrentLine: Boolean;
var
i: Integer;
LMark: TBCEditorBookmark;
begin
Result := False;
for i := 0 to 8 do
begin
LMark := FBookmarks[i];
if Assigned(LMark) then
if LMark.Line = LCurrentLine - 1 then
Exit(True);
end;
end;
function GetBackgroundColor: TColor;
var
LHighlighterAttribute: TBCEditorHighlighterAttribute;
begin
if AMinimap and (moShowBookmarks in FMinimap.Options) and LBookmarkOnCurrentLine then
Result := FMinimap.Colors.Bookmark
else
if LIsCurrentLine and FActiveLine.Visible and (FActiveLine.Color <> clNone) then
Result := FActiveLine.Color
else
if LIsSyncEditBlock then
Result := FSyncEdit.Colors.Background
else
if AMinimap and (FMinimap.Colors.Background <> clNone) then
Result := FMinimap.Colors.Background
else
begin
Result := FBackgroundColor;
if Assigned(FHighlighter) then
begin
LHighlighterAttribute := FHighlighter.GetCurrentRangeAttribute;
if Assigned(LHighlighterAttribute) and (LHighlighterAttribute.Background <> clNone) then
Result := LHighlighterAttribute.Background;
end;
end;
end;
procedure ComputeSelectionInfo;
begin
LAnySelection := SelectionAvailable;
if LAnySelection then
if (FSelectionEndPosition.Line < FSelectionBeginPosition.Line) or
((FSelectionEndPosition.Line = FSelectionBeginPosition.Line) and (FSelectionEndPosition.Char < FSelectionBeginPosition.Char)) then
begin
LSelectionBeginPosition := TextToDisplayPosition(FSelectionEndPosition, True);
LSelectionEndPosition := TextToDisplayPosition(FSelectionBeginPosition, True);
end
else
begin
LSelectionBeginPosition := TextToDisplayPosition(FSelectionBeginPosition, True);
LSelectionEndPosition := TextToDisplayPosition(FSelectionEndPosition, True);
end;
end;
procedure SetDrawingColors(ASelected: Boolean);
var
LColor: TColor;
begin
with FTextDrawer do
begin
{ Selection colors }
if AMinimap and (moShowBookmarks in FMinimap.Options) and LBookmarkOnCurrentLine then
LColor := FMinimap.Colors.Bookmark
else
if ASelected then
begin
if FSelection.Colors.Foreground <> clNone then
SetForegroundColor(FSelection.Colors.Foreground)
else
SetForegroundColor(LForegroundColor);
LColor := FSelection.Colors.Background;
end
{ Normal colors }
else
begin
SetForegroundColor(LForegroundColor);
LColor := LBackgroundColor;
end;
SetBackgroundColor(LColor); { Text }
Canvas.Brush.Color := LColor; { Rest of the line }
end;
end;
function GetCharWidth(AIndex: Integer; AMinimap: Boolean = False): Integer;
begin
if AMinimap then
begin
if FMinimap.Align = maRight then
Result := ClientRect.Width - FMinimap.GetWidth
else
Result := 0;
if FSearch.Map.Align = saRight then
Dec(Result, FSearch.Map.GetWidth)
else
Inc(Result, FSearch.Map.GetWidth);
end
else
Result := FTextOffset;
Result := Result + FTextDrawer.CharWidth * (AIndex - 1);
end;
procedure PaintToken(AToken: string; ATokenLength, ACharsBefore, AFirst, ALast: Integer);
var
LText: string;
X: Integer;
LOldPenColor: TColor;
function RemoveMultiByteFillerChars(const AToken: string; AFirst: Integer; var ACharCount: Integer): string;
var
i, j, k: Integer;
begin
Result := AToken;
i := AFirst;
j := 0;
while AToken[i] = BCEDITOR_FILLER_CHAR do
Dec(i);
k := Min(AFirst + ACharCount, Length(Result));
while i < k do
begin
Inc(j);
while AToken[i] = BCEDITOR_FILLER_CHAR do
Inc(i);
if j <> i then
Result[j] := AToken[i];
Inc(i);
end;
SetLength(Result, j);
ACharCount := j;
end;
begin
if (ALast > AFirst) and (LTokenRect.Right > LTokenRect.Left) then
begin
X := GetCharWidth(AFirst, AMinimap);
Dec(AFirst, ACharsBefore);
if AMinimap then
ATokenLength := Min(ATokenLength, LLastChar)
else
ATokenLength := Min(ATokenLength, LVisibleChars);
LText := RemoveMultiByteFillerChars(AToken, AFirst, ATokenLength);
while AToken[AFirst] = BCEDITOR_FILLER_CHAR do
begin
X := X - FTextDrawer.CharWidth;
Inc(AFirst);
end;
FTextDrawer.ExtTextOut(X + 1, LTokenRect.Top, ETO_OPAQUE or ETO_CLIPPED, LTokenRect, PChar(LText), ATokenLength);
if LTokenHelper.MatchingPairUnderline then
begin
LOldPenColor := Canvas.Pen.Color;
Canvas.Pen.Color := FMatchingPair.Colors.Underline;
Canvas.MoveTo(LTokenRect.Left, LTokenRect.Bottom - 1);
Canvas.LineTo(LTokenRect.Right, LTokenRect.Bottom - 1);
Canvas.Pen.Color := LOldPenColor;
end;
LTokenRect.Left := LTokenRect.Right;
end;
end;
procedure PaintHighlightToken(AFillToEndOfLine: Boolean);
var
LIsTokenSelected: Boolean;
LFirstColumn, LLastColumn, LSelectionStart, LSelectionEnd: Integer;
LFirstUnselectedPartOfToken, LSelected, LSecondUnselectedPartOfToken: Boolean;
X1, X2: Integer;
begin
{ Compute some helper variables. }
LFirstColumn := Max(LFirstChar, LTokenHelper.CharsBefore + 1);
LLastColumn := Min(LLastChar, LTokenHelper.CharsBefore + LTokenHelper.Length + 1);
if LIsSelectionInsideLine then
begin
LFirstUnselectedPartOfToken := LFirstColumn < LLineSelectionStart;
LSelected := (LFirstColumn < LLineSelectionEnd) and (LLastColumn >= LLineSelectionStart);
LSecondUnselectedPartOfToken := LLastColumn >= LLineSelectionEnd;
LIsTokenSelected := LSelected and (LFirstUnselectedPartOfToken or LSecondUnselectedPartOfToken);
end
else
begin
LFirstUnselectedPartOfToken := False;
LSelected := LIsLineSelected;
LSecondUnselectedPartOfToken := False;
LIsTokenSelected := False;
end;
{ Any token chars accumulated? }
if LTokenHelper.Length > 0 then
begin
LBackgroundColor := LTokenHelper.Background;
LForegroundColor := LTokenHelper.Foreground;
FTextDrawer.SetStyle(LTokenHelper.FontStyle);
if AMinimap and not (ioUseBlending in FMinimap.Indicator.Options) then
if (LDisplayLine >= TopLine) and (LDisplayLine < TopLine + VisibleLines) then
if LBackgroundColor <> FSearch.Highlighter.Colors.Background then
LBackgroundColor := FMinimap.Colors.VisibleLines;
if LCustomLineColors and (LCustomForegroundColor <> clNone) then
LForegroundColor := LCustomForegroundColor;
if LCustomLineColors and (LCustomBackgroundColor <> clNone) then
LBackgroundColor := LCustomBackgroundColor;
if LIsTokenSelected then
begin
if LFirstUnselectedPartOfToken then
begin
SetDrawingColors(False);
LTokenRect.Right := GetCharWidth(LLineSelectionStart, AMinimap) + 1;
with LTokenHelper do
PaintToken(Text, LLineSelectionStart - 1, CharsBefore, LFirstColumn, LLineSelectionStart);
end;
{ selected part of the token }
SetDrawingColors(True);
LSelectionStart := Max(LLineSelectionStart, LFirstColumn);
LSelectionEnd := Min(LLineSelectionEnd, LLastColumn);
LTokenRect.Right := GetCharWidth(LSelectionEnd, AMinimap) + 1;
with LTokenHelper do
PaintToken(Text, LSelectionEnd - LSelectionStart, CharsBefore, LSelectionStart, LSelectionEnd);
{ second unselected part of the token }
if LSecondUnselectedPartOfToken then
begin
SetDrawingColors(False);
LTokenRect.Right := GetCharWidth(LLastColumn, AMinimap) + 1;
with LTokenHelper do
PaintToken(Text, LLastColumn - LSelectionEnd, CharsBefore, LLineSelectionEnd, LLastColumn);
end;
end
else
begin
SetDrawingColors(LSelected);
LTokenRect.Right := GetCharWidth(LLastColumn, AMinimap) + 1;
with LTokenHelper do
PaintToken(Text, Length, CharsBefore, LFirstColumn, LLastColumn);
end;
end;
if AFillToEndOfLine and (LTokenRect.Left < LLineRect.Right) then
begin
LBackgroundColor := GetBackgroundColor;
if AMinimap and not (ioUseBlending in FMinimap.Indicator.Options) then
if (LDisplayLine >= TopLine) and (LDisplayLine < TopLine + VisibleLines) then
LBackgroundColor := FMinimap.Colors.VisibleLines;
if LCustomLineColors and (LCustomForegroundColor <> clNone) then
LForegroundColor := LCustomForegroundColor;
if LCustomLineColors and (LCustomBackgroundColor <> clNone) then
LBackgroundColor := LCustomBackgroundColor;
if LIsSelectionInsideLine then
begin
X1 := GetCharWidth(LLineSelectionStart, AMinimap);
X2 := GetCharWidth(LLineSelectionEnd, AMinimap);
if LTokenRect.Left < X1 then
begin
SetDrawingColors(soFromEndOfLine in FSelection.Options);
if (soFromEndOfLine in FSelection.Options) and (soToEndOfLine in FSelection.Options) then
LTokenRect.Right := LTokenRect.Left + FCharWidth
else
LTokenRect.Right := X1;
PatBlt(Canvas.Handle, LTokenRect.Left, LTokenRect.Top, LTokenRect.Width, LTokenRect.Height, PATCOPY); { fill end of line rect }
if (soFromEndOfLine in FSelection.Options) and (soToEndOfLine in FSelection.Options) then
LTokenRect.Left := LTokenRect.Right - FCharWidth
else
LTokenRect.Left := X1;
end;
if LTokenRect.Left < X2 then
begin
SetDrawingColors(not (soToEndOfLine in FSelection.Options) and not (soToEndOfLastLine in FSelection.Options) or
(soToEndOfLastLine in FSelection.Options) and (LDisplayLine <> LSelectionEndPosition.Row) );
LTokenRect.Right := X2;
PatBlt(Canvas.Handle, LTokenRect.Left, LTokenRect.Top, LTokenRect.Width, LTokenRect.Height, PATCOPY); { fill end of line rect }
if (soFromEndOfLine in FSelection.Options) and (soToEndOfLine in FSelection.Options) then
begin
SetDrawingColors(True);
LTokenRect.Right := LTokenRect.Left + FCharWidth;
PatBlt(Canvas.Handle, LTokenRect.Left, LTokenRect.Top, LTokenRect.Width, LTokenRect.Height, PATCOPY); { fill end of line rect }
end;
LTokenRect.Right := X2;
LTokenRect.Left := X2;
end;
if LTokenRect.Left < LLineRect.Right then
begin
SetDrawingColors(False);
LTokenRect.Right := LLineRect.Right;
PatBlt(Canvas.Handle, LTokenRect.Left, LTokenRect.Top, LTokenRect.Width, LTokenRect.Height, PATCOPY); { fill end of line rect }
end;
end
else
begin
SetDrawingColors(not (soToEndOfLine in FSelection.Options) and LIsLineSelected);
LTokenRect.Right := LLineRect.Right;
PatBlt(Canvas.Handle, LTokenRect.Left, LTokenRect.Top, LTokenRect.Width, LTokenRect.Height, PATCOPY); { fill end of line rect }
if (soFromEndOfLine in FSelection.Options) and (soToEndOfLine in FSelection.Options) and LIsLineSelected then
begin
SetDrawingColors(True);
LTokenRect.Right := LTokenRect.Left + FCharWidth;
PatBlt(Canvas.Handle, LTokenRect.Left, LTokenRect.Top, LTokenRect.Width, LTokenRect.Height, PATCOPY); { fill end of line rect }
end;
end;
end;
end;
procedure PrepareTokenHelper(const AToken: string; ACharsBefore, ATokenLength: Integer; AForeground, ABackground: TColor;
AFontStyle: TFontStyles; AMatchingPairUnderline: Boolean; ACustomBackgroundColor: Boolean);
var
i: Integer;
LCanAppend: Boolean;
LAreSpaces: Boolean;
PToken: PChar;
begin
if (ABackground = clNone) or ((FActiveLine.Color <> clNone) and LIsCurrentLine and not ACustomBackgroundColor) then
ABackground := GetBackgroundColor;
if AForeground = clNone then
AForeground := FForegroundColor;
LCanAppend := False;
if LTokenHelper.Length > 0 then
begin
PToken := PChar(AToken);
while PToken^ <> BCEDITOR_NONE_CHAR do
begin
if PToken^ <> BCEDITOR_SPACE_CHAR then
Break;
Inc(PToken);
end;
LAreSpaces := PToken^ = BCEDITOR_NONE_CHAR;
LCanAppend := ((LTokenHelper.FontStyle = AFontStyle) or
(not (fsUnderline in AFontStyle) and not (fsUnderline in LTokenHelper.FontStyle) and LAreSpaces)) and
(LTokenHelper.MatchingPairUnderline = AMatchingPairUnderline) and
((LTokenHelper.Background = ABackground) and ((LTokenHelper.Foreground = AForeground) or LAreSpaces)) or
(AToken = BCEDITOR_FILLER_CHAR);
if not LCanAppend then
PaintHighlightToken(False);
end;
if LCanAppend then
begin
if LTokenHelper.Length + ATokenLength > LTokenHelper.MaxLength then
begin
LTokenHelper.MaxLength := LTokenHelper.Length + ATokenLength + 32;
SetLength(LTokenHelper.Text, LTokenHelper.MaxLength);
end;
for i := 1 to ATokenLength do
LTokenHelper.Text[LTokenHelper.Length + i] := AToken[i];
Inc(LTokenHelper.Length, ATokenLength);
end
else
begin
LTokenHelper.Length := ATokenLength;
if LTokenHelper.Length > LTokenHelper.MaxLength then
begin
LTokenHelper.MaxLength := LTokenHelper.Length + 32;
SetLength(LTokenHelper.Text, LTokenHelper.MaxLength);
end;
for i := 1 to ATokenLength do
LTokenHelper.Text[i] := AToken[i];
LTokenHelper.CharsBefore := ACharsBefore;
LTokenHelper.Foreground := AForeground;
LTokenHelper.Background := ABackground;
LTokenHelper.FontStyle := AFontStyle;
LTokenHelper.MatchingPairUnderline := AMatchingPairUnderline;
end;
end;
procedure PaintLines;
var
i: Integer;
LFirstColumn, LLastColumn: Integer;
LCurrentLineText, LFromLineText, LToLineText, LTempLineText: string;
LCurrentRow: Integer;
LFoldRange: TBCEditorCodeFoldingRange;
LHighlighterAttribute: TBCEditorHighlighterAttribute;
LScrolledXBy: Integer;
LTokenText: string;
LTokenPosition, LRealTokenPosition, LTokenLength: Integer;
LStyle: TFontStyles;
LKeyword, LWordAtSelection, LSelectedText: string;
LAddedMultiByteFillerChars: Boolean;
LMatchingPairUnderline: Boolean;
LOpenTokenEndPos, LOpenTokenEndLen: Integer;
LElement: string;
LIsCustomBackgroundColor: Boolean;
LTextPosition: TBCEditorTextPosition;
LPreviousFirstColumn: Integer;
LTextCaretY: Integer;
LWrappedRowCount: Integer;
function GetWordAtSelection(var ASelectedText: string): string;
var
LTempTextPosition: TBCEditorTextPosition;
LSelectionBeginChar, LSelectionEndChar: Integer;
begin
LTempTextPosition := FSelectionEndPosition;
LSelectionBeginChar := FSelectionBeginPosition.Char;
LSelectionEndChar := FSelectionEndPosition.Char;
if LSelectionBeginChar > LSelectionEndChar then
SwapInt(LSelectionBeginChar, LSelectionEndChar);
LTempTextPosition.Char := LSelectionEndChar - 1;
ASelectedText := Copy(FLines[FSelectionBeginPosition.Line], LSelectionBeginChar,
LSelectionEndChar - LSelectionBeginChar);
Result := GetWordAtTextPosition(LTempTextPosition);
end;
procedure PrepareToken;
begin
LHighlighterAttribute := FHighlighter.GetTokenAttribute;
if Assigned(LHighlighterAttribute) then
begin
LForegroundColor := LHighlighterAttribute.Foreground;
if AMinimap and (FMinimap.Colors.Background <> clNone) then
LBackgroundColor := FMinimap.Colors.Background
else
LBackgroundColor := LHighlighterAttribute.Background;
LStyle := LHighlighterAttribute.Style;
if Assigned(FOnCustomTokenAttribute) then
FOnCustomTokenAttribute(Self, LTokenText, LCurrentLine, LRealTokenPosition, LForegroundColor,
LBackgroundColor, LStyle);
LIsCustomBackgroundColor := False;
LMatchingPairUnderline := False;
if FMatchingPair.Enabled and not FSyncEdit.Active then
if FCurrentMatchingPair <> trNotFound then
if (LCurrentLine - 1 = FCurrentMatchingPairMatch.OpenTokenPos.Line) and
(LRealTokenPosition = FCurrentMatchingPairMatch.OpenTokenPos.Char - 1) or
(LCurrentLine - 1 = FCurrentMatchingPairMatch.CloseTokenPos.Line) and
(LRealTokenPosition = FCurrentMatchingPairMatch.CloseTokenPos.Char - 1) then
begin
if (FCurrentMatchingPair = trOpenAndCloseTokenFound) or (FCurrentMatchingPair = trCloseAndOpenTokenFound) then
begin
LIsCustomBackgroundColor := mpoUseMatchedColor in FMatchingPair.Options;
if LIsCustomBackgroundColor then
begin
if LForegroundColor = FMatchingPair.Colors.Matched then
LForegroundColor := BackgroundColor;
LBackgroundColor := FMatchingPair.Colors.Matched;
end;
LMatchingPairUnderline := mpoUnderline in FMatchingPair.Options;
end
else
if mpoHighlightUnmatched in FMatchingPair.Options then
begin
LIsCustomBackgroundColor := mpoUseMatchedColor in FMatchingPair.Options;
if LIsCustomBackgroundColor then
begin
if LForegroundColor = FMatchingPair.Colors.Unmatched then
LForegroundColor := BackgroundColor;
LBackgroundColor := FMatchingPair.Colors.Unmatched;
end;
LMatchingPairUnderline := mpoUnderline in FMatchingPair.Options;
end;
end;
if FSyncEdit.BlockSelected and LIsSyncEditBlock then
LBackgroundColor := FSyncEdit.Colors.Background;
if not FSyncEdit.Active and LAnySelection and (soHighlightSimilarTerms in FSelection.Options) then
begin
LKeyword := '';
if LTokenText = LWordAtSelection then
LKeyword := LSelectedText;
LIsCustomBackgroundColor := (LKeyword <> '') and (LKeyword = LTokenText);
if LIsCustomBackgroundColor then
begin
if FSearch.Highlighter.Colors.Foreground <> clNone then
LForegroundColor := FSearch.Highlighter.Colors.Foreground;
LBackgroundColor := FSearch.Highlighter.Colors.Background;
end;
end;
PrepareTokenHelper(LTokenText, LTokenPosition, LTokenLength, LForegroundColor, LBackgroundColor, LStyle,
LMatchingPairUnderline, LIsCustomBackgroundColor)
end
else
PrepareTokenHelper(LTokenText, LTokenPosition, LTokenLength, LForegroundColor, LBackgroundColor, Font.Style,
False, False);
end;
begin
LLineRect := AClipRect;
if AMinimap then
LLineRect.Bottom := (AFirstRow - FMinimap.TopLine) * FMinimap.CharHeight
else
LLineRect.Bottom := (AFirstRow - FTopLine) * FLineHeight;
if Assigned(FHighlighter) then
begin
LTokenHelper.MaxLength := Max(128, LVisibleChars);
SetLength(LTokenHelper.Text, LTokenHelper.MaxLength);
end;
LWordAtSelection := GetWordAtSelection(LSelectedText);
LScrolledXBy := (FLeftChar - 1) * FTextDrawer.CharWidth;
LDisplayLine := LFirstLine;
LBookmarkOnCurrentLine := False;
while LDisplayLine <= LLastLine do
begin
LCurrentLine := GetDisplayTextLineNumber(LDisplayLine);
if AMinimap and (moShowBookmarks in FMinimap.Options) then
LBookmarkOnCurrentLine := IsBookmarkOnCurrentLine;
{ Get line with tabs converted to spaces. Trust me, you don't want to mess around with tabs when painting. }
LCurrentLineText := FLines.ExpandedStrings[LCurrentLine - 1];
LFoldRange := nil;
LAddedMultiByteFillerChars := False;
if FCodeFolding.Visible then
begin
LFoldRange := CodeFoldingCollapsableFoldRangeForLine(LCurrentLine);
if Assigned(LFoldRange) and LFoldRange.Collapsed then
begin
LOpenTokenEndLen := 0;
LAddedMultiByteFillerChars := True;
LTempLineText := FLines.ExpandedStrings[LFoldRange.FromLine - 1];
LFromLineText := AddMultiByteFillerChars(PChar(LTempLineText), Length(LTempLineText));
LTempLineText := FLines.ExpandedStrings[LFoldRange.ToLine - 1];
LToLineText := AddMultiByteFillerChars(PChar(LTempLineText), Length(LTempLineText));
LOpenTokenEndPos := Pos(LFoldRange.RegionItem.OpenTokenEnd, AnsiUpperCase(LFromLineText));
if LOpenTokenEndPos > 0 then
begin
if LCurrentLine = 0 then
FHighlighter.ResetCurrentRange
else
FHighlighter.SetCurrentRange(FLines.Ranges[LCurrentLine]);
FHighlighter.SetCurrentLine(LFromLineText);
repeat
while not FHighlighter.GetEndOfLine and
(LOpenTokenEndPos > FHighlighter.GetTokenPosition + FHighlighter.GetTokenLength) do
FHighlighter.Next;
LElement := FHighlighter.GetCurrentRangeAttribute.Element;
if (LElement <> BCEDITOR_ATTRIBUTE_ELEMENT_COMMENT) and (LElement <> BCEDITOR_ATTRIBUTE_ELEMENT_STRING) then
Break;
LOpenTokenEndPos := Pos(LFoldRange.RegionItem.OpenTokenEnd, AnsiUpperCase(LFromLineText), LOpenTokenEndPos + 1);
until LOpenTokenEndPos = 0;
end;
if (LFoldRange.RegionItem.OpenTokenEnd <> '') and (LOpenTokenEndPos > 0) then
begin
LOpenTokenEndLen := Length(LFoldRange.RegionItem.OpenTokenEnd);
LCurrentLineText := Copy(LFromLineText, 1, LOpenTokenEndPos + LOpenTokenEndLen - 1);
end
else
LCurrentLineText := Copy(LFromLineText, 1, Length(LFoldRange.RegionItem.OpenToken) +
Pos(LFoldRange.RegionItem.OpenToken, AnsiUpperCase(LFromLineText)) - 1);
if LFoldRange.RegionItem.CloseToken <> '' then
if Pos(LFoldRange.RegionItem.CloseToken, AnsiUpperCase(LToLineText)) <> 0 then
LCurrentLineText := LCurrentLineText + '..' + TrimLeft(LToLineText);
if LCurrentLine - 1 = FCurrentMatchingPairMatch.OpenTokenPos.Line then
begin
if (LFoldRange.RegionItem.OpenTokenEnd <> '') and (LOpenTokenEndPos > 0) then
FCurrentMatchingPairMatch.CloseTokenPos.Char := LOpenTokenEndPos + LOpenTokenEndLen + 2 { +2 = '..' }
else
FCurrentMatchingPairMatch.CloseTokenPos.Char := FCurrentMatchingPairMatch.OpenTokenPos.Char +
Length(FCurrentMatchingPairMatch.OpenToken) + 2 { +2 = '..' };
FCurrentMatchingPairMatch.CloseTokenPos.Line := FCurrentMatchingPairMatch.OpenTokenPos.Line;
end;
end;
end;
if not LAddedMultiByteFillerChars then
LCurrentLineText := AddMultiByteFillerChars(PChar(LCurrentLineText), Length(LCurrentLineText));
LIsCurrentLine := False;
LTokenPosition := 0;
LTokenLength := 0;
LCurrentRow := LCurrentLine;
LFirstColumn := LFirstChar;
LPreviousFirstColumn := LFirstChar;
LLastColumn := LLastChar;
LTextCaretY := GetTextCaretY + 1;
if FWordWrap.Enabled then
if FWordWrapLineLengths[LDisplayLine] <> 0 then
begin
i := LDisplayLine - 1;
if i > 0 then
begin
while (i > 0) and (GetDisplayTextLineNumber(i) = LCurrentLine) do
begin
LFirstColumn := LFirstColumn + FWordWrapLineLengths[i];
Dec(i);
end;
LLastColumn := LFirstColumn + FWordWrapLineLengths[LDisplayLine];
end;
end;
LWrappedRowCount := 0;
while LCurrentRow = LCurrentLine do
begin
LIsCurrentLine := LTextCaretY = LCurrentLine;
LForegroundColor := FForegroundColor;
LBackgroundColor := GetBackgroundColor;
LCustomLineColors := False;
if Assigned(FOnCustomLineColors) then
FOnCustomLineColors(Self, LCurrentLine, LCustomLineColors, LCustomForegroundColor, LCustomBackgroundColor);
LIsSelectionInsideLine := False;
LLineSelectionStart := 0;
LLineSelectionEnd := 0;
if LAnySelection and (LDisplayLine >= LSelectionBeginPosition.Row) and (LDisplayLine <= LSelectionEndPosition.Row) then
begin
LLineSelectionStart := LFirstChar;
LLineSelectionEnd := LLastChar + 1;
if (FSelection.ActiveMode = smColumn) or
((FSelection.ActiveMode = smNormal) and (LDisplayLine = LSelectionBeginPosition.Row)) then
begin
if LSelectionBeginPosition.Column > LLastChar then
begin
LLineSelectionStart := 0;
LLineSelectionEnd := 0;
end
else
if LSelectionBeginPosition.Column > LFirstChar then
begin
LLineSelectionStart := LSelectionBeginPosition.Column;
LIsSelectionInsideLine := True;
end;
end;
if (FSelection.ActiveMode = smColumn) or
((FSelection.ActiveMode = smNormal) and (LDisplayLine = LSelectionEndPosition.Row)) then
begin
if LSelectionEndPosition.Column < LFirstChar then
begin
LLineSelectionStart := 0;
LLineSelectionEnd := 0;
end
else
if LSelectionEndPosition.Column < LLastChar then
begin
LLineSelectionEnd := LSelectionEndPosition.Column;
LIsSelectionInsideLine := True;
end;
end;
end;
LLineRect.Top := LLineRect.Bottom;
if AMinimap then
Inc(LLineRect.Bottom, FMinimap.CharHeight)
else
Inc(LLineRect.Bottom, FLineHeight);
LIsLineSelected := not LIsSelectionInsideLine and (LLineSelectionStart > 0);
LTokenRect := LLineRect;
if LCurrentLine - 1 = 0 then
FHighlighter.ResetCurrentRange
else
if LWrappedRowCount = 0 then
FHighlighter.SetCurrentRange(Lines.Ranges[LCurrentLine - 2]);
if LWrappedRowCount = 0 then
FHighlighter.SetCurrentLine(LCurrentLineText);
LTokenHelper.Length := 0;
while not FHighlighter.GetEndOfLine do
begin
LTokenPosition := FHighlighter.GetTokenPosition;
LRealTokenPosition := LTokenPosition;
FHighlighter.GetToken(LTokenText);
LTokenLength := FHighlighter.GetTokenLength;
LIsSyncEditBlock := False;
if FSyncEdit.BlockSelected then
begin
LTextPosition := GetTextPosition(LTokenPosition + 1, LCurrentLine - 1);
if FSyncEdit.IsTextPositionInBlock(LTextPosition) then
LIsSyncEditBlock := True;
end;
if LTokenPosition + LTokenLength >= LFirstColumn then
begin
if FWordWrap.Enabled then
begin
if LTokenLength >= LLastColumn then
begin
LTokenText := Copy(LTokenText, LFirstColumn, LLastColumn - LFirstColumn);
PrepareToken;
end;
if LTokenPosition + LTokenLength >= LLastColumn then
begin
Inc(LWrappedRowCount);
LFirstColumn := LFirstColumn + FWordWrapLineLengths[LDisplayLine];
LLastColumn := LFirstColumn + LVisibleChars;
if LTokenPosition + LTokenLength - LPreviousFirstColumn < LVisibleChars then
PrepareToken;
Break;
end;
Dec(LTokenPosition, LFirstColumn - LFirstChar);
end;
PrepareToken;
end;
FHighlighter.Next;
end;
PaintHighlightToken(True);
if not AMinimap then
begin
PaintCodeFoldingCollapseMark(LFoldRange, LTokenPosition, LTokenLength, LCurrentLine, LScrolledXBy, LLineRect);
PaintSpecialChars(LCurrentLine, LPreviousFirstColumn, LLineRect);
LPreviousFirstColumn := LFirstColumn;
PaintCodeFoldingCollapsedLine(LFoldRange, LLineRect);
end;
if Assigned(FOnAfterLinePaint) then
FOnAfterLinePaint(Self, Canvas, LLineRect, LCurrentLine, AMinimap);
Inc(LDisplayLine);
LCurrentRow := GetDisplayTextLineNumber(LDisplayLine);
if LWrappedRowCount > FVisibleLines then
Break;
end;
end;
LIsCurrentLine := False;
end;
begin
LFirstLine := AFirstRow;
LLastLine := ALastRow;
LVisibleChars := GetVisibleChars;
if AMinimap then
begin
LFirstChar := 1;
LLastChar := FMinimap.GetWidth div FTextDrawer.CharWidth;
end
else
begin
if FWordWrap.Enabled then
begin
LFirstChar := 1;
LLastChar := LVisibleChars + 1
end
else
begin
LFirstChar := FLeftChar;
LLastChar := FLeftChar + LVisibleChars + 1;
end;
end;
FTextOffset := GetTextOffset;
if LLastLine >= LFirstLine then
begin
SetDrawingColors(False);
ComputeSelectionInfo;
PaintLines;
end;
{ If there is anything visible below the last line, then fill this as well }
LTokenRect := AClipRect;
if AMinimap then
LTokenRect.Top := Min(FMinimap.VisibleLines, FLineNumbersCount) * FMinimap.CharHeight
else
LTokenRect.Top := (ALastRow - TopLine + 1) * FLineHeight;
if LTokenRect.Top < LTokenRect.Bottom then
begin
LBackgroundColor := FBackgroundColor;
SetDrawingColors(False);
PatBlt(Canvas.Handle, LTokenRect.Left, LTokenRect.Top, LTokenRect.Width, LTokenRect.Height, PATCOPY);
end;
if not AMinimap then
if FRightMargin.Visible then
begin
LRightMarginPosition := FTextOffset + FRightMargin.Position * FTextDrawer.CharWidth;
if (LRightMarginPosition >= AClipRect.Left) and (LRightMarginPosition <= AClipRect.Right) then
begin
Canvas.Pen.Color := FRightMargin.Colors.Edge;
Canvas.MoveTo(LRightMarginPosition, 0);
Canvas.LineTo(LRightMarginPosition, Height);
end;
end;
end;
procedure TBCBaseEditor.RecalculateCharExtent;
const
LFontStyles: array [0 .. 3] of TFontStyles = ([], [fsItalic], [fsBold], [fsItalic, fsBold]);
var
LHasStyle: array [0 .. 3] of Boolean;
i, j: Integer;
LCurrentFontStyle: TFontStyles;
begin
FillChar(LHasStyle, SizeOf(LHasStyle), 0);
if Assigned(FHighlighter) and (FHighlighter.Attributes.Count > 0) then
begin
for i := 0 to FHighlighter.Attributes.Count - 1 do
begin
LCurrentFontStyle := FHighlighter.Attribute[i].Style * [fsItalic, fsBold];
for j := 0 to 3 do
if not LHasStyle[j] then
if LCurrentFontStyle = LFontStyles[j] then
begin
LHasStyle[j] := True;
Break;
end;
end;
end
else
begin
LCurrentFontStyle := Font.Style * [fsItalic, fsBold];
for i := 0 to 3 do
if LCurrentFontStyle = LFontStyles[i] then
begin
LHasStyle[i] := True;
Break;
end;
end;
FLineHeight := 0;
FCharWidth := 0;
FTextDrawer.BaseFont := Font;
for i := 0 to 3 do
if LHasStyle[i] then
begin
FTextDrawer.BaseStyle := LFontStyles[i];
FLineHeight := Max(FLineHeight, FTextDrawer.CharHeight);
FCharWidth := Max(FCharWidth, FTextDrawer.CharWidth);
end;
Inc(FLineHeight, ExtraLineSpacing);
end;
procedure TBCBaseEditor.RedoItem;
var
LUndoItem: TBCEditorUndoItem;
LRun, LStrToDelete: PChar;
LLength: Integer;
LTempString: string;
LTextPosition: TBCEditorTextPosition;
LChangeScrollPastEndOfLine: Boolean;
LBeginX: Integer;
begin
LChangeScrollPastEndOfLine := not (soPastEndOfLine in FScroll.Options);
LUndoItem := FRedoList.PopItem;
if Assigned(LUndoItem) then
try
FSelection.ActiveMode := LUndoItem.ChangeSelectionMode;
IncPaintLock;
FScroll.Options := FScroll.Options + [soPastEndOfLine];
FUndoList.InsideRedo := True;
case LUndoItem.ChangeReason of
crCaret:
begin
FUndoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, '', FSelection.ActiveMode, LUndoItem.ChangeBlockNumber);
TextCaretPosition := LUndoItem.ChangeCaretPosition;
SelectionBeginPosition := LUndoItem.ChangeBeginPosition;
SelectionEndPosition := LUndoItem.ChangeEndPosition;
end;
crSelection:
begin
FUndoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, '', LUndoItem.ChangeSelectionMode, LUndoItem.ChangeBlockNumber);
SetCaretAndSelection(LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition);
end;
crInsert, crPaste, crDragDropInsert:
begin
SetCaretAndSelection(LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeBeginPosition);
DoSelectedText(LUndoItem.ChangeSelectionMode, PChar(LUndoItem.ChangeString), False,
LUndoItem.ChangeBeginPosition, LUndoItem.ChangeBlockNumber);
FUndoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, '', LUndoItem.ChangeSelectionMode, LUndoItem.ChangeBlockNumber);
if LUndoItem.ChangeReason = crDragDropInsert then
SetCaretAndSelection(LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition);
end;
crDelete:
begin
SetCaretAndSelection(LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition);
LTempString := SelectedText;
DoSelectedText(LUndoItem.ChangeSelectionMode, PChar(LUndoItem.ChangeString), False,
LUndoItem.ChangeBeginPosition, LUndoItem.ChangeBlockNumber);
FUndoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, LTempString, LUndoItem.ChangeSelectionMode, LUndoItem.ChangeBlockNumber);
TextCaretPosition := LUndoItem.ChangeCaretPosition;
end;
crLineBreak:
begin
LTextPosition := LUndoItem.ChangeBeginPosition;
SetCaretAndSelection(LTextPosition, LTextPosition, LTextPosition);
CommandProcessor(ecLineBreak, BCEDITOR_CARRIAGE_RETURN, nil);
end;
crIndent:
begin
SetCaretAndSelection(LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition);
FUndoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, LUndoItem.ChangeString, LUndoItem.ChangeSelectionMode,
LUndoItem.ChangeBlockNumber);
end;
crUnindent:
begin
LStrToDelete := PChar(LUndoItem.ChangeString);
SetTextCaretY(LUndoItem.ChangeBeginPosition.Line);
if LUndoItem.ChangeSelectionMode = smColumn then
LBeginX := Min(LUndoItem.ChangeBeginPosition.Char, LUndoItem.ChangeEndPosition.Char)
else
LBeginX := 1;
repeat
LRun := GetEndOfLine(LStrToDelete);
if LRun <> LStrToDelete then
begin
LLength := LRun - LStrToDelete;
if LLength > 0 then
begin
LTempString := FLines[GetTextCaretY];
Delete(LTempString, LBeginX, LLength);
FLines[GetTextCaretY] := LTempString;
end;
end
else
LLength := 0;
if LRun^ = BCEDITOR_CARRIAGE_RETURN then
begin
Inc(LRun);
if LRun^ = BCEDITOR_LINEFEED then
Inc(LRun);
Inc(FDisplayCaretY);
end;
LStrToDelete := LRun;
until LRun^ = BCEDITOR_NONE_CHAR;
if LUndoItem.ChangeSelectionMode = smColumn then
SetCaretAndSelection(LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition)
else
begin
LTextPosition.Char := LUndoItem.ChangeBeginPosition.Char - FTabs.Width;
LTextPosition.Line := LUndoItem.ChangeBeginPosition.Line;
SetCaretAndSelection(LTextPosition, LTextPosition,
GetTextPosition(LUndoItem.ChangeEndPosition.Char - LLength, LUndoItem.ChangeEndPosition.Line));
end;
FUndoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, LUndoItem.ChangeString, LUndoItem.ChangeSelectionMode,
LUndoItem.ChangeBlockNumber);
end;
end;
finally
FUndoList.InsideRedo := False;
if LChangeScrollPastEndOfLine then
FScroll.Options := FScroll.Options - [soPastEndOfLine];
LUndoItem.Free;
DecPaintLock;
end;
end;
procedure TBCBaseEditor.ResetCaret(ADoUpdate: Boolean = True);
var
LCaretStyle: TBCEditorCaretStyle;
LWidth, LHeight: Integer;
begin
if InsertMode then
LCaretStyle := FCaret.Styles.Insert
else
LCaretStyle := FCaret.Styles.Overwrite;
LHeight := 1;
LWidth := 1;
FCaretOffset := Point(FCaret.Offsets.X, FCaret.Offsets.Y);
case LCaretStyle of
csHorizontalLine, csThinHorizontalLine:
begin
LWidth := FCharWidth;
if LCaretStyle = csHorizontalLine then
LHeight := 2;
FCaretOffset.Y := FCaretOffset.Y + FLineHeight;
end;
csHalfBlock:
begin
LWidth := FCharWidth;
LHeight := FLineHeight div 2;
FCaretOffset.Y := FCaretOffset.Y + LHeight;
end;
csBlock:
begin
LWidth := FCharWidth;
LHeight := FLineHeight;
end;
csVerticalLine, csThinVerticalLine:
begin
if LCaretStyle = csVerticalLine then
LWidth := 2;
LHeight := FLineHeight;
end;
end;
Exclude(FStateFlags, sfCaretVisible);
if Focused or FAlwaysShowCaret then
begin
CreateCaret(Handle, 0, LWidth, LHeight);
if ADoUpdate then
UpdateCaret;
end;
end;
procedure TBCBaseEditor.ScanMatchingPair;
var
LOpenLineText: string;
LLine, LTempPosition: Integer;
LDisplayPosition: TBCEditorDisplayPosition;
LFoldRange: TBCEditorCodeFoldingRange;
LLineText: string;
begin
if not FHighlighter.MatchingPairHighlight then
Exit;
LDisplayPosition := DisplayCaretPosition;
FCurrentMatchingPair := GetMatchingToken(LDisplayPosition, FCurrentMatchingPairMatch);
if mpoHighlightAfterToken in FMatchingPair.Options then
if (FCurrentMatchingPair = trNotFound) and (LDisplayPosition.Column > 1) then
begin
Dec(LDisplayPosition.Column);
FCurrentMatchingPair := GetMatchingToken(LDisplayPosition, FCurrentMatchingPairMatch);
end;
if FHighlighter.MatchingPairHighlight and (cfoHighlightMatchingPair in FCodeFolding.Options) then
begin
LFoldRange := CodeFoldingCollapsableFoldRangeForLine(LDisplayPosition.Row);
if not Assigned(LFoldRange) then
LFoldRange := CodeFoldingFoldRangeForLineTo(LDisplayPosition.Row);
if Assigned(LFoldRange) then
begin
if IsKeywordAtCaretPosition(nil, mpoHighlightAfterToken in FMatchingPair.Options) then
begin
FCurrentMatchingPair := trOpenAndCloseTokenFound;
LLineText := FLines.ExpandedStrings[LFoldRange.FromLine - 1];
LOpenLineText := AnsiUpperCase(LLineText);
LTempPosition := Pos(LFoldRange.RegionItem.OpenToken, LOpenLineText);
FCurrentMatchingPairMatch.OpenToken := System.Copy(LLineText,
LTempPosition, Length(LFoldRange.RegionItem.OpenToken + LFoldRange.RegionItem.OpenTokenCanBeFollowedBy));
FCurrentMatchingPairMatch.OpenTokenPos := GetTextPosition(LTempPosition, LFoldRange.FromLine - 1);
LLine := LFoldRange.ToLine;
LLineText := FLines.ExpandedStrings[LLine - 1];
LTempPosition := Pos(LFoldRange.RegionItem.CloseToken, AnsiUpperCase(LLineText));
FCurrentMatchingPairMatch.CloseToken := System.Copy(LLineText, LTempPosition,
Length(LFoldRange.RegionItem.CloseToken));
if not LFoldRange.Collapsed then
FCurrentMatchingPairMatch.CloseTokenPos := GetTextPosition(LTempPosition, LLine - 1)
else
FCurrentMatchingPairMatch.CloseTokenPos := GetTextPosition(FCurrentMatchingPairMatch.OpenTokenPos.Char +
Length(FCurrentMatchingPairMatch.OpenToken) + 2 { +2 = '..' }, LFoldRange.FromLine - 1);
end;
end;
end;
end;
procedure TBCBaseEditor.SetAlwaysShowCaret(const AValue: Boolean);
begin
if FAlwaysShowCaret <> AValue then
begin
FAlwaysShowCaret := AValue;
if not (csDestroying in ComponentState) and not Focused then
begin
if AValue then
ResetCaret
else
begin
HideCaret;
Winapi.Windows.DestroyCaret;
end;
end;
end;
end;
procedure TBCBaseEditor.SetDisplayCaretPosition(AValue: TBCEditorDisplayPosition);
var
LMaxX: Integer;
begin
LMaxX := FScroll.MaxWidth + 1;
if AValue.Row > FLineNumbersCount then
AValue.Row := FLineNumbersCount;
if AValue.Row < 1 then
begin
AValue.Row := 1;
if not (soPastEndOfLine in FScroll.Options) then
LMaxX := 1;
end
else
if not (soPastEndOfLine in FScroll.Options) then
LMaxX := Length(Lines[GetDisplayTextLineNumber(AValue.Row) - 1]) + 1;
if (AValue.Column > LMaxX) and (not (soPastEndOfLine in FScroll.Options) or not (soAutosizeMaxWidth in FScroll.Options)) then
AValue.Column := LMaxX;
if AValue.Column < 1 then
AValue.Column := 1;
IncPaintLock;
try
if FDisplayCaretX <> AValue.Column then
FDisplayCaretX := AValue.Column;
if FDisplayCaretY <> AValue.Row then
begin
if ActiveLine.Color <> clNone then
begin
InvalidateLine(FDisplayCaretY);
InvalidateLine(AValue.Row);
end;
FDisplayCaretY := AValue.Row;
end;
EnsureCursorPositionVisible;
Include(FStateFlags, sfCaretChanged);
Include(FStateFlags, sfScrollbarChanged);
finally
DecPaintLock;
end;
end;
procedure TBCBaseEditor.SetName(const AValue: TComponentName);
var
LTextToName: Boolean;
begin
LTextToName := (ComponentState * [csDesigning, csLoading] = [csDesigning]) and (TrimRight(Text) = Name);
inherited SetName(AValue);
if LTextToName then
Text := AValue;
end;
procedure TBCBaseEditor.SetReadOnly(AValue: Boolean);
begin
if FReadOnly <> AValue then
FReadOnly := AValue;
end;
procedure TBCBaseEditor.SetSelectedTextEmpty(const AChangeString: string = '');
var
LBlockStartPosition: TBCEditorTextPosition;
begin
if AChangeString <> '' then
LBlockStartPosition := SelectionBeginPosition;
FUndoList.BeginBlock;
FUndoList.AddChange(crDelete, TextCaretPosition, SelectionBeginPosition, SelectionEndPosition, GetSelectedText,
FSelection.ActiveMode);
DoSelectedText(AChangeString);
if AChangeString <> '' then
FUndoList.AddChange(crInsert, LBlockStartPosition, LBlockStartPosition, SelectionEndPosition, '', smNormal);
FUndoList.EndBlock;
end;
procedure TBCBaseEditor.DoSelectedText(const AValue: string);
begin
DoSelectedText(FSelection.ActiveMode, PChar(AValue), True);
end;
procedure TBCBaseEditor.DoSelectedText(APasteMode: TBCEditorSelectionMode; AValue: PChar; AAddToUndoList: Boolean);
begin
DoSelectedText(APasteMode, AValue, AAddToUndoList, TextCaretPosition);
end;
procedure TBCBaseEditor.DoSelectedText(APasteMode: TBCEditorSelectionMode; AValue: PChar; AAddToUndoList: Boolean;
ATextCaretPosition: TBCEditorTextPosition; AChangeBlockNumber: Integer = 0);
var
LBeginTextPosition, LEndTextPosition: TBCEditorTextPosition;
LTempString: string;
procedure DeleteSelection;
var
i: Integer;
LFirstLine, LLastLine, LCurrentLine: Integer;
LDeletePosition, LDisplayDeletePosition, LDeletePositionEnd, LDisplayDeletePositionEnd: Integer;
begin
case FSelection.ActiveMode of
smNormal:
begin
if FLines.Count > 0 then
begin
LTempString := Copy(Lines[LBeginTextPosition.Line], 1, LBeginTextPosition.Char - 1) +
Copy(Lines[LEndTextPosition.Line], LEndTextPosition.Char, MaxInt);
FLines.DeleteLines(LBeginTextPosition.Line, Min(LEndTextPosition.Line - LBeginTextPosition.Line, FLines.Count -
LBeginTextPosition.Line));
FLines[LBeginTextPosition.Line] := LTempString;
end;
TextCaretPosition := LBeginTextPosition;
end;
smColumn:
begin
if LBeginTextPosition.Char > LEndTextPosition.Char then
SwapInt(LBeginTextPosition.Char, LEndTextPosition.Char);
with TextToDisplayPosition(LBeginTextPosition) do
begin
LFirstLine := Row;
LDisplayDeletePosition := Column;
end;
with TextToDisplayPosition(LEndTextPosition) do
begin
LLastLine := Row;
LDisplayDeletePositionEnd := Column;
end;
for i := LFirstLine to LLastLine do
begin
with DisplayToTextPosition(GetDisplayPosition(LDisplayDeletePosition, i)) do
begin
LDeletePosition := Char;
LCurrentLine := Line;
end;
LDeletePositionEnd := DisplayToTextPosition(GetDisplayPosition(LDisplayDeletePositionEnd, i)).Char;
LTempString := FLines.List[LCurrentLine].Value;
Delete(LTempString, LDeletePosition, LDeletePositionEnd - LDeletePosition);
FLines[LCurrentLine] := LTempString;
end;
TextCaretPosition := GetTextPosition(LBeginTextPosition.Char, FSelectionEndPosition.Line);
end;
end;
end;
procedure InsertText;
var
LTextCaretPosition: TBCEditorTextPosition;
function CountLines(P: PChar): Integer;
begin
Result := 0;
while P^ <> BCEDITOR_NONE_CHAR do
begin
if P^ = BCEDITOR_CARRIAGE_RETURN then
Inc(P);
if P^ = BCEDITOR_LINEFEED then
Inc(P);
Inc(Result);
P := GetEndOfLine(P);
end;
end;
function InsertNormal: Integer;
var
i: Integer;
LLeftSide: string;
LRightSide: string;
LLine: string;
LPStart: PChar;
LPText: PChar;
LLength, LCharCount: Integer;
LSpaces: string;
begin
Result := 0;
LLeftSide := Copy(FLines[LTextCaretPosition.Line], 1, LTextCaretPosition.Char - 1);
LLength := Length(LLeftSide);
if LTextCaretPosition.Char > LLength + 1 then
begin
LCharCount := LTextCaretPosition.Char - LLength - 1;
if toTabsToSpaces in FTabs.Options then
LSpaces := StringOfChar(BCEDITOR_SPACE_CHAR, LCharCount)
else
begin
LSpaces := StringOfChar(BCEDITOR_TAB_CHAR, LCharCount div FTabs.Width);
LSpaces := LSpaces + StringOfChar(BCEDITOR_TAB_CHAR, LCharCount mod FTabs.Width);
end;
LLeftSide := LLeftSide + LSpaces
end;
LRightSide := Copy(FLines[LTextCaretPosition.Line], LTextCaretPosition.Char, FLines.StringLength(LTextCaretPosition.Line) - (LTextCaretPosition.Char - 1));
{ insert the first line of Value into current line }
LPStart := PChar(AValue);
LPText := GetEndOfLine(LPStart);
if LPText^ <> BCEDITOR_NONE_CHAR then
begin
LLine := LLeftSide + Copy(AValue, 1, LPText - LPStart);
FLines[LTextCaretPosition.Line] := LLine;
FLines.InsertLines(LTextCaretPosition.Line + 1, CountLines(LPText));
end
else
begin
LLine := LLeftSide + AValue + LRightSide;
FLines[LTextCaretPosition.Line] := LLine;
end;
{ insert left lines of Value }
i := LTextCaretPosition.Line + 1;
while LPText^ <> BCEDITOR_NONE_CHAR do
begin
if LPText^ = BCEDITOR_CARRIAGE_RETURN then
Inc(LPText);
if LPText^ = BCEDITOR_LINEFEED then
Inc(LPText);
LPStart := LPText;
LPText := GetEndOfLine(LPStart);
if LPText = LPStart then
begin
if LPText^ <> BCEDITOR_NONE_CHAR then
LLine := ''
else
LLine := LRightSide;
end
else
begin
SetString(LLine, LPStart, LPText - LPStart);
if LPText^ = BCEDITOR_NONE_CHAR then
LLine := LLine + LRightSide
end;
FLines[i] := LLine;
Inc(Result);
Inc(i);
end;
LTextCaretPosition := GetTextPosition(Length(FLines[i - 1]) - Length(LRightSide) + 1, i - 1);
end;
function InsertColumn: Integer;
var
LStr: string;
LPStart: PChar;
LPText: PChar;
LLength: Integer;
LCurrentLine: Integer;
LInsertPosition: Integer;
LLineBreakPosition: TBCEditorTextPosition;
begin
Result := 0;
LCurrentLine := LTextCaretPosition.Line;
LPStart := PChar(AValue);
repeat
LInsertPosition := LTextCaretPosition.Char;
LPText := GetEndOfLine(LPStart);
if LPText <> LPStart then
begin
SetLength(LStr, LPText - LPStart);
Move(LPStart^, LStr[1], (LPText - LPStart) * SizeOf(Char));
if LCurrentLine > FLines.Count then
begin
Inc(Result);
if LPText - LPStart > 0 then
begin
LLength := LInsertPosition - 1;
if toTabsToSpaces in FTabs.Options then
LTempString := StringOfChar(BCEDITOR_SPACE_CHAR, LLength)
else
LTempString := StringOfChar(BCEDITOR_TAB_CHAR, LLength div FTabs.Width) +
StringOfChar(BCEDITOR_TAB_CHAR, LLength mod FTabs.Width);
LTempString := LTempString + LStr;
end
else
LTempString := '';
FLines.Add('');
{ Reflect our changes in undo list }
if AAddToUndoList then
begin
with LLineBreakPosition do
begin
Line := LCurrentLine;
Char := Length(Lines[LCurrentLine - 1]) + 1;
end;
FUndoList.AddChange(crLineBreak, LLineBreakPosition, LLineBreakPosition, LLineBreakPosition, '',
smNormal, AChangeBlockNumber);
end;
end
else
begin
LTempString := FLines[LCurrentLine];
LLength := Length(LTempString);
if (LLength < LInsertPosition) and (LPText - LPStart > 0) then
LTempString := LTempString + StringOfChar(BCEDITOR_SPACE_CHAR, LInsertPosition - LLength - 1) + LStr
else
Insert(LStr, LTempString, LInsertPosition);
end;
FLines[LCurrentLine] := LTempString;
if AAddToUndoList then
FUndoList.AddChange(crInsert, LTextCaretPosition, GetTextPosition(LTextCaretPosition.Char, LCurrentLine),
GetTextPosition(LTextCaretPosition.Char + (LPText - LPStart), LCurrentLine), '', FSelection.ActiveMode,
AChangeBlockNumber);
end;
if LPText^ = BCEDITOR_CARRIAGE_RETURN then
begin
Inc(LPText);
if LPText^ = BCEDITOR_LINEFEED then
Inc(LPText);
Inc(LCurrentLine);
Inc(LTextCaretPosition.Line);
end;
LPStart := LPText;
until LPText^ = BCEDITOR_NONE_CHAR;
Inc(LTextCaretPosition.Char, Length(LStr));
end;
var
i, LStartLine: Integer;
LInsertedLines: Integer;
begin
if Length(AValue) = 0 then
Exit;
if SelectionAvailable then
LTextCaretPosition := LBeginTextPosition
else
LTextCaretPosition := ATextCaretPosition;
LStartLine := LTextCaretPosition.Line;
case APasteMode of
smNormal:
LInsertedLines := InsertNormal;
smColumn:
LInsertedLines := InsertColumn;
else
LInsertedLines := 0;
end;
if LInsertedLines > 0 then
if eoTrimTrailingSpaces in Options then
for i := LStartLine to LStartLine + LInsertedLines do
DoTrimTrailingSpaces(i);
{ Force caret reset }
TextCaretPosition := LTextCaretPosition;
SelectionBeginPosition := ATextCaretPosition;
SelectionEndPosition := ATextCaretPosition;
end;
begin
IncPaintLock;
FLines.BeginUpdate;
try
LBeginTextPosition := SelectionBeginPosition;
LEndTextPosition := SelectionEndPosition;
if (LBeginTextPosition.Char <> LEndTextPosition.Char) or (LBeginTextPosition.Line <> LEndTextPosition.Line) then
DeleteSelection;
if Assigned(AValue) then
InsertText;
finally
FLines.EndUpdate;
DecPaintLock;
end;
end;
procedure TBCBaseEditor.SetWantReturns(AValue: Boolean);
begin
FWantReturns := AValue;
end;
procedure TBCBaseEditor.ShowCaret;
begin
if FCaret.Visible and not FCaret.NonBlinking.Enabled and not (sfCaretVisible in FStateFlags) then
if Winapi.Windows.ShowCaret(Handle) then
Include(FStateFlags, sfCaretVisible);
end;
procedure TBCBaseEditor.UndoItem;
var
LUndoItem: TBCEditorUndoItem;
LTempPosition: TBCEditorTextPosition;
LTempText: string;
LChangeScrollPastEndOfLine: Boolean;
LBeginX: Integer;
begin
LChangeScrollPastEndOfLine := not (soPastEndOfLine in FScroll.Options);
LUndoItem := FUndoList.PopItem;
if Assigned(LUndoItem) then
try
FSelection.ActiveMode := LUndoItem.ChangeSelectionMode;
IncPaintLock;
FScroll.Options := FScroll.Options + [soPastEndOfLine];
case LUndoItem.ChangeReason of
crCaret:
begin
FRedoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, '', FSelection.ActiveMode, LUndoItem.ChangeBlockNumber);
TextCaretPosition := LUndoItem.ChangeCaretPosition;
SelectionBeginPosition := LUndoItem.ChangeBeginPosition;
SelectionEndPosition := LUndoItem.ChangeEndPosition;
end;
crSelection:
begin
FRedoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, '', LUndoItem.ChangeSelectionMode, LUndoItem.ChangeBlockNumber);
SetCaretAndSelection(LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition);
end;
crInsert, crPaste, crDragDropInsert:
begin
SetCaretAndSelection(LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition);
LTempText := SelectedText;
DoSelectedText(LUndoItem.ChangeSelectionMode, PChar(LUndoItem.ChangeString), False,
LUndoItem.ChangeBeginPosition, LUndoItem.ChangeBlockNumber);
FRedoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, LTempText, LUndoItem.ChangeSelectionMode, LUndoItem.ChangeBlockNumber);
end;
crDelete:
begin
LTempPosition := LUndoItem.ChangeBeginPosition;
while LTempPosition.Line > FLines.Count do
begin
LTempPosition := GetTextPosition(1, FLines.Count);
FLines.Add('');
end;
FSelectionBeginPosition := LUndoItem.ChangeBeginPosition;
FSelectionEndPosition := FSelectionBeginPosition;
DoSelectedText(LUndoItem.ChangeSelectionMode, PChar(LUndoItem.ChangeString), False,
LUndoItem.ChangeBeginPosition, LUndoItem.ChangeBlockNumber);
FRedoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, '', LUndoItem.ChangeSelectionMode, LUndoItem.ChangeBlockNumber);
TextCaretPosition := LUndoItem.ChangeCaretPosition;
SelectionBeginPosition := LUndoItem.ChangeBeginPosition;
SelectionEndPosition := LUndoItem.ChangeEndPosition;
EnsureCursorPositionVisible;
end;
crLineBreak:
begin
TextCaretPosition := LUndoItem.ChangeCaretPosition;
LTempText := FLines.Strings[LUndoItem.ChangeBeginPosition.Line];
if (LUndoItem.ChangeBeginPosition.Char - 1 > Length(LTempText)) and (LeftSpaceCount(LUndoItem.ChangeString) = 0) then
LTempText := LTempText + StringOfChar(BCEDITOR_SPACE_CHAR, LUndoItem.ChangeBeginPosition.Char - 1 - Length(LTempText));
SetLineWithRightTrim(LUndoItem.ChangeBeginPosition.Line, LTempText + LUndoItem.ChangeString);
FLines.Delete(LUndoItem.ChangeEndPosition.Line);
FRedoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, '', LUndoItem.ChangeSelectionMode, LUndoItem.ChangeBlockNumber);
end;
crIndent:
begin
SetCaretAndSelection(LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition);
FRedoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, LUndoItem.ChangeString, LUndoItem.ChangeSelectionMode,
LUndoItem.ChangeBlockNumber);
end;
crUnindent:
begin
if LUndoItem.ChangeSelectionMode <> smColumn then
InsertBlock(GetTextPosition(1, LUndoItem.ChangeBeginPosition.Line),
GetTextPosition(1, LUndoItem.ChangeEndPosition.Line), PChar(LUndoItem.ChangeString), False)
else
begin
LBeginX := Min(LUndoItem.ChangeBeginPosition.Char, LUndoItem.ChangeEndPosition.Char);
InsertBlock(GetTextPosition(LBeginX, LUndoItem.ChangeBeginPosition.Line),
GetTextPosition(LBeginX, LUndoItem.ChangeEndPosition.Line), PChar(LUndoItem.ChangeString), False);
end;
FRedoList.AddChange(LUndoItem.ChangeReason, LUndoItem.ChangeCaretPosition, LUndoItem.ChangeBeginPosition,
LUndoItem.ChangeEndPosition, LUndoItem.ChangeString, LUndoItem.ChangeSelectionMode,
LUndoItem.ChangeBlockNumber);
end;
end;
finally
if LChangeScrollPastEndOfLine then
FScroll.Options := FScroll.Options - [soPastEndOfLine];
LUndoItem.Free;
DecPaintLock;
end;
end;
procedure TBCBaseEditor.UpdateMouseCursor;
var
LCursorPoint: TPoint;
LTextPosition: TBCEditorTextPosition;
LNewCursor: TCursor;
LWidth: Integer;
LCursorIndex: Integer;
LMinimapLeft, LMinimapRight: Integer;
begin
Winapi.Windows.GetCursorPos(LCursorPoint);
LCursorPoint := ScreenToClient(LCursorPoint);
LWidth := 0;
if FMinimap.Align = maLeft then
Inc(LWidth, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LWidth, FSearch.Map.GetWidth);
GetMinimapLeftRight(LMinimapLeft, LMinimapRight);
if FMouseMoveScrolling then
begin
LCursorIndex := GetMouseMoveScrollCursorIndex;
if LCursorIndex <> -1 then
SetCursor(FMouseMoveScrollCursors[LCursorIndex])
else
SetCursor(0)
end
else
if (LCursorPoint.X > LWidth) and (LCursorPoint.X < LWidth + FLeftMargin.GetWidth + FCodeFolding.GetWidth) then
SetCursor(Screen.Cursors[FLeftMargin.Cursor])
else
if FMinimap.Visible and (LCursorPoint.X > LMinimapLeft) and (LCursorPoint.X < LMinimapRight) then
SetCursor(Screen.Cursors[FMinimap.Cursor])
else
if FSearch.Map.Visible and (
(FSearch.Map.Align = saRight) and (LCursorPoint.X > ClientRect.Width - FSearch.Map.GetWidth) or
(FSearch.Map.Align = saLeft) and (LCursorPoint.X <= FSearch.Map.GetWidth) ) then
SetCursor(Screen.Cursors[FSearch.Map.Cursor])
else
begin
LTextPosition := DisplayToTextPosition(PixelsToRowColumn(LCursorPoint.X, LCursorPoint.Y));
if (eoDragDropEditing in FOptions) and not MouseCapture and IsTextPositionInSelection(LTextPosition) then
LNewCursor := crArrow
else
if FRightMargin.Moving or FRightMargin.MouseOver then
LNewCursor := FRightMargin.Cursor
else
if FMouseOverURI then
LNewCursor := crHandPoint
else
if FCodeFolding.MouseOverHint then
LNewCursor := FCodeFolding.Hint.Cursor
else
LNewCursor := Cursor;
FKeyboardHandler.ExecuteMouseCursor(Self, LTextPosition, LNewCursor);
SetCursor(Screen.Cursors[LNewCursor]);
end;
end;
{ Public declarations }
function TBCBaseEditor.CaretInView: Boolean;
var
LDisplayPosition: TBCEditorDisplayPosition;
begin
LDisplayPosition := DisplayCaretPosition;
Result := (LDisplayPosition.Column >= LeftChar) and (LDisplayPosition.Column <= LeftChar + VisibleChars) and
(LDisplayPosition.Row >= TopLine) and (LDisplayPosition.Row <= TopLine + VisibleLines);
end;
function TBCBaseEditor.CreateFileStream(const AFileName: string): TStream;
begin
if Assigned(FOnCreateFileStream) then
FOnCreateFileStream(Self, AFileName, Result)
else
Result := TFileStream.Create(AFileName, fmOpenRead);
end;
function TBCBaseEditor.DisplayToTextPosition(const ADisplayPosition: TBCEditorDisplayPosition): TBCEditorTextPosition;
var
i, LChar, LPreviousLine, LRow: Integer;
LIsWrapped: Boolean;
LPLine: PChar;
begin
Result := TBCEditorTextPosition(ADisplayPosition);
Result.Line := GetDisplayTextLineNumber(Result.Line);
LIsWrapped := False;
if FWordWrap.Enabled then
begin
LRow := ADisplayPosition.Row - 1;
LPreviousLine := GetDisplayTextLineNumber(LRow);
while LPreviousLine = Result.Line do
begin
LIsWrapped := True;
Result.Char := Result.Char + FWordWrapLineLengths[LRow];
Dec(LRow);
LPreviousLine := GetDisplayTextLineNumber(LRow);
end;
if LIsWrapped then
begin
i := 1;
LPLine := PChar(FLines[Result.Line - 1]);
if Result.Char <= Length(FLines.ExpandedStrings[Result.Line - 1]) then
while (LPLine^ <> BCEDITOR_NONE_CHAR) and (i < Result.Char) do
begin
if LPLine^ = BCEDITOR_TAB_CHAR then
Dec(Result.Char, FTabs.Width - 1); // TODO: Columns?
Inc(i);
Inc(LPLine);
end;
end;
end;
Dec(Result.Line);
if not LIsWrapped then
begin
LPLine := PChar(FLines[Result.Line]);
LChar := 1;
i := 1;
while LChar < Result.Char do
begin
if LPLine^ <> BCEDITOR_NONE_CHAR then
begin
if LPLine^ = BCEDITOR_TAB_CHAR then
begin
if toColumns in FTabs.Options then
Inc(LChar, FTabs.Width - (LChar - 1) mod FTabs.Width)
else
Inc(LChar, FTabs.Width)
end
else
if Ord(LPLine^) < 128 then
Inc(LChar)
else
Inc(LChar, FTextDrawer.GetCharCount(LPLine));
Inc(LPLine);
end
else
Inc(LChar);
Inc(i);
end;
Result.Char := i;
end;
end;
function TBCBaseEditor.GetColorsFileName(const AFileName: string): string;
begin
Result := Trim(ExtractFilePath(AFileName));
if Result = '' then
Result := FDirectories.Colors;
if Trim(ExtractFilePath(Result)) = '' then
{$WARN SYMBOL_PLATFORM OFF}
Result := IncludeTrailingBackslash(ExtractFilePath(Application.ExeName)) + Result;
Result := IncludeTrailingBackslash(Result) + ExtractFileName(AFileName);
{$WARN SYMBOL_PLATFORM ON}
end;
function TBCBaseEditor.GetHighlighterFileName(const AFileName: string): string;
begin
Result := Trim(ExtractFilePath(AFileName));
if Result = '' then
Result := FDirectories.Highlighters;
if Trim(ExtractFilePath(Result)) = '' then
{$WARN SYMBOL_PLATFORM OFF}
Result := IncludeTrailingBackslash(ExtractFilePath(Application.ExeName)) + Result;
Result := IncludeTrailingBackslash(Result) + ExtractFileName(AFileName);
{$WARN SYMBOL_PLATFORM ON}
end;
function TBCBaseEditor.FindPrevious: Boolean;
begin
Result := False;
if Trim(FSearch.SearchText) = '' then
begin
PreviousSelectedWordPosition;
Exit;
end;
FSearch.Options := FSearch.Options + [soBackwards];
if SearchText(FSearch.SearchText) = 0 then
begin
if soBeepIfStringNotFound in FSearch.Options then
Beep;
SelectionEndPosition := SelectionBeginPosition;
TextCaretPosition := SelectionBeginPosition;
end
else
Result := True;
end;
function TBCBaseEditor.FindNext(AChanged: Boolean = False): Boolean;
begin
Result := False;
if Trim(FSearch.SearchText) = '' then
begin
if not NextSelectedWordPosition then
SelectionEndPosition := SelectionBeginPosition;
FSearchEngine.Clear;
Exit;
end;
FSearch.Options := FSearch.Options - [soBackwards];
if SearchText(FSearch.SearchText, AChanged) = 0 then
begin
if (soBeepIfStringNotFound in FSearch.Options) and not (soWrapAround in FSearch.Options) then
Beep;
SelectionBeginPosition := SelectionEndPosition;
TextCaretPosition := SelectionBeginPosition;
if GetSearchResultCount = 0 then
begin
if soShowStringNotFound in FSearch.Options then
DoSearchStringNotFoundDialog;
end
else
if (soShowSearchMatchNotFound in FSearch.Options) and DoSearchMatchNotFoundWraparoundDialog or
(soWrapAround in FSearch.Options) then
begin
CaretZero;
Result := FindNext;
end
end
else
Result := True;
end;
function TBCBaseEditor.GetBookmark(ABookmark: Integer; var ATextPosition: TBCEditorTextPosition): Boolean;
var
i: Integer;
LMark: TBCEditorBookmark;
begin
Result := False;
if Assigned(Marks) then
for i := 0 to Marks.Count - 1 do
begin
LMark := Marks[i];
if LMark.IsBookmark and (LMark.Index = ABookmark) then
begin
ATextPosition.Char := LMark.Char;
ATextPosition.Line := LMark.Line;
Exit(True);
end;
end;
end;
function TBCBaseEditor.GetPositionOfMouse(out ATextPosition: TBCEditorTextPosition): Boolean;
var
LCursorPoint: TPoint;
begin
Result := False;
Winapi.Windows.GetCursorPos(LCursorPoint);
LCursorPoint := ScreenToClient(LCursorPoint);
if (LCursorPoint.X < 0) or (LCursorPoint.Y < 0) or (LCursorPoint.X > Self.Width) or (LCursorPoint.Y > Self.Height) then
Exit;
ATextPosition := DisplayToTextPosition(PixelsToRowColumn(LCursorPoint.X, LCursorPoint.Y));
Result := True;
end;
function TBCBaseEditor.GetWordAtPixels(X, Y: Integer): string;
begin
Result := GetWordAtTextPosition(DisplayToTextPosition(PixelsToRowColumn(X, Y)));
end;
function TBCBaseEditor.IsCommentChar(AChar: Char): Boolean;
begin
Result := Assigned(FHighlighter) and CharInSet(AChar, FHighlighter.Comments.Chars);
end;
function TBCBaseEditor.IsBookmark(ABookmark: Integer): Boolean;
var
LTextPosition: TBCEditorTextPosition;
begin
Result := GetBookmark(ABookmark, LTextPosition);
end;
function TBCBaseEditor.IsTextPositionInSelection(const ATextPosition: TBCEditorTextPosition): Boolean;
var
LBeginTextPosition, LEndTextPosition: TBCEditorTextPosition;
begin
LBeginTextPosition := SelectionBeginPosition;
LEndTextPosition := SelectionEndPosition;
if (ATextPosition.Line >= LBeginTextPosition.Line) and (ATextPosition.Line <= LEndTextPosition.Line) and
((LBeginTextPosition.Line <> LEndTextPosition.Line) or (LBeginTextPosition.Char <> LEndTextPosition.Char)) then
begin
if FSelection.ActiveMode = smColumn then
begin
if LBeginTextPosition.Char > LEndTextPosition.Char then
Result := (ATextPosition.Char >= LEndTextPosition.Char) and (ATextPosition.Char < LBeginTextPosition.Char)
else
if LBeginTextPosition.Char < LEndTextPosition.Char then
Result := (ATextPosition.Char >= LBeginTextPosition.Char) and (ATextPosition.Char < LEndTextPosition.Char)
else
Result := False;
end
else
Result := ((ATextPosition.Line > LBeginTextPosition.Line) or
(ATextPosition.Line = LBeginTextPosition.Line) and (ATextPosition.Char >= LBeginTextPosition.Char))
and
((ATextPosition.Line < LEndTextPosition.Line) or
(ATextPosition.Line = LEndTextPosition.Line) and (ATextPosition.Char < LEndTextPosition.Char));
end
else
Result := False;
end;
function TBCBaseEditor.IsWordBreakChar(AChar: Char): Boolean;
begin
Result := CharInSet(AChar, [BCEDITOR_NONE_CHAR .. BCEDITOR_SPACE_CHAR, '.', ',', ';', ':', '"', '''', '´', '`', '°',
'^', '!', '?', '&', '$', '@', '§', '%', '#', '~', '[', ']', '(', ')', '{', '}', '<', '>', '-', '=', '+', '*', '/',
'\', '|']);
end;
function TBCBaseEditor.IsWordChar(AChar: Char): Boolean;
begin
Result := not IsWordBreakChar(AChar);
end;
function TBCBaseEditor.ReplaceText(const ASearchText: string; const AReplaceText: string): Integer;
var
LStartTextPosition, LEndTextPosition: TBCEditorTextPosition;
LCurrentTextPosition: TBCEditorTextPosition;
LSearchLength, LReplaceLength, LSearchIndex, LFound: Integer;
LCurrentLine: Integer;
LIsBackward, LIsFromCursor: Boolean;
LIsPrompt: Boolean;
LIsReplaceAll, LIsDeleteLine: Boolean;
LActionReplace: TBCEditorReplaceAction;
LResultOffset: Integer;
LPaintLocked: Boolean;
function InValidSearchRange(First, Last: Integer): Boolean;
begin
Result := True;
if (FSelection.ActiveMode = smNormal) or not (soSelectedOnly in FSearch.Options) then
begin
if ((LCurrentTextPosition.Line = LStartTextPosition.Line) and (First < LStartTextPosition.Char)) or
((LCurrentTextPosition.Line = LEndTextPosition.Line) and (Last > LEndTextPosition.Char)) then
Result := False;
end
else
if (FSelection.ActiveMode = smColumn) then
Result := (First >= LStartTextPosition.Char) and (Last <= LEndTextPosition.Char) or
(LEndTextPosition.Char - LStartTextPosition.Char < 1);
end;
begin
if not Assigned(FSearchEngine) then
raise EBCEditorBaseException.Create(SBCEditorSearchEngineNotAssigned);
Result := 0;
if Length(ASearchText) = 0 then
Exit;
ClearCodeFolding;
FCodeFoldingLock := True;
LIsBackward := roBackwards in FReplace.Options;
LIsPrompt := roPrompt in FReplace.Options;
LIsReplaceAll := roReplaceAll in FReplace.Options;
LIsDeleteLine := eraDeleteLine = FReplace.Action;
LIsFromCursor := not (roEntireScope in FReplace.Options);
FSearchEngine.Pattern := ASearchText;
case FReplace.Engine of
seNormal:
begin
TBCEditorNormalSearch(FSearchEngine).CaseSensitive := roCaseSensitive in FReplace.Options;
TBCEditorNormalSearch(FSearchEngine).WholeWordsOnly := roWholeWordsOnly in FReplace.Options;
end;
end;
if not SelectionAvailable then
FReplace.Options := FReplace.Options - [roSelectedOnly];
if roSelectedOnly in FReplace.Options then
begin
LStartTextPosition := SelectionBeginPosition;
LEndTextPosition := SelectionEndPosition;
if FSelection.ActiveMode = smColumn then
if LStartTextPosition.Char > LEndTextPosition.Char then
SwapInt(LStartTextPosition.Char, LEndTextPosition.Char);
end
else
begin
LStartTextPosition.Char := 1;
LStartTextPosition.Line := 0;
LEndTextPosition.Line := FLines.Count - 1;
LEndTextPosition.Char := Length(Lines[LEndTextPosition.Line]) + 1;
if LIsFromCursor then
if LIsBackward then
LEndTextPosition := TextCaretPosition
else
LStartTextPosition := TextCaretPosition;
end;
if LIsBackward then
LCurrentTextPosition := LEndTextPosition
else
LCurrentTextPosition := LStartTextPosition;
LReplaceLength := 0;
LPaintLocked := False;
BeginUndoBlock;
if LIsReplaceAll and not LIsPrompt then
begin
IncPaintLock;
LPaintLocked := True;
end;
try
while (LCurrentTextPosition.Line >= LStartTextPosition.Line) and (LCurrentTextPosition.Line <= LEndTextPosition.Line) do
begin
LCurrentLine := FSearchEngine.FindAll(Lines[LCurrentTextPosition.Line]);
LResultOffset := 0;
if LIsBackward then
LSearchIndex := FSearchEngine.ResultCount - 1
else
LSearchIndex := 0;
while LCurrentLine > 0 do
begin
LFound := FSearchEngine.Results[LSearchIndex] + LResultOffset;
LSearchLength := FSearchEngine.Lengths[LSearchIndex];
if LIsBackward then
Dec(LSearchIndex)
else
Inc(LSearchIndex);
Dec(LCurrentLine);
if not InValidSearchRange(LFound, LFound + LSearchLength) then
Continue;
Inc(Result);
LCurrentTextPosition.Char := LFound;
SelectionBeginPosition := LCurrentTextPosition;
Inc(LCurrentTextPosition.Char, LSearchLength);
SelectionEndPosition := LCurrentTextPosition;
if LIsBackward then
TextCaretPosition := SelectionBeginPosition
else
TextCaretPosition := LCurrentTextPosition;
if LIsPrompt and Assigned(FOnReplaceText) then
begin
LActionReplace := DoOnReplaceText(ASearchText, AReplaceText, LCurrentTextPosition.Line, LFound, LIsDeleteLine);
if LActionReplace = raCancel then
Exit;
end
else
LActionReplace := raReplace;
if LActionReplace = raSkip then
Dec(Result)
else
begin
if LActionReplace = raReplaceAll then
begin
if not LIsReplaceAll or LIsPrompt then
LIsReplaceAll := True;
LIsPrompt := False;
end;
if LIsDeleteLine then
begin
ExecuteCommand(ecDeleteLine, 'Y', nil);
Dec(LCurrentTextPosition.Line);
end
else
begin
SelectedText := FSearchEngine.Replace(SelectedText, AReplaceText);
LReplaceLength := TextCaretPosition.Char - LFound;
end
end;
if not LIsBackward then
begin
SetTextCaretX(LFound + LReplaceLength);
if (LSearchLength <> LReplaceLength) and (LActionReplace <> raSkip) then
begin
Inc(LResultOffset, LReplaceLength - LSearchLength);
if (FSelection.ActiveMode <> smColumn) and (GetTextCaretY = LEndTextPosition.Line) then
begin
Inc(LEndTextPosition.Char, LReplaceLength - LSearchLength);
SelectionEndPosition := LEndTextPosition;
end;
end;
end;
if not LIsReplaceAll then
Exit;
end;
if LIsBackward then
Dec(LCurrentTextPosition.Line)
else
Inc(LCurrentTextPosition.Line);
end;
finally
FCodeFoldingLock := False;
InitCodeFolding;
if LPaintLocked then
DecPaintLock;
EndUndoBlock;
if CanFocus then
SetFocus;
end;
end;
function TBCBaseEditor.SplitTextIntoWords(AStringList: TStrings; ACaseSensitive: Boolean): string;
var
i, Line: Integer;
LChar: Char;
LWord, LWordList: string;
LStringList: TStringList;
LKeywordStringList: TStringList;
LTextPtr, LKeyWordPtr, LBookmarkTextPtr: PChar;
LOpenTokenSkipFoldRangeList: TList;
LSkipOpenKeyChars, LSkipCloseKeyChars: TBCEditorCharSet;
LSkipRegionItem: TBCEditorSkipRegionItem;
procedure AddKeyChars;
var
i: Integer;
procedure Add(var AKeyChars: TBCEditorCharSet; APKey: PChar);
begin
while APKey^ <> BCEDITOR_NONE_CHAR do
begin
AKeyChars := AKeyChars + [APKey^];
Inc(APKey);
end;
end;
begin
LSkipOpenKeyChars := [];
LSkipCloseKeyChars := [];
for i := 0 to FHighlighter.CompletionProposalSkipRegions.Count - 1 do
begin
LSkipRegionItem := FHighlighter.CompletionProposalSkipRegions[i];
Add(LSkipOpenKeyChars, PChar(LSkipRegionItem.OpenToken));
Add(LSkipCloseKeyChars, PChar(LSkipRegionItem.CloseToken));
end;
end;
begin
Result := '';
AddKeyChars;
AStringList.Clear;
LKeywordStringList := TStringList.Create;
LStringList := TStringList.Create;
LOpenTokenSkipFoldRangeList := TList.Create;
try
for Line := 0 to FLines.Count - 1 do
begin
{ add document words }
LTextPtr := PChar(FLines[Line]);
LWord := '';
while LTextPtr^ <> BCEDITOR_NONE_CHAR do
begin
{ Skip regions - Close }
if (LOpenTokenSkipFoldRangeList.Count > 0) and CharInSet(LTextPtr^, LSkipCloseKeyChars) then
begin
LKeyWordPtr := PChar(TBCEditorSkipRegionItem(LOpenTokenSkipFoldRangeList.Last).CloseToken);
LBookmarkTextPtr := LTextPtr;
{ check if the close keyword found }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (LTextPtr^ = LKeyWordPtr^) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then { if found, pop skip region from the list }
begin
LOpenTokenSkipFoldRangeList.Delete(LOpenTokenSkipFoldRangeList.Count - 1);
Continue; { while TextPtr^ <> BCEDITOR_NONE_CHAR do }
end
else
LTextPtr := LBookmarkTextPtr; { skip region close not found, return pointer back }
end;
{ Skip regions - Open }
if CharInSet(LTextPtr^, LSkipOpenKeyChars) then
begin
for i := 0 to FHighlighter.CompletionProposalSkipRegions.Count - 1 do
begin
LSkipRegionItem := FHighlighter.CompletionProposalSkipRegions[i];
if LTextPtr^ = PChar(LSkipRegionItem.OpenToken)^ then { if the first character is a match }
begin
LKeyWordPtr := PChar(LSkipRegionItem.OpenToken);
LBookmarkTextPtr := LTextPtr;
{ check if the open keyword found }
while (LTextPtr^ <> BCEDITOR_NONE_CHAR) and (LKeyWordPtr^ <> BCEDITOR_NONE_CHAR) and (LTextPtr^ = LKeyWordPtr^) do
begin
Inc(LTextPtr);
Inc(LKeyWordPtr);
end;
if LKeyWordPtr^ = BCEDITOR_NONE_CHAR then { if found, skip single line comment or push skip region into stack }
begin
if LSkipRegionItem.RegionType = ritSingleLineComment then
begin
{ single line comment skip until next line }
while LTextPtr^ <> BCEDITOR_NONE_CHAR do
Inc(LTextPtr);
end
else
LOpenTokenSkipFoldRangeList.Add(LSkipRegionItem);
Dec(LTextPtr); { the end of the while loop will increase }
Break; { for i := 0 to BCEditor.Highlighter.CompletionProposalSkipRegions... }
end
else
LTextPtr := LBookmarkTextPtr; { skip region open not found, return pointer back }
end;
end;
end;
if LOpenTokenSkipFoldRangeList.Count = 0 then
begin
if (LWord = '') and (LTextPtr^.IsLower or LTextPtr^.IsUpper or (LTextPtr^ = BCEDITOR_UNDERSCORE)) or
(LWord <> '') and (LTextPtr^.IsLower or LTextPtr^.IsUpper or LTextPtr^.IsNumber or (LTextPtr^ = BCEDITOR_UNDERSCORE)) then
LWord := LWord + LTextPtr^
else
begin
if (LWord <> '') and (Length(LWord) > 1) then
if Pos(LWord + BCEDITOR_CARRIAGE_RETURN + BCEDITOR_LINEFEED, LWordList) = 0 then { no duplicates }
LWordList := LWordList + LWord + BCEDITOR_CARRIAGE_RETURN + BCEDITOR_LINEFEED;
LWord := ''
end;
end;
if LTextPtr^ <> BCEDITOR_NONE_CHAR then
Inc(LTextPtr);
end;
if (LWord <> '') and (Length(LWord) > 1) then
if Pos(LWord + BCEDITOR_CARRIAGE_RETURN + BCEDITOR_LINEFEED, LWordList) = 0 then { no duplicates }
LWordList := LWordList + LWord + BCEDITOR_CARRIAGE_RETURN + BCEDITOR_LINEFEED;
end;
{ add highlighter keywords }
FHighlighter.AddKeywords(LKeywordStringList);
for i := 0 to LKeywordStringList.Count - 1 do
begin
LWord := LKeywordStringList.Strings[i];
if Length(LWord) > 1 then
begin
LChar := LWord[1];
if LChar.IsLower or LChar.IsUpper or (LChar = BCEDITOR_UNDERSCORE) then
if Pos(LWord + BCEDITOR_CARRIAGE_RETURN + BCEDITOR_LINEFEED, LWordList) = 0 then { no duplicates }
LWordList := LWordList + LWord + BCEDITOR_CARRIAGE_RETURN + BCEDITOR_LINEFEED;
end;
end;
LStringList.Text := LWordList;
LStringList.Sort;
AStringList.Assign(LStringList);
finally
LStringList.Free;
LOpenTokenSkipFoldRangeList.Free;
LKeywordStringList.Free;
end;
end;
function TBCBaseEditor.TextToDisplayPosition(const ATextPosition: TBCEditorTextPosition; ARealWidth: Boolean = True): TBCEditorDisplayPosition;
var
i: Integer;
LChar: Integer;
LIsWrapped: Boolean;
LPLine: PChar;
function GetWrapLineLength(ARow: Integer): Integer;
begin
if FWordWrapLineLengths[ARow] <> 0 then
Result := FWordWrapLineLengths[ARow]
else
Result := GetVisibleChars
end;
begin
Result := TBCEditorDisplayPosition(ATextPosition);
Result.Row := GetDisplayLineNumber(ATextPosition.Line + 1);
LIsWrapped := False;
if Visible and FWordWrap.Enabled then
begin
i := 1;
LPLine := PChar(FLines[ATextPosition.Line]);
if Result.Column <= Length(FLines[ATextPosition.Line]) then
while (LPLine^ <> BCEDITOR_NONE_CHAR) and (i < Result.Column) do
begin
// TODO: Columns?
if LPLine^ = BCEDITOR_TAB_CHAR then
Inc(Result.Column, FTabs.Width - 1);
Inc(i);
Inc(LPLine);
end;
if VisibleChars > 0 then
begin
if Result.Row >= Length(FWordWrapLineLengths) then
Result.Row := Length(FWordWrapLineLengths) - 1;
// LIsWrapped := True
// else
while Result.Column - 1 > GetWrapLineLength(Result.Row) do
begin
LIsWrapped := True;
if FWordWrapLineLengths[Result.Row] <> 0 then
Dec(Result.Column, FWordWrapLineLengths[Result.Row])
else
Result.Column := 1;
Inc(Result.Row);
end;
end;
end;
if not LIsWrapped then
begin
LPLine := PChar(FLines[ATextPosition.Line]);
LChar := 1;
i := 1;
while i < ATextPosition.Char do
begin
if LPLine^ <> BCEDITOR_NONE_CHAR then
begin
if LPLine^ = BCEDITOR_TAB_CHAR then
begin
if toColumns in FTabs.Options then
Inc(LChar, FTabs.Width - (LChar - 1) mod FTabs.Width)
else
Inc(LChar, FTabs.Width)
end
else
if ARealWidth and (LPLine^ <> BCEDITOR_SPACE_CHAR) and (LPLine^ <> '') then
begin
if Ord(LPLine^) < 128 then
Inc(LChar)
else
Inc(LChar, FTextDrawer.GetCharCount(LPLine))
end
else
Inc(LChar);
Inc(LPLine);
end
else
Inc(LChar);
Inc(i);
end;
Result.Column := LChar;
end;
end;
function TBCBaseEditor.WordEnd: TBCEditorTextPosition;
begin
Result := WordEnd(TextCaretPosition);
end;
function TBCBaseEditor.StringWordEnd(const ALine: string; AStart: Integer): Integer;
var
LPChar: PChar;
begin
if (AStart > 0) and (AStart <= Length(ALine)) then
begin
LPChar := PChar(@ALine[AStart]);
repeat
if IsWordBreakChar((LPChar + 1)^) and IsWordChar(LPChar^) then
Exit(AStart + 1);
Inc(LPChar);
Inc(AStart);
until LPChar^ = BCEDITOR_NONE_CHAR;
end;
Result := 0;
end;
function TBCBaseEditor.StringWordStart(const ALine: string; AStart: Integer): Integer;
var
i: Integer;
begin
Result := 0;
if (AStart > 0) and (AStart <= Length(ALine)) then
for i := AStart downto 1 do
if IsWordBreakChar(ALine[i - 1]) and IsWordChar(ALine[i]) then
Exit(i);
end;
function TBCBaseEditor.WordEnd(const ATextPosition: TBCEditorTextPosition): TBCEditorTextPosition;
var
LLine: string;
begin
Result := ATextPosition;
if (Result.Char >= 1) and (Result.Line < FLines.Count) then
begin
LLine := FLines[Result.Line];
if Result.Char < Length(LLine) then
begin
Result.Char := StringWordEnd(LLine, Result.Char);
if Result.Char = 0 then
Result.Char := Length(LLine) + 1;
end;
end;
end;
function TBCBaseEditor.WordStart: TBCEditorTextPosition;
begin
Result := WordStart(TextCaretPosition);
end;
function TBCBaseEditor.WordStart(const ATextPosition: TBCEditorTextPosition): TBCEditorTextPosition;
var
LLine: string;
begin
Result := ATextPosition;
if (Result.Line >= 0) and (Result.Line < FLines.Count) then
begin
LLine := FLines[Result.Line];
Result.Char := Min(Result.Char, Length(LLine) + 1);
Result.Char := StringWordStart(LLine, Result.Char - 1);
if Result.Char = 0 then
Result.Char := 1;
end;
end;
procedure TBCBaseEditor.AddKeyCommand(ACommand: TBCEditorCommand; AShift: TShiftState; AKey: Word;
ASecondaryShift: TShiftState; ASecondaryKey: Word);
var
LKeyCommand: TBCEditorKeyCommand;
begin
LKeyCommand := KeyCommands.NewItem;
with LKeyCommand do
begin
Command := ACommand;
Key := AKey;
SecondaryKey := ASecondaryKey;
ShiftState := AShift;
SecondaryShiftState := ASecondaryShift;
end;
end;
procedure TBCBaseEditor.AddKeyDownHandler(AHandler: TKeyEvent);
begin
FKeyboardHandler.AddKeyDownHandler(AHandler);
end;
procedure TBCBaseEditor.AddKeyPressHandler(AHandler: TBCEditorKeyPressWEvent);
begin
FKeyboardHandler.AddKeyPressHandler(AHandler);
end;
procedure TBCBaseEditor.AddKeyUpHandler(AHandler: TKeyEvent);
begin
FKeyboardHandler.AddKeyUpHandler(AHandler);
end;
procedure TBCBaseEditor.AddMouseCursorHandler(AHandler: TBCEditorMouseCursorEvent);
begin
FKeyboardHandler.AddMouseCursorHandler(AHandler);
end;
procedure TBCBaseEditor.AddMouseDownHandler(AHandler: TMouseEvent);
begin
FKeyboardHandler.AddMouseDownHandler(AHandler);
end;
procedure TBCBaseEditor.AddMouseUpHandler(AHandler: TMouseEvent);
begin
FKeyboardHandler.AddMouseUpHandler(AHandler);
end;
procedure TBCBaseEditor.BeginUndoBlock;
begin
FUndoList.BeginBlock;
end;
procedure TBCBaseEditor.BeginUpdate;
begin
IncPaintLock;
end;
procedure TBCBaseEditor.CaretZero;
var
LTextCaretPosition: TBCEditorTextPosition;
begin
LTextCaretPosition.Char := 1;
LTextCaretPosition.Line := 0;
TextCaretPosition := LTextCaretPosition;
SelectionBeginPosition := LTextCaretPosition;
SelectionEndPosition := LTextCaretPosition;
end;
procedure TBCBaseEditor.ChainEditor(AEditor: TBCBaseEditor);
begin
if Highlighter.FileName = '' then
Highlighter.LoadFromFile(AEditor.Highlighter.FileName);
if Highlighter.Colors.FileName = '' then
Highlighter.Colors.LoadFromFile(AEditor.Highlighter.Colors.FileName);
HookEditorLines(AEditor.Lines, AEditor.UndoList, AEditor.RedoList);
InitCodeFolding;
FChainedEditor := AEditor;
AEditor.FreeNotification(Self);
end;
procedure TBCBaseEditor.Clear;
begin
FLines.Clear;
end;
procedure TBCBaseEditor.ClearBookmark(ABookmark: Integer);
begin
if (ABookmark in [0 .. 8]) and Assigned(FBookmarks[ABookmark]) then
begin
DoOnBeforeClearBookmark(FBookmarks[ABookmark]);
FMarkList.Remove(FBookmarks[ABookmark]);
FBookmarks[ABookmark] := nil;
DoOnAfterClearBookmark;
end
end;
procedure TBCBaseEditor.ClearBookmarks;
var
i: Integer;
begin
for i := 0 to Length(FBookmarks) - 1 do
if Assigned(FBookmarks[i]) then
ClearBookmark(i);
end;
procedure TBCBaseEditor.ClearMarks;
var
i: Integer;
begin
i := 0;
while i < Marks.Count do
if not Marks.Items[i].IsBookmark then
Marks.Delete(i)
else
Inc(i);
end;
procedure TBCBaseEditor.ClearCodeFolding;
begin
if FCodeFoldingLock then
Exit;
FAllCodeFoldingRanges.ClearAll;
FResetLineNumbersCache := True;
SetLength(FCodeFoldingTreeLine, 0);
SetLength(FCodeFoldingRangeFromLine, 0);
SetLength(FCodeFoldingRangeToLine, 0);
end;
procedure TBCBaseEditor.ClearMatchingPair;
begin
FCurrentMatchingPair := trNotFound;
end;
procedure TBCBaseEditor.ClearSelection;
begin
if SelectionAvailable then
SelectedText := '';
end;
procedure TBCBaseEditor.ClearUndo;
begin
FUndoList.Clear;
FRedoList.Clear;
end;
procedure TBCBaseEditor.CodeFoldingCollapseAll;
var
i: Integer;
begin
FLines.BeginUpdate;
for i := 9 downto 0 do
CodeFoldingCollapseLevel(i);
FLines.EndUpdate;
UpdateScrollBars;
end;
procedure TBCBaseEditor.CodeFoldingCollapseLevel(ALevel: Integer);
var
i: Integer;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
FLines.BeginUpdate;
for i := FAllCodeFoldingRanges.AllCount - 1 downto 0 do
begin
LCodeFoldingRange := FAllCodeFoldingRanges[i];
if (LCodeFoldingRange.FoldRangeLevel = ALevel) and (not LCodeFoldingRange.Collapsed) and
(not LCodeFoldingRange.ParentCollapsed) and LCodeFoldingRange.Collapsable then
CodeFoldingCollapse(LCodeFoldingRange);
end;
FLines.EndUpdate;
InvalidateLeftMargin;
end;
procedure TBCBaseEditor.CodeFoldingUncollapseAll;
var
i: Integer;
LBlockBeginPosition, LBlockEndPosition: TBCEditorTextPosition;
begin
LBlockBeginPosition.Char := FSelectionBeginPosition.Char;
LBlockBeginPosition.Line := GetDisplayTextLineNumber(FSelectionBeginPosition.Line);
LBlockEndPosition.Char := FSelectionEndPosition.Char;
LBlockEndPosition.Line := GetDisplayTextLineNumber(FSelectionEndPosition.Line);
FLines.BeginUpdate;
for i := 0 to 9 do
CodeFoldingUncollapseLevel(i, False);
FLines.EndUpdate;
FSelectionBeginPosition := LBlockBeginPosition;
FSelectionEndPosition := LBlockEndPosition;
UpdateScrollBars;
end;
procedure TBCBaseEditor.CodeFoldingUncollapseLevel(ALevel: Integer; ANeedInvalidate: Boolean);
var
i: Integer;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
FResetLineNumbersCache := True;
for i := FAllCodeFoldingRanges.AllCount - 1 downto 0 do
begin
LCodeFoldingRange := FAllCodeFoldingRanges[i];
if (LCodeFoldingRange.FoldRangeLevel = ALevel) and LCodeFoldingRange.Collapsed and
not LCodeFoldingRange.ParentCollapsed then
CodeFoldingUncollapse(LCodeFoldingRange);
end;
if ANeedInvalidate then
InvalidateLeftMargin;
end;
procedure TBCBaseEditor.CommandProcessor(ACommand: TBCEditorCommand; AChar: Char; AData: Pointer);
var
i, LCollapsedCount: Integer;
LOldSelectionBeginPosition, LOldSelectionEndPosition: TBCEditorTextPosition;
function CodeFoldingUncollapseLine(ALine: Integer): Integer;
var
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
Result := 0;
if ALine < Length(FCodeFoldingRangeFromLine) then
begin
LCodeFoldingRange := FCodeFoldingRangeFromLine[ALine];
if Assigned(LCodeFoldingRange) then
if LCodeFoldingRange.Collapsed then
begin
Result := LCodeFoldingRange.ToLine - LCodeFoldingRange.FromLine;
CodeFoldingUncollapse(LCodeFoldingRange);
end;
end;
end;
begin
{ first the program event handler gets a chance to process the command }
DoOnProcessCommand(ACommand, AChar, AData);
if ACommand <> ecNone then
begin
{ notify hooked command handlers before the command is executed inside of the class }
NotifyHookedCommandHandlers(False, ACommand, AChar, AData);
FRescanCodeFolding := (ACommand = ecCut) or (ACommand = ecPaste) or (ACommand = ecDeleteLine) or
SelectionAvailable and ((ACommand = ecLineBreak) or (ACommand = ecBackspace) or (ACommand = ecChar)) or
((ACommand = ecChar) or (ACommand = ecBackspace) or (ACommand = ecTab) or (ACommand = ecDeleteChar) or
(ACommand = ecLineBreak)) and IsKeywordAtCaretPosition or
(ACommand = ecBackspace) and IsCommentAtCaretPosition or
((ACommand = ecChar) and CharInSet(AChar, FHighlighter.SkipOpenKeyChars + FHighlighter.SkipCloseKeyChars));
if FCodeFolding.Visible then
begin
case ACommand of
ecBackspace, ecDeleteChar, ecDeleteWord, ecDeleteLastWord, ecDeleteLine, ecClear, ecLineBreak, ecChar,
ecString, ecImeStr, ecCut, ecPaste, ecBlockIndent, ecBlockUnindent, ecTab:
if SelectionAvailable then
begin
LOldSelectionBeginPosition := GetSelectionBeginPosition;
LOldSelectionEndPosition := GetSelectionEndPosition;
LCollapsedCount := 0;
for i := LOldSelectionBeginPosition.Line to LOldSelectionEndPosition.Line do
LCollapsedCount := CodeFoldingUncollapseLine(i + 1);
FSelectionBeginPosition := LOldSelectionBeginPosition;
FSelectionEndPosition := LOldSelectionEndPosition;
if LCollapsedCount <> 0 then
begin
Inc(FSelectionEndPosition.Line, LCollapsedCount);
FSelectionEndPosition.Char := Length(Lines[FSelectionEndPosition.Line]) + 1;
end;
end
else
CodeFoldingUncollapseLine(GetTextCaretY + 1);
end;
end;
{ internal command handler }
if ACommand < ecUserFirst then
ExecuteCommand(ACommand, AChar, AData);
{ notify hooked command handlers after the command was executed inside of the class }
NotifyHookedCommandHandlers(True, ACommand, AChar, AData);
end;
DoOnCommandProcessed(ACommand, AChar, AData);
if FUndoList.Changed or FRedoList.Changed then
DoChange;
end;
procedure TBCBaseEditor.CopyToClipboard;
var
LText: string;
LChangeTrim: Boolean;
LOldSelectionEndPosition: TBCEditorTextPosition;
procedure SetEndPosition(ACodeFoldingRange: TBCEditorCodeFoldingRange);
begin
if Assigned(ACodeFoldingRange) then
if ACodeFoldingRange.Collapsed then
FSelectionEndPosition := DisplayToTextPosition(GetDisplayPosition(1, SelectionEndPosition.Line + 2));
end;
begin
if SelectionAvailable then
begin
LChangeTrim := (FSelection.ActiveMode = smColumn) and (eoTrimTrailingSpaces in Options);
try
if LChangeTrim then
Exclude(FOptions, eoTrimTrailingSpaces);
LOldSelectionEndPosition := FSelectionEndPosition;
if FCodeFolding.Visible then
if SelectionBeginPosition.Line = SelectionEndPosition.Line then
SetEndPosition(FCodeFoldingRangeFromLine[SelectionBeginPosition.Line + 1])
else
SetEndPosition(FCodeFoldingRangeFromLine[SelectionEndPosition.Line + 1]);
LText := SelectedText;
FSelectionEndPosition := LOldSelectionEndPosition;
finally
if LChangeTrim then
Include(FOptions, eoTrimTrailingSpaces);
end;
DoCopyToClipboard(LText);
end;
end;
procedure TBCBaseEditor.CutToClipboard;
begin
CommandProcessor(ecCut, BCEDITOR_NONE_CHAR, nil);
end;
procedure TBCBaseEditor.DeleteLines(const ALineNumber: Integer; const ACount: Integer);
begin
FSelectionBeginPosition.Char := 1;
FSelectionBeginPosition.Line := ALineNumber - 1;
FSelectionEndPosition.Char := 1;
FSelectionEndPosition.Line := ALineNumber + ACount - 1;
SetSelectedTextEmpty;
RescanCodeFoldingRanges;
ScanMatchingPair;
end;
procedure TBCBaseEditor.DeleteWhitespace;
var
LStrings: TStringList;
begin
if ReadOnly then
Exit;
if SelectionAvailable then
begin
LStrings := TStringList.Create;
try
LStrings.Text := SelectedText;
SelectedText := BCEditor.Utils.DeleteWhitespace(LStrings.Text);
finally
LStrings.Free;
end;
end
else
Text := BCEditor.Utils.DeleteWhitespace(Text);
end;
procedure TBCBaseEditor.DoBlockComment;
var
i: Integer;
LLength: Integer;
LStartLine, LEndLine: Integer;
LComment: string;
LCommentIndex: Integer;
LSpaceCount: Integer;
LSpaces: string;
LLineText: string;
LTextCaretPosition, LSelectionBeginPosition, LSelectionEndPosition: TBCEditorTextPosition;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
LDeleteComment: Boolean;
LPosition: Integer;
begin
LLength := Length(FHighlighter.Comments.BlockComments);
if LLength > 0 then
begin
LTextCaretPosition := TextCaretPosition;
LSelectionBeginPosition := SelectionBeginPosition;
LSelectionEndPosition := SelectionEndPosition;
if SelectionAvailable then
begin
LStartLine := LSelectionBeginPosition.Line;
LEndLine := LSelectionEndPosition.Line;
end
else
begin
LStartLine := LTextCaretPosition.Line;
LEndLine := LTextCaretPosition.Line;
end;
for i := LStartLine to LEndLine do
begin
LCodeFoldingRange := CodeFoldingRangeForLine(i + 1);
if Assigned(LCodeFoldingRange) and LCodeFoldingRange.Collapsed then
CodeFoldingUncollapse(LCodeFoldingRange);
end;
i := 0;
LCommentIndex := -2;
LLineText := FLines[LStartLine];
LSpaceCount := LeftSpaceCount(LLineText, False);
LSpaces := Copy(LLineText, 1, LSpaceCount);
LLineText := TrimLeft(LLineText);
if LLineText <> '' then
while i < LLength - 1 do
begin
if Pos(FHighlighter.Comments.BlockComments[i], LLineText) = 1 then
begin
LCommentIndex := i;
Break;
end;
Inc(i, 2);
end;
FUndoList.BeginBlock;
LDeleteComment := False;
if LCommentIndex <> -2 then
begin
LDeleteComment := True;
LComment := FHighlighter.Comments.BlockComments[LCommentIndex];
FUndoList.AddChange(crDelete, LTextCaretPosition, GetTextPosition(LSpaceCount + 1, LStartLine),
GetTextPosition(LSpaceCount + Length(LComment) + 1, LStartLine), LComment, FSelection.ActiveMode);
LLineText := Copy(LLineText, Length(LComment) + 1, Length(LLineText));
end;
Inc(LCommentIndex, 2);
LComment := '';
if LCommentIndex < LLength - 1 then
LComment := FHighlighter.Comments.BlockComments[LCommentIndex];
LLineText := LSpaces + LComment + LLineText;
FLines.BeginUpdate;
FLines.Strings[LStartLine] := LLineText;
FUndoList.AddChange(crInsert, LTextCaretPosition, GetTextPosition(1 + LSpaceCount, LStartLine),
GetTextPosition(1 + LSpaceCount + Length(LComment), LStartLine), '', FSelection.ActiveMode);
Inc(LCommentIndex);
LLineText := FLines[LEndLine];
LSpaceCount := LeftSpaceCount(LLineText, False);
LSpaces := Copy(LLineText, 1, LSpaceCount);
LLineText := TrimLeft(LLineText);
if LDeleteComment and (LLineText <> '') then
begin
LComment := FHighlighter.Comments.BlockComments[LCommentIndex - 2];
LPosition := Length(LLineText) - Length(LComment) + 1;
if (LPosition > 0) and (Pos(LComment, LLineText) = LPosition) then
begin
FUndoList.AddChange(crDelete, LTextCaretPosition, GetTextPosition(LSpaceCount + Length(LLineText) - Length(LComment) + 1, LEndLine),
GetTextPosition(LSpaceCount + Length(LLineText) + 1, LEndLine), LComment, FSelection.ActiveMode);
LLineText := Copy(LLineText, 1, Length(LLineText) - Length(LComment));
end;
end;
if (LCommentIndex > 0) and (LCommentIndex < LLength) then
LComment := FHighlighter.Comments.BlockComments[LCommentIndex]
else
LComment := '';
LLineText := LSpaces + LLineText + LComment;
FLines.Strings[LEndLine] := LLineText;
FUndoList.AddChange(crInsert, LTextCaretPosition, GetTextPosition(Length(LLineText) - Length(LComment) + 1,
LEndLine), GetTextPosition(Length(LLineText) + Length(LComment) + 1, LEndLine), '', FSelection.ActiveMode);
FUndoList.EndBlock;
FLines.EndUpdate;
TextCaretPosition := LTextCaretPosition;
FSelectionBeginPosition := LSelectionBeginPosition;
FSelectionEndPosition := LSelectionEndPosition;
RescanCodeFoldingRanges;
ScanMatchingPair;
end;
end;
procedure TBCBaseEditor.DoCutToClipboard;
begin
if not ReadOnly and SelectionAvailable then
begin
BeginUndoBlock;
DoCopyToClipboard(SelectedText);
SelectedText := '';
EndUndoBlock;
end;
end;
procedure TBCBaseEditor.DragDrop(ASource: TObject; X, Y: Integer);
var
LNewCaretPosition: TBCEditorTextPosition;
LDoDrop, LDropAfter, LDropMove: Boolean;
LSelectionBeginPosition, LSelectionEndPosition: TBCEditorTextPosition;
LDragDropText: string;
LChangeScrollPastEndOfLine: Boolean;
begin
if not ReadOnly and (ASource is TBCBaseEditor) and TBCBaseEditor(ASource).SelectionAvailable then
begin
IncPaintLock;
try
inherited;
ComputeCaret(X, Y);
LNewCaretPosition := TextCaretPosition;
if ASource <> Self then
begin
LDropMove := GetKeyState(VK_SHIFT) < 0;
LDoDrop := True;
LDropAfter := False;
end
else
begin
LDropMove := GetKeyState(VK_CONTROL) >= 0;
LSelectionBeginPosition := SelectionBeginPosition;
LSelectionEndPosition := SelectionEndPosition;
LDropAfter := (LNewCaretPosition.Line > LSelectionEndPosition.Line) or
((LNewCaretPosition.Line = LSelectionEndPosition.Line) and ((LNewCaretPosition.Char > LSelectionEndPosition.Char) or
((not LDropMove) and (LNewCaretPosition.Char = LSelectionEndPosition.Char))));
LDoDrop := LDropAfter or (LNewCaretPosition.Line < LSelectionBeginPosition.Line) or
((LNewCaretPosition.Line = LSelectionBeginPosition.Line) and ((LNewCaretPosition.Char < LSelectionBeginPosition.Char) or
((not LDropMove) and (LNewCaretPosition.Char = LSelectionBeginPosition.Char))));
end;
if LDoDrop then
begin
BeginUndoBlock;
try
LDragDropText := TBCBaseEditor(ASource).SelectedText;
if LDropMove then
begin
if ASource <> Self then
TBCBaseEditor(ASource).SelectedText := ''
else
begin
SelectedText := '';
if LDropAfter and (LNewCaretPosition.Line = LSelectionEndPosition.Line) then
Dec(LNewCaretPosition.Char, LSelectionEndPosition.Char - LSelectionBeginPosition.Char);
if LDropAfter and (LSelectionEndPosition.Line > LSelectionBeginPosition.Line) then
Dec(LNewCaretPosition.Line, LSelectionEndPosition.Line - LSelectionBeginPosition.Line);
end;
end;
LChangeScrollPastEndOfLine := not(soPastEndOfLine in FScroll.Options);
try
if LChangeScrollPastEndOfLine then
FScroll.Options := FScroll.Options + [soPastEndOfLine];
TextCaretPosition := LNewCaretPosition;
SelectionBeginPosition := LNewCaretPosition;
SelectedText := LDragDropText;
finally
if LChangeScrollPastEndOfLine then
FScroll.Options := FScroll.Options - [soPastEndOfLine];
end;
SelectionEndPosition := TextCaretPosition;
CommandProcessor(ecSelectionGotoXY, BCEDITOR_NONE_CHAR, @LNewCaretPosition);
finally
EndUndoBlock;
end;
end;
finally
DecPaintLock;
Exclude(FStateFlags, sfDragging);
end;
end
else
inherited;
end;
procedure TBCBaseEditor.EndUndoBlock;
begin
FUndoList.EndBlock;
end;
procedure TBCBaseEditor.EndUpdate;
begin
DecPaintLock;
end;
procedure TBCBaseEditor.EnsureCursorPositionVisible(AForceToMiddle: Boolean = False; AEvenIfVisible: Boolean = False);
var
LMiddle: Integer;
LVisibleX: Integer;
LCaretRow: Integer;
begin
if VisibleChars <= 0 then
Exit;
HandleNeeded;
IncPaintLock;
try
LVisibleX := DisplayCaretX;
if LVisibleX < LeftChar then
LeftChar := LVisibleX
else
if LVisibleX >= VisibleChars + LeftChar then
LeftChar := LVisibleX - VisibleChars + 1;
LCaretRow := DisplayCaretY;
if AForceToMiddle then
begin
if LCaretRow < TopLine - 1 then
begin
LMiddle := VisibleLines div 2;
if LCaretRow - LMiddle < 0 then
TopLine := 1
else
TopLine := LCaretRow - LMiddle + 1;
end
else
if LCaretRow > TopLine + VisibleLines - 2 then
begin
LMiddle := VisibleLines div 2;
TopLine := LCaretRow - VisibleLines - 1 + LMiddle;
end
else
if AEvenIfVisible then
begin
LMiddle := FVisibleLines div 2;
TopLine := LCaretRow - LMiddle + 1;
end;
end
else
begin
if LCaretRow < TopLine then
TopLine := LCaretRow
else
if LCaretRow > TopLine + Max(1, VisibleLines) - 1 then
TopLine := LCaretRow - (VisibleLines - 1);
end;
finally
DecPaintLock;
end;
end;
procedure TBCBaseEditor.ExecuteCommand(ACommand: TBCEditorCommand; AChar: Char; AData: pointer);
var
i: Integer;
LLength, LRealLength: Integer;
LLineText: string;
LHelper: string;
LSpaceBuffer: string;
LSpaceCount1: Integer;
LSpaceCount2: Integer;
LVisualSpaceCount1, LVisualSpaceCount2: Integer;
LBackCounterLine: Integer;
LBlockStartPosition: TBCEditorTextPosition;
LChangeScroll: Boolean;
LMoveBookmark: Boolean;
LWordPosition: TBCEditorTextPosition;
LTextCaretPosition: TBCEditorTextPosition;
LCaretNewPosition: TBCEditorTextPosition;
LOldSelectionMode: TBCEditorSelectionMode;
LCounter: Integer;
LUndoBeginPosition, LUndoEndPosition: TBCEditorTextPosition;
LCaretRow: Integer;
S: string;
LChar: Char;
LPChar: PChar;
LFoldRange: TBCEditorCodeFoldingRange;
function SaveTrimmedWhitespace(const S: string; APosition: Integer): string;
var
i: Integer;
begin
i := APosition - 1;
while (i > 0) and (S[i] < BCEDITOR_EXCLAMATION_MARK) do
Dec(i);
Result := Copy(S, i + 1, APosition - i - 1);
end;
function AllWhiteUpToCaret(const ALine: string; ALength: Integer): Boolean;
var
j: Integer;
begin
if (ALength = 0) or (LTextCaretPosition.Char = 1) then
begin
Result := True;
Exit;
end;
Result := False;
j := 1;
while (j <= ALength) and (j < LTextCaretPosition.Char) do
begin
if ALine[j] > BCEDITOR_SPACE_CHAR then
Exit;
Inc(j);
end;
Result := True;
end;
function AreCaretsEqual(const TextPosition1, TextPosition2: TBCEditorTextPosition): Boolean;
begin
Result := (TextPosition1.Line = TextPosition2.Line) and (TextPosition1.Char = TextPosition2.Char);
end;
begin
LHelper := '';
IncPaintLock;
LTextCaretPosition := TextCaretPosition;
try
case ACommand of
ecLeft, ecSelectionLeft:
if not FSyncEdit.Active or FSyncEdit.Active and (LTextCaretPosition.Char > FSyncEdit.EditBeginPosition.Char) then
MoveCaretHorizontally(-1, ACommand = ecSelectionLeft);
ecRight, ecSelectionRight:
if not FSyncEdit.Active or FSyncEdit.Active and (LTextCaretPosition.Char < FSyncEdit.EditEndPosition.Char) then
MoveCaretHorizontally(1, ACommand = ecSelectionRight);
ecPageLeft, ecSelectionPageLeft:
MoveCaretHorizontally(-VisibleChars, ACommand = ecSelectionPageLeft);
ecPageRight, ecSelectionPageRight:
MoveCaretHorizontally(VisibleChars, ACommand = ecSelectionPageRight);
ecLineStart, ecSelectionLineStart:
DoHomeKey(ACommand = ecSelectionLineStart);
ecLineEnd, ecSelectionLineEnd:
DoEndKey(ACommand = ecSelectionLineEnd);
ecUp, ecSelectionUp:
MoveCaretVertically(-1, ACommand = ecSelectionUp);
ecDown, ecSelectionDown:
MoveCaretVertically(1, ACommand = ecSelectionDown);
ecPageUp, ecSelectionPageUp, ecPageDown, ecSelectionPageDown:
begin
LCounter := FVisibleLines shr Ord(soHalfPage in FScroll.Options);
if ACommand in [ecPageUp, ecSelectionPageUp] then
LCounter := -LCounter;
TopLine := TopLine + LCounter;
MoveCaretVertically(LCounter, ACommand in [ecSelectionPageUp, ecSelectionPageDown]);
end;
ecPageTop, ecSelectionPageTop, ecPageBottom, ecSelectionPageBottom:
begin
LCounter := 0;
if ACommand in [ecPageBottom, ecSelectionPageBottom] then
LCounter := VisibleLines - 1;
LCaretNewPosition := DisplayToTextPosition(GetDisplayPosition(DisplayCaretX, TopLine + LCounter));
MoveCaretAndSelection(LTextCaretPosition, LCaretNewPosition, ACommand in [ecSelectionPageTop, ecSelectionPageBottom]);
end;
ecEditorTop, ecSelectionEditorTop:
begin
with LCaretNewPosition do
begin
Char := 1;
Line := 0;
end;
MoveCaretAndSelection(LTextCaretPosition, LCaretNewPosition, ACommand = ecSelectionEditorTop);
end;
ecEditorBottom, ecSelectionEditorBottom:
begin
with LCaretNewPosition do
begin
Char := 1;
Line := FLines.Count - 1;
if Line > 0 then
Char := Length(FLines[Line]) + 1;
end;
MoveCaretAndSelection(LTextCaretPosition, LCaretNewPosition, ACommand = ecSelectionEditorBottom);
end;
ecGotoXY, ecSelectionGotoXY:
if Assigned(AData) then
MoveCaretAndSelection(LTextCaretPosition, TBCEditorTextPosition(AData^), ACommand = ecSelectionGotoXY);
ecGotoBookmark1 .. ecGotoBookmark9:
if FLeftMargin.Bookmarks.ShortCuts then
GotoBookmark(ACommand - ecGotoBookmark1);
ecSetBookmark1 .. ecSetBookmark9:
if FLeftMargin.Bookmarks.ShortCuts then
begin
i := ACommand - ecSetBookmark1;
if Assigned(AData) then
LTextCaretPosition := TBCEditorTextPosition(AData^);
if Assigned(FBookmarks[i]) then
begin
LMoveBookmark := FBookmarks[i].Line <> LTextCaretPosition.Line;
ClearBookmark(i);
if LMoveBookmark then
SetBookmark(i, LTextCaretPosition);
end
else
SetBookmark(i, LTextCaretPosition);
end;
ecWordLeft, ecSelectionWordLeft:
begin
LCaretNewPosition := WordStart;
if AreCaretsEqual(LCaretNewPosition, LTextCaretPosition) or (ACommand = ecWordLeft) then
LCaretNewPosition := PreviousWordPosition;
MoveCaretAndSelection(LTextCaretPosition, LCaretNewPosition, ACommand = ecSelectionWordLeft);
end;
ecWordRight, ecSelectionWordRight:
begin
LCaretNewPosition := WordEnd;
if AreCaretsEqual(LCaretNewPosition, LTextCaretPosition) or (ACommand = ecWordRight) then
LCaretNewPosition := NextWordPosition;
MoveCaretAndSelection(LTextCaretPosition, LCaretNewPosition, ACommand = ecSelectionWordRight);
end;
ecSelectionWord:
SetSelectedWord;
ecSelectAll:
SelectAll;
ecBackspace:
if not ReadOnly then
begin
FUndoList.BeginBlock;
FUndoList.AddChange(crCaret, LTextCaretPosition, LTextCaretPosition, LTextCaretPosition, '', smNormal);
if SelectionAvailable then
begin
if FSyncEdit.Active then
begin
if LTextCaretPosition.Char < FSyncEdit.EditBeginPosition.Char then
Exit;
FSyncEdit.MoveEndPositionChar(-FSelectionEndPosition.Char + FSelectionBeginPosition.Char);
end;
SetSelectedTextEmpty;
end
else
begin
if FSyncEdit.Active then
begin
if LTextCaretPosition.Char <= FSyncEdit.EditBeginPosition.Char then
Exit;
FSyncEdit.MoveEndPositionChar(-1);
end;
LLineText := FLines[LTextCaretPosition.Line];
LLength := Length(LLineText);
if LTextCaretPosition.Char > LLength + 1 then
begin
LHelper := '';
if LLength > 0 then
SetTextCaretX(LLength + 1)
else
begin
LSpaceCount1 := LTextCaretPosition.Char - 1;
LSpaceCount2 := 0;
if LSpaceCount1 > 0 then
begin
LBackCounterLine := LTextCaretPosition.Line;
if (eoTrimTrailingSpaces in Options) and (LLength = 0) then
while LBackCounterLine >= 0 do
begin
LSpaceCount2 := LeftSpaceCount(Lines[LBackCounterLine], True);
if LSpaceCount2 < LSpaceCount1 then
Break;
Dec(LBackCounterLine);
end
else
while LBackCounterLine >= 0 do
begin
LSpaceCount2 := LeftSpaceCount(Lines[LBackCounterLine]);
if LSpaceCount2 < LSpaceCount1 then
Break;
Dec(LBackCounterLine);
end;
if (LBackCounterLine = -1) and (LSpaceCount2 > LSpaceCount1) then
LSpaceCount2 := 0;
end;
if LSpaceCount2 = LSpaceCount1 then
LSpaceCount2 := 0;
SetTextCaretX(LTextCaretPosition.Char - (LSpaceCount1 - LSpaceCount2));
FStateFlags := FStateFlags + [sfCaretChanged];
end;
end
else
if LTextCaretPosition.Char = 1 then
begin
if LTextCaretPosition.Line > 0 then
begin
LCaretNewPosition.Line := LTextCaretPosition.Line - 1;
LCaretNewPosition.Char := Length(Lines[LTextCaretPosition.Line - 1]) + 1;
FUndoList.AddChange(crDelete, LTextCaretPosition, LCaretNewPosition, LTextCaretPosition, SLineBreak,
smNormal);
FLines.Delete(LTextCaretPosition.Line);
if eoTrimTrailingSpaces in Options then
LLineText := TrimRight(LLineText);
FLines[LCaretNewPosition.Line] := FLines[LCaretNewPosition.Line] + LLineText;
LHelper := BCEDITOR_CARRIAGE_RETURN + BCEDITOR_LINEFEED;
LFoldRange := CodeFoldingFoldRangeForLineTo(LTextCaretPosition.Line);
if Assigned(LFoldRange) and LFoldRange.Collapsed then
begin
DisplayCaretY := LFoldRange.FromLine;
DisplayCaretX := Length(Lines[LFoldRange.FromLine - 1]) + 2 + LCaretNewPosition.Char;
end
else
TextCaretPosition := LCaretNewPosition;
end;
end
else
begin
LSpaceCount1 := LeftSpaceCount(LLineText);
LSpaceCount2 := 0;
if (LLineText[LTextCaretPosition.Char - 1] <= BCEDITOR_SPACE_CHAR) and
(LSpaceCount1 = LTextCaretPosition.Char - 1) then
begin
LVisualSpaceCount1 := GetLeadingExpandedLength(LLineText);
LVisualSpaceCount2 := 0;
LBackCounterLine := LTextCaretPosition.Line - 1;
while LBackCounterLine >= 0 do
begin
LVisualSpaceCount2 := GetLeadingExpandedLength(FLines[LBackCounterLine]);
if LVisualSpaceCount2 < LVisualSpaceCount1 then
begin
LSpaceCount2 := LeftSpaceCount(FLines[LBackCounterLine]);
Break;
end;
Dec(LBackCounterLine);
end;
if (LBackCounterLine = -1) and (LSpaceCount2 > LSpaceCount1) then
LSpaceCount2 := 0;
if LSpaceCount2 = LSpaceCount1 then
LSpaceCount2 := 0;
if LSpaceCount2 > 0 then
begin
i := LTextCaretPosition.Char - 2;
LLength := GetLeadingExpandedLength(LLineText, i);
while (i > 0) and (LLength > LVisualSpaceCount2) do
begin
Dec(i);
LLength := GetLeadingExpandedLength(LLineText, i);
end;
LHelper := Copy(LLineText, i + 1, LSpaceCount1 - i);
Delete(LLineText, i + 1, LSpaceCount1 - i);
FUndoList.AddChange(crDelete, LTextCaretPosition, GetTextPosition(i + 1, LTextCaretPosition.Line),
LTextCaretPosition, LHelper, smNormal);
if LVisualSpaceCount2 - LLength > 0 then
LSpaceBuffer := StringOfChar(BCEDITOR_SPACE_CHAR, LVisualSpaceCount2 - LLength);
Insert(LSpaceBuffer, LLineText, i + 1);
SetTextCaretX(i + Length(LSpaceBuffer) + 1);
end
else
begin
LVisualSpaceCount2 := LVisualSpaceCount1 - (LVisualSpaceCount1 mod FTabs.Width);
if LVisualSpaceCount2 = LVisualSpaceCount1 then
LVisualSpaceCount2 := Max(LVisualSpaceCount2 - FTabs.Width, 0);
i := LTextCaretPosition.Char - 2;
LLength := GetLeadingExpandedLength(LLineText, i);
while (i > 0) and (LLength > LVisualSpaceCount2) do
begin
Dec(i);
LLength := GetLeadingExpandedLength(LLineText, i);
end;
LHelper := Copy(LLineText, i + 1, LSpaceCount1 - i);
Delete(LLineText, i + 1, LSpaceCount1 - i);
FUndoList.AddChange(crDelete, LTextCaretPosition, GetTextPosition(i + 1, LTextCaretPosition.Line),
LTextCaretPosition, LHelper, smNormal);
SetTextCaretX(i + 1);
end;
FLines[LTextCaretPosition.Line] := LLineText;
FStateFlags := FStateFlags + [sfCaretChanged];
end
else
begin
LChar := LLineText[LTextCaretPosition.Char - 1];
i := 1;
if LChar.IsSurrogate then
i := 2;
LHelper := Copy(LLineText, LTextCaretPosition.Char - i, i);
FUndoList.AddChange(crDelete, LTextCaretPosition, GetTextPosition(LTextCaretPosition.Char - i,
LTextCaretPosition.Line), LTextCaretPosition, LHelper, smNormal);
Delete(LLineText, LTextCaretPosition.Char - i, i);
FLines[LTextCaretPosition.Line] := LLineText;
SetTextCaretX(LTextCaretPosition.Char - i);
end;
end;
end;
if FSyncEdit.Active then
DoSyncEdit;
FUndoList.EndBlock;
end;
ecDeleteChar:
if not ReadOnly then
if SelectionAvailable then
SetSelectedTextEmpty
else
begin
LLineText := FLines[LTextCaretPosition.Line];
LLength := Length(LLineText);
if LTextCaretPosition.Char <= LLength then
begin
LHelper := Copy(LLineText, LTextCaretPosition.Char, 1);
Delete(LLineText, LTextCaretPosition.Char, 1);
SetLineWithRightTrim(LTextCaretPosition.Line, LLineText);
FUndoList.AddChange(crDelete, LTextCaretPosition, LTextCaretPosition,
GetTextPosition(LTextCaretPosition.Char + 1, LTextCaretPosition.Line), LHelper, smNormal);
end
else
begin
if LTextCaretPosition.Line < FLines.Count - 1 then
begin
FUndoList.BeginBlock;
LSpaceCount1 := LTextCaretPosition.Char - 1 - LLength;
LSpaceBuffer := StringOfChar(BCEDITOR_SPACE_CHAR, LSpaceCount1);
if LSpaceCount1 > 0 then
FUndoList.AddChange(crInsert, LTextCaretPosition,
GetTextPosition(LTextCaretPosition.Char - LSpaceCount1, LTextCaretPosition.Line),
GetTextPosition(LTextCaretPosition.Char, LTextCaretPosition.Line), '', smNormal);
with LTextCaretPosition do
begin
Char := 1;
Line := Line + 1;
end;
FUndoList.AddChange(crDelete, LTextCaretPosition, TextCaretPosition, LTextCaretPosition, SLineBreak, smNormal);
FLines[LTextCaretPosition.Line - 1] := LLineText + LSpaceBuffer + FLines[LTextCaretPosition.Line];
FLines.Attributes[LTextCaretPosition.Line - 1].LineState := lsModified;
FLines.Delete(LTextCaretPosition.Line);
FUndoList.EndBlock;
end;
end;
end;
ecDeleteWord, ecDeleteEndOfLine:
if not ReadOnly then
begin
LLineText := FLines[LTextCaretPosition.Line];
LLength := Length(LLineText);
if ACommand = ecDeleteWord then
LWordPosition := WordEnd
else
begin
LWordPosition.Char := LLength + 1;
LWordPosition.Line := LTextCaretPosition.Line;
end;
if (LWordPosition.Char <> LTextCaretPosition.Char) or (LWordPosition.Line <> LTextCaretPosition.Line) then
begin
SetSelectionBeginPosition(LTextCaretPosition);
SetSelectionEndPosition(LWordPosition);
FSelection.ActiveMode := smNormal;
LHelper := SelectedText;
DoSelectedText('');
FUndoList.AddChange(crDelete, LTextCaretPosition, SelectionBeginPosition, LWordPosition, LHelper, smNormal);
end;
end;
ecDeleteLastWord, ecDeleteBeginningOfLine:
if not ReadOnly then
begin
if ACommand = ecDeleteLastWord then
LWordPosition := PreviousWordPosition
else
begin
LWordPosition.Char := 1;
LWordPosition.Line := LTextCaretPosition.Line;
end;
if (LWordPosition.Char <> LTextCaretPosition.Char) or (LWordPosition.Line <> LTextCaretPosition.Line) then
begin
LOldSelectionMode := FSelection.Mode;
try
FSelection.Mode := smNormal;
SetSelectionBeginPosition(LTextCaretPosition);
SetSelectionEndPosition(LWordPosition);
LHelper := SelectedText;
DoSelectedText('');
FUndoList.AddChange(crDelete, LTextCaretPosition, LWordPosition, LTextCaretPosition, LHelper, smNormal);
DisplayCaretPosition := TextToDisplayPosition(LWordPosition);
finally
FSelection.Mode := LOldSelectionMode;
end;
end;
end;
ecDeleteLine:
if not ReadOnly and (Lines.Count > 0) then
begin
if SelectionAvailable then
SetSelectionBeginPosition(LTextCaretPosition);
LHelper := FLines[LTextCaretPosition.Line];
if LTextCaretPosition.Line = FLines.Count - 1 then
begin
FLines[LTextCaretPosition.Line] := '';
FUndoList.AddChange(crDelete, LTextCaretPosition, GetTextPosition(1, LTextCaretPosition.Line),
GetTextPosition(Length(LHelper) + 1, LTextCaretPosition.Line), LHelper, smNormal);
end
else
begin
FLines.Delete(LTextCaretPosition.Line);
LHelper := LHelper + BCEDITOR_CARRIAGE_RETURN + BCEDITOR_LINEFEED;
FUndoList.AddChange(crDelete, LTextCaretPosition, GetTextPosition(1, LTextCaretPosition.Line),
GetTextPosition(1, LTextCaretPosition.Line + 1), LHelper, smNormal);
end;
TextCaretPosition := GetTextPosition(1, LTextCaretPosition.Line);
end;
ecMoveLineUp:
begin
FCommandDrop := True;
try
LUndoBeginPosition := SelectionBeginPosition;
LUndoEndPosition := SelectionEndPosition;
with LBlockStartPosition do
begin
Char := Min(LUndoBeginPosition.Char, LUndoEndPosition.Char);
Line := Min(LUndoBeginPosition.Line, LUndoEndPosition.Line);
end;
LBlockStartPosition := TBCEditorTextPosition(RowColumnToPixels(TextToDisplayPosition(LBlockStartPosition)));
Dec(LBlockStartPosition.Line, FLineHeight);
DragDrop(Self, LBlockStartPosition.Char, LBlockStartPosition.Line);
finally
FCommandDrop := False;
end;
end;
ecMoveLineDown:
begin
FCommandDrop := True;
try
LUndoBeginPosition := SelectionBeginPosition;
LUndoEndPosition := SelectionEndPosition;
with LBlockStartPosition do
begin
Char := Min(LUndoBeginPosition.Char, LUndoEndPosition.Char);
Line := Max(LUndoBeginPosition.Line, LUndoEndPosition.Line);
end;
LBlockStartPosition := TBCEditorTextPosition(RowColumnToPixels(TextToDisplayPosition(LBlockStartPosition)));
Inc(LBlockStartPosition.Line, FLineHeight);
DragDrop(Self, LBlockStartPosition.Char, LBlockStartPosition.Line);
finally
FCommandDrop := False;
end;
end;
ecMoveCharLeft:
begin
FCommandDrop := True;
try
LUndoBeginPosition := SelectionBeginPosition;
LUndoEndPosition := SelectionEndPosition;
with LBlockStartPosition do
begin
Char := Min(LUndoBeginPosition.Char, LUndoEndPosition.Char);
Line := Min(LUndoBeginPosition.Line, LUndoEndPosition.Line);
end;
LBlockStartPosition := TBCEditorTextPosition(RowColumnToPixels(TextToDisplayPosition(GetTextPosition(LBlockStartPosition.Char - 1,
LBlockStartPosition.Line))));
DragDrop(Self, LBlockStartPosition.Char, LBlockStartPosition.Line);
finally
FCommandDrop := False;
end;
end;
ecMoveCharRight:
begin
FCommandDrop := True;
try
LUndoBeginPosition := SelectionBeginPosition;
LUndoEndPosition := SelectionEndPosition;
with LBlockStartPosition do
begin
Char := Max(LUndoBeginPosition.Char, LUndoEndPosition.Char);
Line := Min(LUndoBeginPosition.Line, LUndoEndPosition.Line);
end;
LBlockStartPosition := TBCEditorTextPosition(RowColumnToPixels(TextToDisplayPosition(GetTextPosition(LBlockStartPosition.Char + 1,
LBlockStartPosition.Line))));
DragDrop(Self, LBlockStartPosition.Char, LBlockStartPosition.Line);
finally
FCommandDrop := False;
end;
end;
ecSearchNext:
FindNext;
ecSearchPrevious:
FindPrevious;
ecClear:
if not ReadOnly then
Clear;
ecInsertLine:
if not ReadOnly then
begin
FUndoList.BeginBlock;
FUndoList.AddChange(crCaret, LTextCaretPosition, LTextCaretPosition, LTextCaretPosition, '', smNormal);
LLineText := FLines[LTextCaretPosition.Line];
LLength := Length(LLineText);
FLines.Insert(LTextCaretPosition.Line + 1, '');
FUndoList.AddChange(crInsert, LTextCaretPosition, GetTextPosition(LLength + 1, LTextCaretPosition.Line),
GetTextPosition(1, LTextCaretPosition.Line + 1), '', smNormal);
with FLines do
Attributes[LTextCaretPosition.Line + 1].LineState := lsModified;
DisplayCaretX := 1;
DisplayCaretY := FDisplayCaretY + 1;
FUndoList.EndBlock;
end;
ecLineBreak:
if not ReadOnly then
begin
FUndoList.BeginBlock;
try
if SelectionAvailable then
begin
SetSelectedTextEmpty;
LTextCaretPosition := TextCaretPosition;
end;
FUndoList.AddChange(crCaret, LTextCaretPosition, LTextCaretPosition, LTextCaretPosition, '', smNormal);
LLineText := FLines[LTextCaretPosition.Line];
LLength := Length(LLineText);
if LLength > 0 then
begin
if LLength >= LTextCaretPosition.Char then
begin
if LTextCaretPosition.Char > 1 then
begin
{ A line break after the first char and before the end of the line. }
LSpaceCount1 := LeftSpaceCount(LLineText, True);
LSpaceBuffer := '';
if eoAutoIndent in FOptions then
if toTabsToSpaces in FTabs.Options then
LSpaceBuffer := StringOfChar(BCEDITOR_SPACE_CHAR, LSpaceCount1)
else
begin
LSpaceBuffer := StringOfChar(BCEDITOR_TAB_CHAR, LSpaceCount1 div FTabs.Width);
LSpaceBuffer := LSpaceBuffer + StringOfChar(BCEDITOR_TAB_CHAR, LSpaceCount1 mod FTabs.Width);
end;
FLines[LTextCaretPosition.Line] := Copy(LLineText, 1, LTextCaretPosition.Char - 1);
LLineText := Copy(LLineText, LTextCaretPosition.Char, MaxInt);
FUndoList.AddChange(crDelete, LTextCaretPosition, LTextCaretPosition,
GetTextPosition(LTextCaretPosition.Char + Length(LLineText), LTextCaretPosition.Line), LLineText, smNormal);
if (eoAutoIndent in FOptions) and (LSpaceCount1 > 0) then
LLineText := LSpaceBuffer + LLineText;
FLines.Insert(LTextCaretPosition.Line + 1, LLineText);
FUndoList.AddChange(crLineBreak, GetTextPosition(1, LTextCaretPosition.Line + 1),
LTextCaretPosition, GetTextPosition(1, LTextCaretPosition.Line + 1), '', smNormal);
FUndoList.AddChange(crInsert, GetTextPosition(Length(LSpaceBuffer) + 1, LTextCaretPosition.Line + 1),
GetTextPosition(1, LTextCaretPosition.Line + 1),
GetTextPosition(Length(LLineText) + 1, LTextCaretPosition.Line + 1), LLineText, smNormal);
with FLines do
begin
Attributes[LTextCaretPosition.Line].LineState := lsModified;
Attributes[LTextCaretPosition.Line + 1].LineState := lsModified;
end;
DisplayCaretX := LSpaceCount1 + 1;
DisplayCaretY := FDisplayCaretY + 1;
end
else
begin
{ A line break at the first char. }
FLines.Insert(LTextCaretPosition.Line, '');
FUndoList.AddChange(crLineBreak, LTextCaretPosition, LTextCaretPosition, LTextCaretPosition, '',
smNormal);
with FLines do
Attributes[LTextCaretPosition.Line + 1].LineState := lsModified;
DisplayCaretY := DisplayCaretY + 1;
end;
end
else
begin
{ A line break after the end of the line. }
LSpaceCount1 := 0;
if eoAutoIndent in FOptions then
LSpaceCount1 := LeftSpaceCount(LLineText, True);
FLines.Insert(LTextCaretPosition.Line + 1, '');
if LTextCaretPosition.Char > LLength + 1 then
LTextCaretPosition.Char := LLength + 1;
FUndoList.AddChange(crLineBreak, GetTextPosition(1, LTextCaretPosition.Line + 1),
LTextCaretPosition, GetTextPosition(1, LTextCaretPosition.Line + 1), '', smNormal);
with FLines do
Attributes[LTextCaretPosition.Line + 1].LineState := lsModified;
DisplayCaretY := FDisplayCaretY + 1;
DisplayCaretX := LSpaceCount1 + 1
end;
end
else
begin
{ A line break at the empty line. }
if FLines.Count = 0 then
FLines.Add('');
Inc(LTextCaretPosition.Line);
FLines.Insert(LTextCaretPosition.Line, '');
FUndoList.AddChange(crLineBreak, LTextCaretPosition, LTextCaretPosition, LTextCaretPosition, '', smNormal);
with FLines do
Attributes[LTextCaretPosition.Line].LineState := lsModified;
DisplayCaretY := FDisplayCaretY + 1;
end;
DoTrimTrailingSpaces(LTextCaretPosition.Line);
SelectionBeginPosition := LTextCaretPosition;
SelectionEndPosition := LTextCaretPosition;
EnsureCursorPositionVisible;
finally
UndoList.EndBlock;
end;
end;
ecTab:
if not ReadOnly then
DoTabKey;
ecShiftTab:
if not ReadOnly then
DoShiftTabKey;
ecChar:
if not ReadOnly and (AChar >= BCEDITOR_SPACE_CHAR) and (AChar <> BCEDITOR_CTRL_BACKSPACE) then
begin
if SelectionAvailable then
begin
if FSyncEdit.Active then
FSyncEdit.MoveEndPositionChar(-FSelectionEndPosition.Char + FSelectionBeginPosition.Char + 1);
SetSelectedTextEmpty(AChar)
end
else
begin
if FSyncEdit.Active then
FSyncEdit.MoveEndPositionChar(1);
LLineText := FLines[LTextCaretPosition.Line];
LLength := Length(LLineText);
LSpaceCount1 := 0;
if LLength < LTextCaretPosition.Char - 1 then
begin
if toTabsToSpaces in FTabs.Options then
LSpaceBuffer := StringOfChar(BCEDITOR_SPACE_CHAR, LTextCaretPosition.Char - LLength - Ord(FInsertMode))
else
if AllWhiteUpToCaret(LLineText, LLength) then
LSpaceBuffer := StringOfChar(BCEDITOR_TAB_CHAR, (LTextCaretPosition.Char - LLength - Ord(FInsertMode)) div FTabs.Width) +
StringOfChar(BCEDITOR_TAB_CHAR, (LTextCaretPosition.Char - LLength - Ord(FInsertMode)) mod FTabs.Width)
else
LSpaceBuffer := StringOfChar(BCEDITOR_SPACE_CHAR, LTextCaretPosition.Char - LLength - Ord(FInsertMode));
LSpaceCount1 := Length(LSpaceBuffer);
end;
LBlockStartPosition := LTextCaretPosition;
if FInsertMode then
begin
if not FWordWrap.Enabled and not (soAutosizeMaxWidth in FScroll.Options) and (DisplayCaretX > FScroll.MaxWidth) then
Exit;
if LSpaceCount1 > 0 then
LLineText := LLineText + LSpaceBuffer + AChar
else
Insert(AChar, LLineText, LTextCaretPosition.Char);
FLines[LTextCaretPosition.Line] := LLineText;
if LSpaceCount1 > 0 then
begin
LTextCaretPosition.Char := LLength + LSpaceCount1 + 2;
FUndoList.AddChange(crInsert, LTextCaretPosition, GetTextPosition(LLength + 1,
LTextCaretPosition.Line), GetTextPosition(LLength + LSpaceCount1 + 2, LTextCaretPosition.Line), '',
smNormal);
FLines.Attributes[LTextCaretPosition.Line].LineState := lsModified;
end
else
begin
LTextCaretPosition.Char := LTextCaretPosition.Char + 1;
FUndoList.AddChange(crInsert, LTextCaretPosition, LBlockStartPosition, LTextCaretPosition, '',
smNormal);
FLines.Attributes[LTextCaretPosition.Line].LineState := lsModified;
end;
end
else
begin
if LTextCaretPosition.Char <= LLength then
LHelper := Copy(LLineText, LTextCaretPosition.Char, 1);
if LTextCaretPosition.Char <= LLength then
LLineText[LTextCaretPosition.Char] := AChar
else
if LSpaceCount1 > 0 then
begin
LSpaceBuffer[LSpaceCount1] := AChar;
LLineText := LLineText + LSpaceBuffer;
end
else
LLineText := LLineText + AChar;
FLines[LTextCaretPosition.Line] := LLineText;
if LSpaceCount1 > 0 then
begin
LTextCaretPosition.Char := LLength + LSpaceCount1 + 1;
FUndoList.AddChange(crInsert, LTextCaretPosition, GetTextPosition(LLength + 1,
LTextCaretPosition.Line), GetTextPosition(LLength + LSpaceCount1 + 1, LTextCaretPosition.Line), '',
smNormal);
FLines.Attributes[LTextCaretPosition.Line].LineState := lsModified;
end
else
begin
LTextCaretPosition.Char := LTextCaretPosition.Char + 1;
FUndoList.AddChange(crInsert, LTextCaretPosition, LBlockStartPosition, LTextCaretPosition, LHelper,
smNormal);
FLines.Attributes[LTextCaretPosition.Line].LineState := lsModified;
end;
end;
if FWordWrap.Enabled and (LTextCaretPosition.Char > VisibleChars) then
CreateLineNumbersCache(True);
TextCaretPosition := LTextCaretPosition;
if LTextCaretPosition.Char >= LeftChar + VisibleChars then
LeftChar := LeftChar + Min(25, VisibleChars - 1);
end;
if FSyncEdit.Active then
DoSyncEdit;
end;
ecUpperCase, ecLowerCase, ecAlternatingCase, ecSentenceCase, ecTitleCase, ecUpperCaseBlock, ecLowerCaseBlock,
ecAlternatingCaseBlock:
if not ReadOnly then
DoToggleSelectedCase(ACommand);
ecUndo:
if not ReadOnly then
begin
FUndoRedo := True;
try
DoInternalUndo;
finally
FUndoRedo := False;
end;
end;
ecRedo:
if not ReadOnly then
begin
FUndoRedo := True;
try
DoInternalRedo;
finally
FUndoRedo := False;
end;
end;
ecCut:
if not ReadOnly and SelectionAvailable then
DoCutToClipboard;
ecCopy:
CopyToClipboard;
ecPaste:
if not ReadOnly then
DoPasteFromClipboard;
ecScrollUp, ecScrollDown:
begin
LCaretRow := DisplayCaretY;
if (LCaretRow < TopLine) or (LCaretRow >= TopLine + VisibleLines) then
EnsureCursorPositionVisible
else
begin
if ACommand = ecScrollUp then
begin
TopLine := TopLine - 1;
if LCaretRow > TopLine + VisibleLines - 1 then
MoveCaretVertically((TopLine + VisibleLines - 1) - LCaretRow, False);
end
else
begin
TopLine := TopLine + 1;
if LCaretRow < TopLine then
MoveCaretVertically(TopLine - LCaretRow, False);
end;
EnsureCursorPositionVisible;
end;
end;
ecScrollLeft:
begin
LeftChar := LeftChar - 1;
Update;
end;
ecScrollRight:
begin
LeftChar := LeftChar + 1;
Update;
end;
ecInsertMode:
InsertMode := True;
ecOverwriteMode:
InsertMode := False;
ecToggleMode:
InsertMode := not InsertMode;
ecBlockIndent:
if not ReadOnly then
DoBlockIndent;
ecBlockUnindent:
if not ReadOnly then
DoBlockUnindent;
ecNormalSelect:
FSelection.Mode := smNormal;
ecColumnSelect:
FSelection.Mode := smColumn;
ecContextHelp:
begin
if Assigned(FOnContextHelp) then
FOnContextHelp(Self, WordAtCursor);
end;
ecBlockComment:
if not ReadOnly then
DoBlockComment;
ecLineComment:
if not ReadOnly then
DoLineComment;
ecImeStr:
if not ReadOnly then
begin
LPChar := PChar(AData);
LLength := Length(PChar(AData));
LRealLength := 0;
for i := 0 to LLength - 1 do //FI:W528 FixInsight ignore
begin
if Ord(LPChar^) < 128 then
LRealLength := LRealLength + 1
else
LRealLength := LRealLength + FTextDrawer.GetCharCount(LPChar);
Inc(LPChar);
end;
SetString(S, PChar(AData), LLength);
if SelectionAvailable then
begin
BeginUndoBlock;
try
FUndoList.AddChange(crDelete, LTextCaretPosition, FSelectionBeginPosition, FSelectionEndPosition,
LHelper, smNormal);
LBlockStartPosition := FSelectionBeginPosition;
DoSelectedText(S);
FUndoList.AddChange(crInsert, LTextCaretPosition, FSelectionBeginPosition, FSelectionEndPosition,
LHelper, smNormal);
finally
EndUndoBlock;
end;
InvalidateLeftMarginLines(-1, -1);
end
else
begin
LLineText := FLines[LTextCaretPosition.Line];
LLength := Length(LLineText);
if LLength < LTextCaretPosition.Char then
LLineText := LLineText + StringOfChar(BCEDITOR_SPACE_CHAR, LTextCaretPosition.Char - LLength - 1);
LChangeScroll := not (soPastEndOfLine in FScroll.Options);
try
if LChangeScroll then
FScroll.Options := FScroll.Options + [soPastEndOfLine];
LBlockStartPosition := LTextCaretPosition;
if not FInsertMode then
begin
LHelper := Copy(LLineText, LTextCaretPosition.Char, LLength);
Delete(LLineText, LTextCaretPosition.Char, LLength);
end;
Insert(S, LLineText, LTextCaretPosition.Char);
DisplayCaretX := DisplayCaretX + LRealLength;
SetLineWithRightTrim(GetTextCaretY, LLineText);
if FInsertMode then
LHelper := '';
FUndoList.AddChange(crInsert, LTextCaretPosition, LBlockStartPosition, TextCaretPosition, LHelper,
smNormal);
if DisplayCaretX >= LeftChar + VisibleChars then
LeftChar := LeftChar + Min(25, VisibleChars - 1);
finally
if LChangeScroll then
FScroll.Options := FScroll.Options - [soPastEndOfLine];
end;
end;
end;
end;
finally
DecPaintLock;
end;
end;
procedure TBCBaseEditor.ExportToHTML(const AFileName: string; const ACharSet: string = ''; AEncoding: System.SysUtils.TEncoding = nil);
var
LFileStream: TFileStream;
begin
LFileStream := TFileStream.Create(AFileName, fmCreate);
try
ExportToHTML(LFileStream, ACharSet, AEncoding);
finally
LFileStream.Free;
end;
end;
procedure TBCBaseEditor.ExportToHTML(AStream: TStream; const ACharSet: string = ''; AEncoding: System.SysUtils.TEncoding = nil);
begin
with TBCEditorExportHTML.Create(FLines, FHighlighter, Font, ACharSet) do
try
SaveToStream(AStream, AEncoding);
finally
Free;
end;
end;
procedure TBCBaseEditor.GotoBookmark(ABookmark: Integer);
var
LTextPosition: TBCEditorTextPosition;
begin
if (ABookmark in [0 .. 8]) and Assigned(FBookmarks[ABookmark]) and (FBookmarks[ABookmark].Line <= FLines.Count) then
begin
LTextPosition.Char := FBookmarks[ABookmark].Char;
LTextPosition.Line := FBookmarks[ABookmark].Line;
GotoLineAndCenter(LTextPosition.Line);
if SelectionAvailable then
InvalidateSelection;
FSelectionBeginPosition := TextCaretPosition;
FSelectionEndPosition := FSelectionBeginPosition;
end;
end;
procedure TBCBaseEditor.GotoLineAndCenter(ATextLine: Integer);
var
i: Integer;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
LTextCaretPosition: TBCEditorTextPosition;
begin
if FCodeFolding.Visible then
for i := 0 to FAllCodeFoldingRanges.AllCount - 1 do
begin
LCodeFoldingRange := FAllCodeFoldingRanges[i];
if LCodeFoldingRange.FromLine > ATextLine then
Break
else
if (LCodeFoldingRange.FromLine <= ATextLine) and LCodeFoldingRange.Collapsed then
CodeFoldingUncollapse(LCodeFoldingRange);
end;
LTextCaretPosition := GetTextPosition(1, ATextLine);
TopLine := Max(LTextCaretPosition.Line - FVisibleLines div 2, 1);
SetTextCaretPosition(LTextCaretPosition);
if SelectionAvailable then
InvalidateSelection;
FSelectionBeginPosition := LTextCaretPosition;
FSelectionEndPosition := FSelectionBeginPosition;
EnsureCursorPositionVisible(True);
end;
procedure TBCBaseEditor.HookEditorLines(ALines: TBCEditorLines; AUndo, ARedo: TBCEditorUndoList);
var
LOldWrap: Boolean;
begin
Assert(not Assigned(FChainedEditor));
Assert(FLines = FOriginalLines);
LOldWrap := FWordWrap.Enabled;
UpdateWordWrap(False);
if Assigned(FChainedEditor) then
RemoveChainedEditor
else
if FLines <> FOriginalLines then
UnhookEditorLines;
FOnChainLinesCleared := ALines.OnCleared;
ALines.OnCleared := ChainLinesCleared;
FOnChainLinesDeleted := ALines.OnDeleted;
ALines.OnDeleted := ChainLinesDeleted;
FOnChainLinesInserted := ALines.OnInserted;
ALines.OnInserted := ChainLinesInserted;
FOnChainLinesPutted := ALines.OnPutted;
ALines.OnPutted := ChainLinesPutted;
FOnChainLinesChanging := ALines.OnChanging;
ALines.OnChanging := ChainLinesChanging;
FOnChainLinesChanged := ALines.OnChange;
ALines.OnChange := ChainLinesChanged;
FOnChainUndoAdded := AUndo.OnAddedUndo;
AUndo.OnAddedUndo := ChainUndoRedoAdded;
FOnChainRedoAdded := ARedo.OnAddedUndo;
ARedo.OnAddedUndo := ChainUndoRedoAdded;
FLines := ALines;
FUndoList := AUndo;
FRedoList := ARedo;
LinesHookChanged;
UpdateWordWrap(LOldWrap);
end;
procedure TBCBaseEditor.InsertLine(const ALineNumber: Integer; const AValue: string);
var
LTextCaretPosition: TBCEditorTextPosition;
begin
FLines.BeginUpdate;
FLines.Insert(ALineNumber - 1, AValue);
FLines.EndUpdate;
LTextCaretPosition.Char := 1;
LTextCaretPosition.Line := ALineNumber - 1;
FUndoList.AddChange(crLineBreak, LTextCaretPosition, LTextCaretPosition,
GetTextPosition(Length(AValue) + 1, LTextCaretPosition.Line), AValue, smNormal);
RescanCodeFoldingRanges;
ScanMatchingPair;
end;
procedure TBCBaseEditor.InitCodeFolding;
begin
if FCodeFoldingLock then
Exit;
ClearCodeFolding;
if Visible then
CreateLineNumbersCache(True);
ScanCodeFoldingRanges;
CodeFoldingResetCaches;
end;
procedure TBCBaseEditor.InsertBlock(const ABlockBeginPosition, ABlockEndPosition: TBCEditorTextPosition;
AChangeStr: PChar; AAddToUndoList: Boolean);
var
LSelectionMode: TBCEditorSelectionMode;
begin
LSelectionMode := FSelection.ActiveMode;
SetCaretAndSelection(ABlockBeginPosition, ABlockBeginPosition, ABlockEndPosition);
FSelection.ActiveMode := smColumn;
DoSelectedText(smColumn, AChangeStr, AAddToUndoList);
FSelection.ActiveMode := LSelectionMode;
end;
procedure TBCBaseEditor.InvalidateLeftMargin;
begin
InvalidateLeftMarginLines(-1, -1);
end;
procedure TBCBaseEditor.InvalidateLeftMarginLine(ALine: Integer);
begin
if (ALine < 1) or (ALine > FLines.Count) then
Exit;
InvalidateLeftMarginLines(ALine, ALine);
end;
procedure TBCBaseEditor.InvalidateLeftMarginLines(AFirstLine, ALastLine: Integer);
var
LInvalidationRect: TRect;
LWidth: Integer;
begin
if Visible and HandleAllocated then
begin
LWidth := 0;
if FMinimap.Align = maLeft then
Inc(LWidth, FMinimap.GetWidth);
if FSearch.Map.Align = saLeft then
Inc(LWidth, FSearch.Map.GetWidth);
if (AFirstLine = -1) and (ALastLine = -1) then
begin
LInvalidationRect := Rect(LWidth, 0, LWidth + FLeftMargin.GetWidth, ClientHeight);
if sfLinesChanging in FStateFlags then
UnionRect(FInvalidateRect, FInvalidateRect, LInvalidationRect)
else
InvalidateRect(LInvalidationRect);
end
else
begin
if ALastLine < AFirstLine then
SwapInt(ALastLine, AFirstLine);
AFirstLine := Max(AFirstLine, TopLine);
ALastLine := Min(ALastLine, TopLine + VisibleLines);
if FWordWrap.Enabled then
if ALastLine > FLines.Count then
ALastLine := TopLine + VisibleLines;
if ALastLine >= AFirstLine then
begin
LInvalidationRect := Rect(LWidth, FLineHeight * (AFirstLine - TopLine),
LWidth + FLeftMargin.GetWidth, FLineHeight * (ALastLine - TopLine + 1));
if sfLinesChanging in FStateFlags then
UnionRect(FInvalidateRect, FInvalidateRect, LInvalidationRect)
else
InvalidateRect(LInvalidationRect);
end;
end;
end;
end;
procedure TBCBaseEditor.InvalidateLine(ALine: Integer);
var
LInvalidationRect: TRect;
begin
if (not HandleAllocated) or (ALine < 1) or (ALine > FLines.Count) or (not Visible) or FMouseMoveScrolling then
Exit;
if FWordWrap.Enabled then
begin
InvalidateLines(ALine, ALine);
Exit;
end;
if (ALine >= TopLine) and (ALine <= TopLine + VisibleLines) then
begin
LInvalidationRect := Rect(0, FLineHeight * (ALine - TopLine), ClientWidth, 0);
LInvalidationRect.Bottom := LInvalidationRect.Top + FLineHeight;
DeflateMinimapRect(LInvalidationRect);
if sfLinesChanging in FStateFlags then
UnionRect(FInvalidateRect, FInvalidateRect, LInvalidationRect)
else
InvalidateRect(LInvalidationRect);
end;
end;
procedure TBCBaseEditor.InvalidateLines(AFirstLine, ALastLine: Integer);
var
LInvalidationRect: TRect;
begin
if FMouseMoveScrolling then
Exit;
if Visible and HandleAllocated then
begin
if (AFirstLine = -1) and (ALastLine = -1) then
begin
LInvalidationRect := ClientRect;
DeflateMinimapRect(LInvalidationRect);
if sfLinesChanging in FStateFlags then
UnionRect(FInvalidateRect, FInvalidateRect, LInvalidationRect)
else
InvalidateRect(LInvalidationRect);
end
else
begin
AFirstLine := Max(AFirstLine, 1);
ALastLine := Max(ALastLine, 1);
if ALastLine < AFirstLine then
SwapInt(ALastLine, AFirstLine);
AFirstLine := Max(AFirstLine, TopLine);
ALastLine := Min(ALastLine, TopLine + VisibleLines);
if FWordWrap.Enabled then
if ALastLine > FLines.Count then
ALastLine := TopLine + VisibleLines;
if ALastLine >= AFirstLine then
begin
LInvalidationRect := Rect(0, FLineHeight * (AFirstLine - TopLine), ClientWidth,
FLineHeight * (ALastLine - TopLine + 1));
DeflateMinimapRect(LInvalidationRect);
if sfLinesChanging in FStateFlags then
UnionRect(FInvalidateRect, FInvalidateRect, LInvalidationRect)
else
InvalidateRect(LInvalidationRect);
end;
end;
end;
end;
procedure TBCBaseEditor.InvalidateMinimap;
var
LInvalidationRect: TRect;
LRectLeft, LRectRight: Integer;
begin
FMinimapBufferBmp.Height := 0;
GetMinimapLeftRight(LRectLeft, LRectRight);
LInvalidationRect := Rect(LRectLeft, 0, LRectRight, ClientHeight);
InvalidateRect(LInvalidationRect);
end;
procedure TBCBaseEditor.InvalidateSelection;
begin
InvalidateLines(SelectionBeginPosition.Line, SelectionEndPosition.Line);
end;
procedure TBCBaseEditor.LeftMarginChanged(Sender: TObject);
var
LWidth: Integer;
begin
if not (csLoading in ComponentState) and Assigned(FHighlighter) and not FHighlighter.Loading then
begin
if FLeftMargin.LineNumbers.Visible and FLeftMargin.Autosize then
FLeftMargin.AutosizeDigitCount(Lines.Count);
if FLeftMargin.Autosize then
begin
FTextDrawer.SetBaseFont(FLeftMargin.Font);
LWidth := FLeftMargin.RealLeftMarginWidth(FTextDrawer.CharWidth);
FLeftMarginCharWidth := FTextDrawer.CharWidth;
FTextDrawer.SetBaseFont(Font);
SetLeftMarginWidth(LWidth);
end
else
SetLeftMarginWidth(FLeftMargin.GetWidth);
Invalidate;
end;
end;
procedure TBCBaseEditor.LoadFromFile(const AFileName: string; AEncoding: System.SysUtils.TEncoding = nil);
var
LFileStream: TFileStream;
begin
LFileStream := TFileStream.Create(AFileName, fmOpenRead);
try
LoadFromStream(LFileStream, AEncoding);
finally
LFileStream.Free;
end;
end;
procedure TBCBaseEditor.LoadFromStream(AStream: TStream; AEncoding: System.SysUtils.TEncoding = nil);
var
LBuffer: TBytes;
LWithBOM: Boolean;
LWordWrapEnabled: Boolean;
begin
FEncoding := nil;
ClearMatchingPair;
LWordWrapEnabled := FWordWrap.Enabled;
FWordWrap.Enabled := False;
ClearCodeFolding;
ClearBookmarks;
if Assigned(AEncoding) then
FEncoding := AEncoding
else
{ Identify encoding }
if IsUTF8(AStream, LWithBOM) then
begin
if LWithBOM then
FEncoding := TEncoding.UTF8
else
FEncoding := BCEditor.Encoding.TEncoding.UTF8WithoutBOM;
end
else
{ Read file into buffer }
begin
SetLength(LBuffer, AStream.Size);
AStream.ReadBuffer(pointer(LBuffer)^, Length(LBuffer));
TEncoding.GetBufferEncoding(LBuffer, FEncoding);
end;
AStream.Position := 0;
FLines.LoadFromStream(AStream, FEncoding);
CreateLineNumbersCache(True);
if FCodeFolding.Visible then
begin
ScanCodeFoldingRanges;
CodeFoldingResetCaches;
end;
if CanFocus then
SetFocus;
FWordWrap.Enabled := LWordWrapEnabled;
SizeOrFontChanged(True);
Invalidate;
end;
procedure TBCBaseEditor.LockUndo;
begin
FUndoList.Lock;
FRedoList.Lock;
end;
procedure TBCBaseEditor.Notification(AComponent: TComponent; AOperation: TOperation);
begin
inherited Notification(AComponent, AOperation);
if AOperation = opRemove then
begin
if AComponent = FChainedEditor then
RemoveChainedEditor;
if Assigned(FLeftMargin) then
if Assigned(FLeftMargin.Bookmarks) then
if Assigned(FLeftMargin.Bookmarks.Images) then
if (AComponent = FLeftMargin.Bookmarks.Images) then
begin
FLeftMargin.Bookmarks.Images := nil;
InvalidateLeftMarginLines(-1, -1);
end;
end;
end;
procedure TBCBaseEditor.PasteFromClipboard;
begin
CommandProcessor(ecPaste, BCEDITOR_NONE_CHAR, nil);
end;
procedure TBCBaseEditor.DoPasteFromClipboard;
var
LClipBoardText: string;
LTextCaretPosition: TBCEditorTextPosition;
LStartPositionOfBlock: TBCEditorTextPosition;
LEndPositionOfBlock: TBCEditorTextPosition;
LPasteMode: TBCEditorSelectionMode;
LLength, LCharCount: Integer;
LSpaces: string;
begin
LTextCaretPosition := TextCaretPosition;
LPasteMode := FSelection.Mode;
FUndoList.BeginBlock;
LLength := FLines.StringLength(LTextCaretPosition.Line);
if SelectionAvailable then
FUndoList.AddChange(crDelete, LTextCaretPosition, SelectionBeginPosition, SelectionEndPosition, GetSelectedText,
FSelection.ActiveMode)
else
begin
FSelection.ActiveMode := Selection.Mode;
if LTextCaretPosition.Char > LLength + 1 then
begin
LCharCount := LTextCaretPosition.Char - LLength - 1;
if toTabsToSpaces in FTabs.Options then
LSpaces := StringOfChar(BCEDITOR_SPACE_CHAR, LCharCount)
else
begin
LSpaces := StringOfChar(BCEDITOR_TAB_CHAR, LCharCount div FTabs.Width);
LSpaces := LSpaces + StringOfChar(BCEDITOR_TAB_CHAR, LCharCount mod FTabs.Width);
end;
FUndoList.AddChange(crInsert, GetTextPosition(LLength + 1, LTextCaretPosition.Line),
GetTextPosition(LLength + 1, LTextCaretPosition.Line),
GetTextPosition(LLength + Length(LSpaces) + 1, LTextCaretPosition.Line), '', FSelection.ActiveMode);
LTextCaretPosition.Char := LLength + Length(LSpaces) + 1;
end;
end;
LClipBoardText := GetClipboardText;
if SelectionAvailable then
begin
LStartPositionOfBlock := SelectionBeginPosition;
LEndPositionOfBlock := SelectionEndPosition;
FSelectionBeginPosition := LStartPositionOfBlock;
FSelectionEndPosition := LEndPositionOfBlock;
if FSyncEdit.Active then
FSyncEdit.MoveEndPositionChar(-FSelectionEndPosition.Char + FSelectionBeginPosition.Char + Length(LClipBoardText));
end
else
begin
LStartPositionOfBlock := LTextCaretPosition;
if FSyncEdit.Active then
FSyncEdit.MoveEndPositionChar(Length(LClipBoardText));
end;
DoSelectedText(LPasteMode, PChar(LClipBoardText), True);
LEndPositionOfBlock := SelectionEndPosition;
FUndoList.AddChange(crPaste, LTextCaretPosition, LStartPositionOfBlock, LEndPositionOfBlock, SelectedText, LPasteMode);
FUndoList.EndBlock;
if FSyncEdit.Active then
DoSyncEdit;
EnsureCursorPositionVisible;
Invalidate;
end;
procedure TBCBaseEditor.DoRedo;
begin
CommandProcessor(ecRedo, BCEDITOR_NONE_CHAR, nil);
end;
procedure TBCBaseEditor.DoInternalRedo;
procedure RemoveGroupBreak;
var
LRedoItem: TBCEditorUndoItem;
begin
if FRedoList.LastChangeReason = crGroupBreak then
begin
LRedoItem := FRedoList.PopItem;
try
FUndoList.AddGroupBreak;
finally
LRedoItem.Free;
end;
UpdateModifiedStatus;
end;
end;
var
LRedoItem: TBCEditorUndoItem;
LLastChangeBlockNumber: Integer;
LLastChangeReason: TBCEditorChangeReason;
LLastChangeString: string;
LPasteAction: Boolean;
LKeepGoing: Boolean;
begin
if ReadOnly then
Exit;
LLastChangeBlockNumber := FRedoList.LastChangeBlockNumber;
LLastChangeReason := FRedoList.LastChangeReason;
LLastChangeString := FRedoList.LastChangeString;
LPasteAction := LLastChangeReason = crPaste;
LRedoItem := FRedoList.PeekItem;
if Assigned(LRedoItem) then
begin
repeat
RedoItem;
LRedoItem := FRedoList.PeekItem;
LKeepGoing := False;
if Assigned(LRedoItem) then
begin
if uoGroupUndo in FUndo.Options then
LKeepGoing := LPasteAction and (FRedoList.LastChangeString = LLastChangeString) or
(LLastChangeReason = LRedoItem.ChangeReason) and (LRedoItem.ChangeBlockNumber = LLastChangeBlockNumber) or
(LRedoItem.ChangeBlockNumber <> 0) and (LRedoItem.ChangeBlockNumber = LLastChangeBlockNumber);
LLastChangeReason := LRedoItem.ChangeReason;
LPasteAction := LLastChangeReason = crPaste;
end;
until not LKeepGoing;
RemoveGroupBreak;
end;
end;
procedure TBCBaseEditor.DoLineComment;
var
i: Integer;
LLength: Integer;
LLine, LEndLine: Integer;
LCommentIndex: Integer;
LSpaceCount: Integer;
LSpaces: string;
LLineText: string;
LComment: string;
LTextCaretPosition, LSelectionBeginPosition, LSelectionEndPosition: TBCEditorTextPosition;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
begin
LLength := Length(FHighlighter.Comments.LineComments);
if LLength > 0 then
begin
LTextCaretPosition := TextCaretPosition;
LSelectionBeginPosition := SelectionBeginPosition;
LSelectionEndPosition := SelectionEndPosition;
if SelectionAvailable then
begin
LLine := LSelectionBeginPosition.Line;
LEndLine := LSelectionEndPosition.Line;
end
else
begin
LLine := LTextCaretPosition.Line;
LEndLine := LLine;
end;
FLines.BeginUpdate;
FUndoList.BeginBlock;
for LLine := LLine to LEndLine do
begin
LCodeFoldingRange := CodeFoldingRangeForLine(LLine + 1);
if Assigned(LCodeFoldingRange) and LCodeFoldingRange.Collapsed then
CodeFoldingUncollapse(LCodeFoldingRange);
i := 0;
LCommentIndex := -1;
LLineText := FLines[LLine];
LSpaceCount := LeftSpaceCount(LLineText, False);
LSpaces := Copy(LLineText, 1, LSpaceCount);
LLineText := TrimLeft(LLineText);
if LLineText <> '' then
while i < LLength do
begin
if Pos(FHighlighter.Comments.LineComments[i], LLineText) = 1 then
begin
LCommentIndex := i;
Break;
end;
Inc(i);
end;
if LCommentIndex <> -1 then
begin
LComment := FHighlighter.Comments.LineComments[LCommentIndex];
FUndoList.AddChange(crDelete, LTextCaretPosition, GetTextPosition(1 + LSpaceCount, LLine),
GetTextPosition(Length(LComment) + 1 + LSpaceCount, LLine), LComment, smNormal);
LLineText := Copy(LLineText, Length(FHighlighter.Comments.LineComments[LCommentIndex]) + 1, Length(LLineText));
end;
Inc(LCommentIndex);
LComment := '';
if LCommentIndex < LLength then
LComment := FHighlighter.Comments.LineComments[LCommentIndex];
LLineText := LComment + LSpaces + LLineText;
FLines.Strings[LLine] := LLineText;
FUndoList.AddChange(crInsert, LTextCaretPosition, GetTextPosition(1, LLine),
GetTextPosition(Length(LComment) + 1, LLine), '', smNormal);
if not SelectionAvailable then
begin
Inc(LTextCaretPosition.Line);
TextCaretPosition := LTextCaretPosition;
end;
end;
FUndoList.EndBlock;
FLines.EndUpdate;
FSelectionBeginPosition := LSelectionBeginPosition;
FSelectionEndPosition := LSelectionEndPosition;
if SelectionAvailable then
TextCaretPosition := LTextCaretPosition;
RescanCodeFoldingRanges;
ScanMatchingPair;
end;
end;
procedure TBCBaseEditor.RegisterCommandHandler(const AHookedCommandEvent: TBCEditorHookedCommandEvent; AHandlerData: Pointer);
begin
if not Assigned(AHookedCommandEvent) then
Exit;
if not Assigned(FHookedCommandHandlers) then
FHookedCommandHandlers := TObjectList.Create;
if FindHookedCommandEvent(AHookedCommandEvent) = -1 then
FHookedCommandHandlers.Add(TBCEditorHookedCommandHandler.Create(AHookedCommandEvent, AHandlerData))
end;
procedure TBCBaseEditor.RemoveChainedEditor;
begin
if Assigned(FChainedEditor) then
RemoveFreeNotification(FChainedEditor);
FChainedEditor := nil;
UnhookEditorLines;
end;
procedure TBCBaseEditor.RemoveKeyDownHandler(AHandler: TKeyEvent);
begin
FKeyboardHandler.RemoveKeyDownHandler(AHandler);
end;
procedure TBCBaseEditor.RemoveKeyPressHandler(AHandler: TBCEditorKeyPressWEvent);
begin
FKeyboardHandler.RemoveKeyPressHandler(AHandler);
end;
procedure TBCBaseEditor.RemoveKeyUpHandler(AHandler: TKeyEvent);
begin
FKeyboardHandler.RemoveKeyUpHandler(AHandler);
end;
procedure TBCBaseEditor.RemoveMouseCursorHandler(AHandler: TBCEditorMouseCursorEvent);
begin
FKeyboardHandler.RemoveMouseCursorHandler(AHandler);
end;
procedure TBCBaseEditor.RemoveMouseDownHandler(AHandler: TMouseEvent);
begin
FKeyboardHandler.RemoveMouseDownHandler(AHandler);
end;
procedure TBCBaseEditor.RemoveMouseUpHandler(AHandler: TMouseEvent);
begin
FKeyboardHandler.RemoveMouseUpHandler(AHandler);
end;
procedure TBCBaseEditor.ReplaceLine(const ALineNumber: Integer; const AValue: string);
var
LTextCaretPosition: TBCEditorTextPosition;
begin
LTextCaretPosition.Char := 1;
LTextCaretPosition.Line := ALineNumber - 1;
FUndoList.AddChange(crPaste, LTextCaretPosition, GetTextPosition(1, ALineNumber - 1),
GetTextPosition(Length(AValue) + 1, ALineNumber - 1), FLines.Strings[ALineNumber - 1], FSelection.ActiveMode);
FLines.BeginUpdate;
FLines.Strings[ALineNumber - 1] := AValue;
FLines.EndUpdate;
RescanCodeFoldingRanges;
ScanMatchingPair;
end;
procedure TBCBaseEditor.RescanCodeFoldingRanges;
var
i: Integer;
LCodeFoldingRange: TBCEditorCodeFoldingRange;
LLengthCodeFoldingRangeFromLine, LLengthCodeFoldingRangeToLine: Integer;
begin
FRescanCodeFolding := False;
LLengthCodeFoldingRangeFromLine := Length(FCodeFoldingRangeFromLine);
LLengthCodeFoldingRangeToLine := Length(FCodeFoldingRangeToLine);
{ Delete all uncollapsed folds }
for i := FAllCodeFoldingRanges.AllCount - 1 downto 0 do
begin
LCodeFoldingRange := FAllCodeFoldingRanges[i];
if Assigned(LCodeFoldingRange) then
begin
if not LCodeFoldingRange.Collapsed and not LCodeFoldingRange.ParentCollapsed then
begin
if (LCodeFoldingRange.FromLine > 0) and (LCodeFoldingRange.FromLine <= LLengthCodeFoldingRangeFromLine) then
FCodeFoldingRangeFromLine[LCodeFoldingRange.FromLine] := nil;
if (LCodeFoldingRange.ToLine > 0) and (LCodeFoldingRange.ToLine <= LLengthCodeFoldingRangeToLine) then
FCodeFoldingRangeToLine[LCodeFoldingRange.ToLine] := nil;
FreeAndNil(LCodeFoldingRange);
FAllCodeFoldingRanges.List.Delete(i);
end
end;
end;
ScanCodeFoldingRanges;
CodeFoldingResetCaches;
Invalidate;
end;
procedure TBCBaseEditor.SaveToFile(const AFileName: string; AEncoding: System.SysUtils.TEncoding = nil);
var
LFileStream: TFileStream;
begin
LFileStream := TFileStream.Create(AFileName, fmCreate);
try
SaveToStream(LFileStream, AEncoding);
finally
LFileStream.Free;
end;
end;
procedure TBCBaseEditor.SaveToStream(AStream: TStream; AEncoding: System.SysUtils.TEncoding = nil);
begin
if Assigned(AEncoding) then
FEncoding := AEncoding;
FLines.SaveToStream(AStream, FEncoding);
Modified := False;
end;
procedure TBCBaseEditor.SelectAll;
var
LOldCaretPosition, LLastTextPosition: TBCEditorTextPosition;
begin
LOldCaretPosition := TextCaretPosition;
LLastTextPosition.Char := 1;
LLastTextPosition.Line := FLines.Count - 1;
if LLastTextPosition.Line >= 0 then
Inc(LLastTextPosition.Char, Length(Lines[LLastTextPosition.Line]))
else
LLastTextPosition.Line := 0;
SetCaretAndSelection(LOldCaretPosition, GetTextPosition(1, 0), LLastTextPosition);
FLastSortOrder := soDesc;
Invalidate;
end;
procedure TBCBaseEditor.SetBookmark(AIndex: Integer; ATextPosition: TBCEditorTextPosition);
var
LBookmark: TBCEditorBookmark;
begin
if (AIndex in [0 .. 8]) and (ATextPosition.Line >= 0) and (ATextPosition.Line <= Max(0, FLines.Count - 1)) then
begin
LBookmark := TBCEditorBookmark.Create(Self);
with LBookmark do
begin
Line := ATextPosition.Line;
Char := ATextPosition.Char;
ImageIndex := AIndex;
Index := AIndex;
Visible := True;
InternalImage := not Assigned(FLeftMargin.Bookmarks.Images);
end;
DoOnBeforeBookmarkPlaced(LBookmark);
if Assigned(LBookmark) then
begin
if Assigned(FBookmarks[AIndex]) then
ClearBookmark(AIndex);
FBookmarks[AIndex] := LBookmark;
FMarkList.Add(FBookmarks[AIndex]);
end;
DoOnAfterBookmarkPlaced;
end;
end;
procedure TBCBaseEditor.SetCaretAndSelection(ACaretPosition, ABlockBeginPosition, ABlockEndPosition: TBCEditorTextPosition);
var
LOldSelectionMode: TBCEditorSelectionMode;
begin
LOldSelectionMode := FSelection.ActiveMode;
IncPaintLock;
try
TextCaretPosition := ACaretPosition;
SetSelectionBeginPosition(ABlockBeginPosition);
SetSelectionEndPosition(ABlockEndPosition);
finally
FSelection.ActiveMode := LOldSelectionMode;
DecPaintLock;
end;
end;
procedure TBCBaseEditor.SetFocus;
begin
Winapi.Windows.SetFocus(Handle);
inherited;
end;
procedure TBCBaseEditor.SetLineColor(ALine: Integer; AForegroundColor, ABackgroundColor: TColor);
begin
if (ALine >= 0) and (ALine < FLines.Count) then
begin
FLines.Attributes[ALine].Foreground := AForegroundColor;
FLines.Attributes[ALine].Background := ABackgroundColor;
InvalidateLine(ALine + 1);
end;
end;
procedure TBCBaseEditor.SetLineColorToDefault(ALine: Integer);
begin
if (ALine >= 0) and (ALine < FLines.Count) then
InvalidateLine(ALine + 1);
end;
procedure TBCBaseEditor.Sort(ASortOrder: TBCEditorSortOrder = soToggle);
var
i, LLastLength: Integer;
S: string;
LStringList: TStringList;
LOldSelectionBeginPosition, LOldSelectionEndPosition: TBCEditorTextPosition;
begin
LStringList := TStringList.Create;
try
if SelectionAvailable then
LStringList.Text := SelectedText
else
LStringList.Text := Text;
LStringList.Sort;
S := '';
if (ASortOrder = soDesc) or (ASortOrder = soToggle) and (FLastSortOrder = soAsc) then
begin
FLastSortOrder := soDesc;
for i := LStringList.Count - 1 downto 0 do
begin
S := S + LStringList.Strings[i];
if i <> 0 then
S := S + Chr(13) + Chr(10);
end;
end
else
begin
FLastSortOrder := soAsc;
S := LStringList.Text;
end;
S := TrimRight(S);
LStringList.Text := S;
if SelectionAvailable then
begin
LOldSelectionBeginPosition := GetSelectionBeginPosition;
LOldSelectionEndPosition := GetSelectionEndPosition;
SelectedText := S;
FSelectionBeginPosition := LOldSelectionBeginPosition;
FSelectionEndPosition := LOldSelectionEndPosition;
LLastLength := Length(LStringList.Strings[LStringList.Count - 1]) + 1;
FSelectionEndPosition.Char := LLastLength
end
else
Text := S;
finally
LStringList.Free;
if FCodeFolding.Visible then
RescanCodeFoldingRanges;
end;
end;
procedure TBCBaseEditor.ToggleBookmark(AIndex: Integer = -1);
var
i: Integer;
LTextPosition: TBCEditorTextPosition;
LMark: TBCEditorBookmark;
begin
if AIndex <> -1 then
begin
if not GetBookmark(AIndex, LTextPosition) then
SetBookmark(AIndex, TextCaretPosition)
else
ClearBookmark(AIndex);
end
else
begin
for i := 0 to Marks.Count - 1 do
begin
LMark := Marks[i];
if GetTextCaretY = LMark.Line then
begin
ClearBookmark(LMark.Index);
Exit;
end;
end;
LTextPosition := TextCaretPosition;
for i := 0 to 8 do
if not GetBookmark(i, LTextPosition) then { variables used because X and Y are var parameters }
begin
SetBookmark(i, TextCaretPosition);
Exit;
end;
end;
end;
procedure TBCBaseEditor.UnhookEditorLines;
var
LOldWrap: Boolean;
begin
Assert(not Assigned(FChainedEditor));
if FLines = FOriginalLines then
Exit;
LOldWrap := FWordWrap.Enabled;
UpdateWordWrap(False);
with FLines do
begin
OnCleared := FOnChainLinesCleared;
OnDeleted := FOnChainLinesDeleted;
OnInserted := FOnChainLinesInserted;
OnPutted := FOnChainLinesPutted;
OnChanging := FOnChainLinesChanging;
OnChange := FOnChainLinesChanged;
end;
FUndoList.OnAddedUndo := FOnChainUndoAdded;
FRedoList.OnAddedUndo := FOnChainRedoAdded;
FOnChainLinesCleared := nil;
FOnChainLinesDeleted := nil;
FOnChainLinesInserted := nil;
FOnChainLinesPutted := nil;
FOnChainLinesChanging := nil;
FOnChainLinesChanged := nil;
FOnChainUndoAdded := nil;
FLines := FOriginalLines;
FUndoList := FOriginalUndoList;
FRedoList := FOriginalRedoList;
LinesHookChanged;
UpdateWordWrap(LOldWrap);
end;
procedure TBCBaseEditor.ToggleSelectedCase(ACase: TBCEditorCase = cNone);
var
LSelectionStart, LSelectionEnd: TBCEditorTextPosition;
begin
if AnsiUpperCase(SelectedText) <> AnsiUpperCase(FSelectedCaseText) then
begin
FSelectedCaseCycle := cUpper;
FSelectedCaseText := SelectedText;
end;
if ACase <> cNone then
FSelectedCaseCycle := ACase;
BeginUpdate;
LSelectionStart := SelectionBeginPosition;
LSelectionEnd := SelectionEndPosition;
case FSelectedCaseCycle of
cUpper: { UPPERCASE }
if FSelection.ActiveMode = smColumn then
CommandProcessor(ecUpperCaseBlock, BCEDITOR_NONE_CHAR, nil)
else
CommandProcessor(ecUpperCase, BCEDITOR_NONE_CHAR, nil);
cLower: { lowercase }
if FSelection.ActiveMode = smColumn then
CommandProcessor(ecLowerCaseBlock, BCEDITOR_NONE_CHAR, nil)
else
CommandProcessor(ecLowerCase, BCEDITOR_NONE_CHAR, nil);
cAlternating: { aLtErNaTiNg cAsE }
if FSelection.ActiveMode = smColumn then
CommandProcessor(ecAlternatingCaseBlock, BCEDITOR_NONE_CHAR, nil)
else
CommandProcessor(ecAlternatingCase, BCEDITOR_NONE_CHAR, nil);
cSentence: { Sentence case }
CommandProcessor(ecSentenceCase, BCEDITOR_NONE_CHAR, nil);
cTitle: { Title Case }
CommandProcessor(ecTitleCase, BCEDITOR_NONE_CHAR, nil);
cOriginal: { Original text }
SelectedText := FSelectedCaseText;
end;
SelectionBeginPosition := LSelectionStart;
SelectionEndPosition := LSelectionEnd;
EndUpdate;
Inc(FSelectedCaseCycle);
if FSelectedCaseCycle > cOriginal then
FSelectedCaseCycle := cUpper;
end;
procedure TBCBaseEditor.UnlockUndo;
begin
FUndoList.Unlock;
FRedoList.Unlock;
end;
procedure TBCBaseEditor.UnregisterCommandHandler(AHookedCommandEvent: TBCEditorHookedCommandEvent);
var
i: Integer;
begin
if not Assigned(AHookedCommandEvent) then
Exit;
i := FindHookedCommandEvent(AHookedCommandEvent);
if i > -1 then
FHookedCommandHandlers.Delete(i)
end;
procedure TBCBaseEditor.UpdateCaret;
var
X, Y: Integer;
LClientRect: TRect;
LCaretDisplayPosition: TBCEditorDisplayPosition;
LCaretTextPosition: TBCEditorTextPosition;
LCaretPoint: TPoint;
LCompositionForm: TCompositionForm;
LCaretStyle: TBCEditorCaretStyle;
begin
if (PaintLock <> 0) or not (Focused or FAlwaysShowCaret) then
Include(FStateFlags, sfCaretChanged)
else
begin
Exclude(FStateFlags, sfCaretChanged);
LCaretDisplayPosition := DisplayCaretPosition;
if FWordWrap.Enabled then
begin
if FWordWrapLineLengths[LCaretDisplayPosition.Row] = 0 then
begin
if LCaretDisplayPosition.Column > VisibleChars + 1 then
LCaretDisplayPosition.Column := VisibleChars + 1;
end
else
if LCaretDisplayPosition.Column > FWordWrapLineLengths[LCaretDisplayPosition.Row] + 1 then
LCaretDisplayPosition.Column := FWordWrapLineLengths[LCaretDisplayPosition.Row] + 1;
end;
LCaretPoint := RowColumnToPixels(LCaretDisplayPosition);
X := LCaretPoint.X + FCaretOffset.X;
if InsertMode then
LCaretStyle := FCaret.Styles.Insert
else
LCaretStyle := FCaret.Styles.Overwrite;
if LCaretStyle in [csHorizontalLine, csThinHorizontalLine, csHalfBlock, csBlock] then
X := X + 1;
Y := LCaretPoint.Y + FCaretOffset.Y;
LClientRect := ClientRect;
DeflateMinimapRect(LClientRect);
SetCaretPos(X, Y);
if (X >= LClientRect.Left + FLeftMargin.GetWidth + FCodeFolding.GetWidth) and (X < LClientRect.Right) and (Y >= LClientRect.Top) and (Y < LClientRect.Bottom) then
ShowCaret
else
HideCaret;
LCompositionForm.dwStyle := CFS_POINT;
LCompositionForm.ptCurrentPos := Point(X, Y);
ImmSetCompositionWindow(ImmGetContext(Handle), @LCompositionForm);
if Assigned(FOnCaretChanged) then
begin
LCaretTextPosition := TextCaretPosition;
FOnCaretChanged(Self, LCaretTextPosition.Char, LCaretTextPosition.Line + FLeftMargin.LineNumbers.StartFrom);
end;
end;
end;
function IsTextMessage(AMessage: Cardinal): Boolean;
begin
Result := (AMessage = WM_SETTEXT) or (AMessage = WM_GETTEXT) or (AMessage = WM_GETTEXTLENGTH);
end;
procedure TBCBaseEditor.WndProc(var AMessage: TMessage);
const
ALT_KEY_DOWN = $20000000;
begin
{ Prevent Alt-Backspace from beeping }
if (AMessage.Msg = WM_SYSCHAR) and (AMessage.wParam = VK_BACK) and (AMessage.LParam and ALT_KEY_DOWN <> 0) then
AMessage.Msg := 0;
{ handle direct WndProc calls that could happen through VCL-methods like Perform }
if HandleAllocated and IsWindowUnicode(Handle) then
begin
if not FWindowProducedMessage then
begin
FWindowProducedMessage := True;
if IsTextMessage(AMessage.Msg) then
begin
with AMessage do
Result := SendMessageA(Handle, Msg, wParam, LParam);
Exit;
end;
end
else
FWindowProducedMessage := False;
end;
{$IFDEF USE_ALPHASKINS}
if AMessage.Msg = SM_ALPHACMD then
case AMessage.WParamHi of
AC_CTRLHANDLED:
begin
AMessage.Result := 1;
Exit;
end;
AC_GETAPPLICATION:
begin
AMessage.Result := LRESULT(Application);
Exit
end;
AC_REMOVESKIN:
if (ACUInt(AMessage.LParam) = ACUInt(SkinData.SkinManager)) and not(csDestroying in ComponentState) then
begin
if FScrollWnd <> nil then
FreeAndNil(FScrollWnd);
CommonWndProc(AMessage, FCommonData);
RecreateWnd;
Exit;
end;
AC_REFRESH:
if (ACUInt(AMessage.LParam) = ACUInt(SkinData.SkinManager)) and Visible then
begin
CommonWndProc(AMessage, FCommonData);
RefreshEditScrolls(SkinData, FScrollWnd);
SendMessage(Handle, WM_NCPAINT, 0, 0);
Exit;
end;
AC_SETNEWSKIN:
if (ACUInt(AMessage.LParam) = ACUInt(SkinData.SkinManager)) then
begin
CommonWndProc(AMessage, FCommonData);
Exit;
end;
end;
if not ControlIsReady(Self) or not Assigned(FCommonData) or not FCommonData.Skinned then
inherited
else
begin
if AMessage.Msg = SM_ALPHACMD then
case AMessage.WParamHi of
AC_ENDPARENTUPDATE:
if FCommonData.Updating then
begin
if not InUpdating(FCommonData, True) then
Perform(WM_NCPAINT, 0, 0);
Exit;
end;
end;
CommonWndProc(AMessage, FCommonData);
inherited;
case AMessage.Msg of
TB_SETANCHORHIGHLIGHT, WM_SIZE:
SendMessage(Handle, WM_NCPAINT, 0, 0);
CM_SHOWINGCHANGED:
RefreshEditScrolls(SkinData, FScrollWnd);
end;
end;
{$ELSE}
inherited;
{$ENDIF}
end;
initialization
{$IFDEF USE_VCL_STYLES}
TCustomStyleEngine.RegisterStyleHook(TBCBaseEditor, TBCEditorStyleHook);
{$ENDIF}
finalization
{$IFDEF USE_VCL_STYLES}
TCustomStyleEngine.UnregisterStyleHook(TBCBaseEditor, TBCEditorStyleHook);
{$ENDIF}
end.
| 33.712684 | 174 | 0.695983 |
831ab744990eee02b0320aa287101c114351ce65 | 1,966 | pas | Pascal | src/actions/DatasetActionDemo/Action.DataSet.pas | bogdanpolak/internalBSC | 75f7f9be576de7af0f1748f602137cca4dc8bb84 | [
"MIT"
]
| 3 | 2019-01-13T08:41:55.000Z | 2020-11-11T03:00:56.000Z | src/actions/DatasetActionDemo/Action.DataSet.pas | bogdanpolak/internalBSC | 75f7f9be576de7af0f1748f602137cca4dc8bb84 | [
"MIT"
]
| 7 | 2018-09-27T15:27:35.000Z | 2019-08-13T15:30:23.000Z | src/actions/DatasetActionDemo/Action.DataSet.pas | bogdanpolak/internalBSC | 75f7f9be576de7af0f1748f602137cca4dc8bb84 | [
"MIT"
]
| 3 | 2019-01-13T08:41:57.000Z | 2020-11-11T03:01:00.000Z | unit Action.DataSet;
interface
uses
System.Classes,
Data.DB,
Vcl.ActnList;
type
TDataSetFirstAction = class(TAction)
private
FDataSource: TDataSource;
procedure SetDataSource(DataSource: TDataSource);
protected
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
public
FCountHandlesTarget: integer;
function HandlesTarget(Target: TObject): Boolean; override;
procedure ExecuteTarget(Target: TObject); override;
procedure UpdateTarget(Target: TObject); override;
property DataSource: TDataSource read FDataSource write SetDataSource;
end;
implementation
// ------------------------------------------------------------------------
// TDataSetFirstAction
// ------------------------------------------------------------------------
procedure TDataSetFirstAction.ExecuteTarget(Target: TObject);
begin
FDataSource.DataSet.First;
end;
procedure TDataSetFirstAction.UpdateTarget(Target: TObject);
begin
Enabled := (FDataSource <> nil) and FDataSource.DataSet.Active and
not FDataSource.DataSet.Bof;
end;
// TDataSource specyfic code
function TDataSetFirstAction.HandlesTarget(Target: TObject): Boolean;
var
isAccepted: Boolean;
begin
isAccepted := (FDataSource <> nil) and (Target = FDataSource) and
(FDataSource.DataSet <> nil);
if isAccepted then
FCountHandlesTarget := FCountHandlesTarget + 1;
Result := isAccepted;
end;
procedure TDataSetFirstAction.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = DataSource) then
DataSource := nil;
end;
procedure TDataSetFirstAction.SetDataSource(DataSource: TDataSource);
begin
if DataSource <> FDataSource then
begin
FDataSource := DataSource;
// TODO: Check this. Not sure why it's required
if DataSource <> nil then
DataSource.FreeNotification(Self);
end;
end;
end.
| 25.868421 | 75 | 0.700407 |
fcf88dfe196c2b50c54e2fe9e7551293069217f0 | 8,177 | dfm | Pascal | Components/JVCL/design/JvCsvDataForm.dfm | sabatex/Delphi | 0efbe6eb38bf8aa2bf269d1866741266e90b9cbf | [
"MIT"
]
| null | null | null | Components/JVCL/design/JvCsvDataForm.dfm | sabatex/Delphi | 0efbe6eb38bf8aa2bf269d1866741266e90b9cbf | [
"MIT"
]
| null | null | null | Components/JVCL/design/JvCsvDataForm.dfm | sabatex/Delphi | 0efbe6eb38bf8aa2bf269d1866741266e90b9cbf | [
"MIT"
]
| 1 | 2019-12-24T08:39:18.000Z | 2019-12-24T08:39:18.000Z | object JvCsvDefStrDialog: TJvCsvDefStrDialog
Left = 382
Top = 246
Width = 442
Height = 333
Caption = 'JvCsvDataSet.CSVFieldDef Editor'
Color = clBtnFace
Constraints.MinHeight = 333
Constraints.MinWidth = 442
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
Icon.Data = {
0000010001001010100000000000280100001600000028000000100000002000
00000100040000000000C0000000000000000000000000000000000000000000
000000008000008000000080800080000000800080008080000080808000C0C0
C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000
00000000000000777777777000000000000000770000007777777007700000F8
88887070770000F888887087077000F888887088707000F888887088870000F8
88887088F00000F88888708F000000F8888870F0000000FFFFFFF00000000000
000000000000000000000000000000000000000000000000000000000000FFFF
0000C01F0000800F000080070000800300008001000080010000800100008003
000080070000800F0000801F0000803F0000FFFF0000FFFF0000FFFF0000}
OldCreateOrder = False
Position = poScreenCenter
Scaled = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 24
Top = 228
Width = 66
Height = 13
Anchors = [akLeft, akBottom]
Caption = 'CSVFieldDef='
end
object Label2: TLabel
Left = 12
Top = 48
Width = 54
Height = 13
Caption = 'Field Types'
end
object Label3: TLabel
Left = 8
Top = 4
Width = 53
Height = 13
Caption = 'Field Name'
end
object SpeedButtonAdd: TSpeedButton
Left = 8
Top = 196
Width = 101
Height = 22
Anchors = [akLeft, akBottom]
Caption = '&Add'
Glyph.Data = {
76010000424D7601000000000000760000002800000020000000100000000100
0400000000000001000000000000000000001000000000000000000000000000
8000008000000080800080000000800080008080000080808000C0C0C0000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00DDDDDD00007D
DDDDDDDDDD8888FDDDDDDDDDDD02207DDDDDDDDDDD8778FDDDDDDDDDDD0A207D
DDDDDDDDDD8F78FDDDDDDDDDDD0A207DDDDDDDDDDD8F78FDDDDDDDDDDD0A207D
DDDDDDDDDD8F78FDDDDDDD77770A20777777DD77778F78FFFFFFD000000A2000
0007D888888F7888888FD022222A22222207D877777F7777778FD0AAAAAAAAAA
AA07D8FFFFFFFFFFFF8FD000000A2000000DD888888F7888888DDDDDDD0A207D
DDDDDDDDDD8F78FDDDDDDDDDDD0A207DDDDDDDDDDD8F78FDDDDDDDDDDD0A207D
DDDDDDDDDD8F78FDDDDDDDDDDD0A207DDDDDDDDDDD8F78FDDDDDDDDDDD0A207D
DDDDDDDDDD8F78FDDDDDDDDDDD0000DDDDDDDDDDDD8888DDDDDD}
NumGlyphs = 2
OnClick = SpeedButtonAddClick
end
object SpeedButtonDel: TSpeedButton
Left = 336
Top = 196
Width = 85
Height = 22
Anchors = [akLeft, akBottom]
Caption = '&Delete'
OnClick = SpeedButtonDelClick
end
object SpeedButtonMod: TSpeedButton
Left = 128
Top = 196
Width = 89
Height = 22
Anchors = [akLeft, akBottom]
Caption = '&Modify'
Glyph.Data = {
76010000424D7601000000000000760000002800000020000000100000000100
0400000000000001000000000000000000001000000000000000000000000000
8000008000000080800080000000800080008080000080808000C0C0C0000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00DDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD7777777777
7777DD77777777777777D000000000000007D888888888888887D0AAAAAAAAAA
AA07D877777777777787D0AAAAAAAAAAAA07D8FFFFFFFFFFFF87D00000000000
000DD88888888888888DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDDDDD77777777777777DD77777777777777D00000000000
0007D888888888888887D0AAAAAAAAAAAA07D877777777777787D0AAAAAAAAAA
AA07D8FFFFFFFFFFFF87D00000000000000DD88888888888888DDDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD}
NumGlyphs = 2
OnClick = SpeedButtonModClick
end
object LabelFieldLen: TLabel
Left = 140
Top = 4
Width = 33
Height = 13
Caption = 'Length'
end
object Label5: TLabel
Left = 240
Top = 4
Width = 27
Height = 13
Caption = 'Fields'
end
object Bevel1: TBevel
Left = 228
Top = 4
Width = 2
Height = 213
Anchors = [akLeft, akTop, akBottom]
end
object SpeedButtonMoveFieldUp: TSpeedButton
Left = 240
Top = 196
Width = 23
Height = 22
Anchors = [akLeft, akBottom]
Glyph.Data = {
76010000424D7601000000000000760000002800000020000000100000000100
04000000000000010000120B0000120B00001000000000000000000000000000
800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333000333
3333333333777F33333333333309033333333333337F7F333333333333090333
33333333337F7F33333333333309033333333333337F7F333333333333090333
33333333337F7F33333333333309033333333333FF7F7FFFF333333000090000
3333333777737777F333333099999990333333373F3333373333333309999903
333333337F33337F33333333099999033333333373F333733333333330999033
3333333337F337F3333333333099903333333333373F37333333333333090333
33333333337F7F33333333333309033333333333337373333333333333303333
333333333337F333333333333330333333333333333733333333}
NumGlyphs = 2
OnClick = SpeedButtonMoveFieldUpClick
end
object SpeedButtonMoveFieldDown: TSpeedButton
Left = 264
Top = 196
Width = 23
Height = 22
Anchors = [akLeft, akBottom]
Glyph.Data = {
76010000424D7601000000000000760000002800000020000000100000000100
04000000000000010000120B0000120B00001000000000000000000000000000
800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333303333
333333333337F33333333333333033333333333333373F333333333333090333
33333333337F7F33333333333309033333333333337373F33333333330999033
3333333337F337F33333333330999033333333333733373F3333333309999903
333333337F33337F33333333099999033333333373333373F333333099999990
33333337FFFF3FF7F33333300009000033333337777F77773333333333090333
33333333337F7F33333333333309033333333333337F7F333333333333090333
33333333337F7F33333333333309033333333333337F7F333333333333090333
33333333337F7F33333333333300033333333333337773333333}
NumGlyphs = 2
OnClick = SpeedButtonMoveFieldDownClick
end
object LabelKey: TLabel
Left = 296
Top = 204
Width = 40
Height = 21
Anchors = [akLeft, akBottom]
AutoSize = False
end
object EditCsvStr: TEdit
Left = 96
Top = 226
Width = 321
Height = 31
TabStop = False
Anchors = [akLeft, akBottom]
BorderStyle = bsNone
Color = clBtnFace
ReadOnly = True
TabOrder = 3
end
object ButtonOk: TButton
Left = 268
Top = 264
Width = 75
Height = 25
Anchors = [akLeft, akBottom]
Caption = 'Ok'
TabOrder = 5
OnClick = ButtonOkClick
end
object ButtonCancel: TButton
Left = 352
Top = 264
Width = 75
Height = 25
Anchors = [akLeft, akBottom]
Cancel = True
Caption = 'Cancel'
TabOrder = 6
OnClick = ButtonCancelClick
end
object ListBoxFieldTypes: TListBox
Left = 8
Top = 64
Width = 209
Height = 129
Anchors = [akLeft, akTop, akBottom]
ItemHeight = 13
Items.Strings = (
'Boolean (0 or 1 only)'
'String (String with Maximum Length)'
'Integer (1234)'
'Float (123.45)'
'DateTime (YYYY/MM/DD HH:MM:SS)'
'Hex Timestamp (GMTTIME Hex)'
'Hex LocalTime (LOCALTIME Hex)'
'Date (YYYY/MM/DD)'
'Time (HH:MM:SS)')
TabOrder = 4
OnClick = ListBoxFieldTypesClick
end
object EditFieldName: TEdit
Left = 8
Top = 20
Width = 121
Height = 21
TabOrder = 0
end
object EditFieldLength: TEdit
Left = 140
Top = 20
Width = 77
Height = 21
TabOrder = 1
end
object ListBoxFields: TListBox
Left = 240
Top = 24
Width = 181
Height = 169
Anchors = [akLeft, akTop, akBottom]
ItemHeight = 13
TabOrder = 2
OnClick = ListBoxFieldsClick
OnKeyUp = ListBoxFieldsKeyUp
end
end
| 31.329502 | 70 | 0.756145 |
47305c730c2eef70f7d18eccf6f9e706cf62cfbe | 5,673 | pas | Pascal | numbers/0037.pas | nickelsworth/swag | 7c21c0da2291fc249b9dc5cfe121a7672a4ffc08 | [
"BSD-2-Clause"
]
| 11 | 2015-12-12T05:13:15.000Z | 2020-10-14T13:32:08.000Z | numbers/0037.pas | nickelsworth/swag | 7c21c0da2291fc249b9dc5cfe121a7672a4ffc08 | [
"BSD-2-Clause"
]
| null | null | null | numbers/0037.pas | nickelsworth/swag | 7c21c0da2291fc249b9dc5cfe121a7672a4ffc08 | [
"BSD-2-Clause"
]
| 8 | 2017-05-05T05:24:01.000Z | 2021-07-03T20:30:09.000Z | UNIT Bits;
(**) INTERFACE (**)
TYPE
bbit = 0..7;
wbit = 0..15;
lbit = 0..31;
PROCEDURE SetBitB(VAR B : Byte; bit : bbit);
PROCEDURE ClearBitB(VAR B : Byte; bit : bbit);
PROCEDURE ToggleBitB(VAR B : Byte; bit : bbit);
FUNCTION BitSetB(B : Byte; bit : bbit) : Boolean;
FUNCTION BitClearB(B : Byte; bit : bbit) : Boolean;
PROCEDURE SetBitW(VAR W : Word; bit : wbit);
PROCEDURE ClearBitW(VAR W : Word; bit : wbit);
PROCEDURE ToggleBitW(VAR W : Word; bit : wbit);
FUNCTION BitSetW(W : Word; bit : wbit) : Boolean;
FUNCTION BitClearW(W : Word; bit : wbit) : Boolean;
PROCEDURE SetBitL(VAR L : LongInt; bit : lbit);
PROCEDURE ClearBitL(VAR L : LongInt; bit : lbit);
PROCEDURE ToggleBitL(VAR L : LongInt; bit : lbit);
FUNCTION BitSetL(L : LongInt; bit : lbit) : Boolean;
FUNCTION BitClearL(L : LongInt; bit : lbit) : Boolean;
(**) IMPLEMENTATION (**)
PROCEDURE SetBitB(VAR B : Byte; bit : bbit);
Assembler;
ASM
MOV CL, bit
MOV BL, 1
SHL BL, CL {BL contains 2-to-the-bit}
LES DI, B
OR ES:[DI], BL {OR turns on bit}
END;
PROCEDURE ClearBitB(VAR B : Byte; bit : bbit);
Assembler;
ASM
MOV CL, bit
MOV BL, 1
SHL BL, CL {BL contains 2-to-the-bit}
NOT BL
LES DI, B
AND ES:[DI], BL {AND of NOT BL turns off bit}
END;
PROCEDURE ToggleBitB(VAR B : Byte; bit : bbit);
Assembler;
ASM
MOV CL, bit
MOV BL, 1
SHL BL, CL {BL contains 2-to-the-bit}
LES DI, B
XOR ES:[DI], BL {XOR toggles bit}
END;
FUNCTION BitSetB(B : Byte; bit : bbit) : Boolean;
Assembler;
ASM
MOV CL, bit
MOV BL, 1
SHL BL, CL {BL contains 2-to-the-bit}
MOV AL, 0 {set result to FALSE}
TEST B, BL
JZ @No
INC AL {set result to TRUE}
@No:
END;
FUNCTION BitClearB(B : Byte; bit : bbit) : Boolean;
Assembler;
ASM
MOV CL, bit
MOV BL, 1
SHL BL, CL {BL contains 2-to-the-bit}
MOV AL, 0 {set result to FALSE}
TEST B, BL
JNZ @No
INC AL {set result to TRUE}
@No:
END;
PROCEDURE SetBitW(VAR W : Word; bit : wbit);
Assembler;
ASM
MOV CL, bit
MOV BX, 1
SHL BX, CL {BX contains 2-to-the-bit}
LES DI, W
OR ES:[DI], BX {OR turns on bit}
END;
PROCEDURE ClearBitW(VAR W : Word; bit : wbit);
Assembler;
ASM
MOV CL, bit
MOV BX, 1
SHL BX, CL {BX contains 2-to-the-bit}
NOT BX
LES DI, W
AND ES:[DI], BX {AND of NOT BX turns off bit}
END;
PROCEDURE ToggleBitW(VAR W : Word; bit : wbit);
Assembler;
ASM
MOV CL, bit
MOV BX, 1
SHL BX, CL {BX contains 2-to-the-bit}
LES DI, W
XOR ES:[DI], BX {XOR toggles bit}
END;
FUNCTION BitSetW(W : Word; bit : wbit) : Boolean;
Assembler;
ASM
MOV CL, bit
MOV BX, 1
SHL BX, CL {BX contains 2-to-the-bit}
MOV AL, 0 {set result to FALSE}
TEST W, BX
JZ @No
INC AL {set result to TRUE}
@No:
END;
FUNCTION BitClearW(W : Word; bit : wbit) : Boolean;
Assembler;
ASM
MOV CL, bit
MOV BX, 1
SHL BX, CL {BX contains 2-to-the-bit}
MOV AL, 0 {set result to FALSE}
TEST W, BX
JNZ @No
INC AL {set result to TRUE}
@No:
END;
PROCEDURE SetBitL(VAR L : LongInt; bit : lbit);
Assembler;
ASM
LES DI, L
MOV CL, bit
MOV BX, 1
SHL BX, CL {BX contains 2-to-the-bit}
JZ @TopWord {if zero, use high word}
OR ES:[DI], BX {OR turns on bit}
JMP @Finish
@TopWord:
SUB CL, 16
MOV BX, 1
SHL BX, CL
OR ES:[DI+2], BX
@Finish:
END;
PROCEDURE ClearBitL(VAR L : LongInt; bit : lbit);
Assembler;
ASM
LES DI, L
MOV CL, bit
MOV BX, 1
SHL BX, CL {BX contains 2-to-the-bit}
JZ @TopWord {if zero, use high word}
NOT BX
AND ES:[DI], BX {AND of NOT BX turns off bit}
JMP @Finish
@TopWord:
SUB CL, 16
MOV BX, 1
SHL BX, CL
NOT BX
AND ES:[DI+2], BX
@Finish:
END;
PROCEDURE ToggleBitL(VAR L : LongInt; bit : lbit);
Assembler;
ASM
LES DI, L
MOV CL, bit
MOV BX, 1
SHL BX, CL {BX contains 2-to-the-bit}
JZ @TopWord {if zero, use high word}
XOR ES:[DI], BX {XOR toggles bit}
JMP @Finish
@TopWord:
SUB CL, 16
MOV BX, 1
SHL BX, CL
XOR ES:[DI+2], BX
@Finish:
END;
FUNCTION BitSetL(L : LongInt; bit : lbit) : Boolean;
Assembler;
ASM
MOV AL, 0 {set result to FALSE}
MOV CL, bit
MOV BX, 1
SHL BX, CL {BX contains 2-to-the-bit}
JZ @TopWord {if zero, use high word}
TEST Word(L), BX
JMP @Finish
@TopWord:
SUB CL, 16
MOV BX, 1
SHL BX, CL
TEST Word(L+2), BX
@Finish:
JZ @No
INC AL {set result to TRUE}
@No:
END;
FUNCTION BitClearL(L : LongInt; bit : lbit) : Boolean;
Assembler;
ASM
MOV AL, 0 {set result to FALSE}
MOV CL, bit
MOV BX, 1
SHL BX, CL {BX contains 2-to-the-bit}
JZ @TopWord {if zero, use high word}
TEST Word(L), BX
JMP @Finish
@TopWord:
SUB CL, 16
MOV BX, 1
SHL BX, CL
TEST Word(L+2), BX
@Finish:
JNZ @No
INC AL {set result to TRUE}
@No:
END;
END.
| 23.736402 | 57 | 0.519126 |
fc7211377bf506fe3f1d2c63d7b6c96a87b74a3d | 44,080 | pas | Pascal | library/fhir4b/fhir4b_resources_base.pas | HealthIntersections/fhirserver | 759bf1a270bca48b3ef97385074cfc0b37fae0dc | [
"BSD-3-Clause"
]
| 5 | 2021-11-16T22:35:26.000Z | 2022-02-16T08:40:37.000Z | library/fhir4b/fhir4b_resources_base.pas | HealthIntersections/fhirserver | 759bf1a270bca48b3ef97385074cfc0b37fae0dc | [
"BSD-3-Clause"
]
| 7 | 2021-11-01T06:27:37.000Z | 2022-02-08T19:55:52.000Z | library/fhir4b/fhir4b_resources_base.pas | HealthIntersections/fhirserver | 759bf1a270bca48b3ef97385074cfc0b37fae0dc | [
"BSD-3-Clause"
]
| 2 | 2022-02-15T13:27:52.000Z | 2022-02-16T08:40:48.000Z | unit fhir4b_resources_base;
{
Copyright (c) 2011+, HL7 and Health Intersections Pty Ltd (http://www.healthintersections.com.au)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
}
{$I fhir.inc}
{$I fhir4b.inc}
interface
// Generated on Mon, Dec 27, 2021 21:46+1100 for FHIR v4.3.0
uses
SysUtils, Classes,
fsl_base, fsl_utilities, fsl_stream,
fhir_objects, fhir_utilities,
fhir4b_base, fhir4b_enums, fhir4b_types;
type
TFhirResourceType = (
frtNull, // Resource type not known / not Specified
{$IFDEF FHIR_ACCOUNT}frtAccount, {$ENDIF}
{$IFDEF FHIR_ACTIVITYDEFINITION}frtActivityDefinition, {$ENDIF}
{$IFDEF FHIR_ADMINISTRABLEPRODUCTDEFINITION}frtAdministrableProductDefinition, {$ENDIF}
{$IFDEF FHIR_ADVERSEEVENT}frtAdverseEvent, {$ENDIF}
{$IFDEF FHIR_ALLERGYINTOLERANCE}frtAllergyIntolerance, {$ENDIF}
{$IFDEF FHIR_APPOINTMENT}frtAppointment, {$ENDIF}
{$IFDEF FHIR_APPOINTMENTRESPONSE}frtAppointmentResponse, {$ENDIF}
{$IFDEF FHIR_AUDITEVENT}frtAuditEvent, {$ENDIF}
{$IFDEF FHIR_BASIC}frtBasic, {$ENDIF}
{$IFDEF FHIR_BINARY}frtBinary, {$ENDIF}
{$IFDEF FHIR_BIOLOGICALLYDERIVEDPRODUCT}frtBiologicallyDerivedProduct, {$ENDIF}
{$IFDEF FHIR_BODYSTRUCTURE}frtBodyStructure, {$ENDIF}
{$IFDEF FHIR_BUNDLE}frtBundle, {$ENDIF}
{$IFDEF FHIR_CAPABILITYSTATEMENT}frtCapabilityStatement, {$ENDIF}
{$IFDEF FHIR_CAREPLAN}frtCarePlan, {$ENDIF}
{$IFDEF FHIR_CARETEAM}frtCareTeam, {$ENDIF}
{$IFDEF FHIR_CATALOGENTRY}frtCatalogEntry, {$ENDIF}
{$IFDEF FHIR_CHARGEITEM}frtChargeItem, {$ENDIF}
{$IFDEF FHIR_CHARGEITEMDEFINITION}frtChargeItemDefinition, {$ENDIF}
{$IFDEF FHIR_CITATION}frtCitation, {$ENDIF}
{$IFDEF FHIR_CLAIM}frtClaim, {$ENDIF}
{$IFDEF FHIR_CLAIMRESPONSE}frtClaimResponse, {$ENDIF}
{$IFDEF FHIR_CLINICALIMPRESSION}frtClinicalImpression, {$ENDIF}
{$IFDEF FHIR_CLINICALUSEDEFINITION}frtClinicalUseDefinition, {$ENDIF}
{$IFDEF FHIR_CODESYSTEM}frtCodeSystem, {$ENDIF}
{$IFDEF FHIR_COMMUNICATION}frtCommunication, {$ENDIF}
{$IFDEF FHIR_COMMUNICATIONREQUEST}frtCommunicationRequest, {$ENDIF}
{$IFDEF FHIR_COMPARTMENTDEFINITION}frtCompartmentDefinition, {$ENDIF}
{$IFDEF FHIR_COMPOSITION}frtComposition, {$ENDIF}
{$IFDEF FHIR_CONCEPTMAP}frtConceptMap, {$ENDIF}
{$IFDEF FHIR_CONDITION}frtCondition, {$ENDIF}
{$IFDEF FHIR_CONSENT}frtConsent, {$ENDIF}
{$IFDEF FHIR_CONTRACT}frtContract, {$ENDIF}
{$IFDEF FHIR_COVERAGE}frtCoverage, {$ENDIF}
{$IFDEF FHIR_COVERAGEELIGIBILITYREQUEST}frtCoverageEligibilityRequest, {$ENDIF}
{$IFDEF FHIR_COVERAGEELIGIBILITYRESPONSE}frtCoverageEligibilityResponse, {$ENDIF}
{$IFDEF FHIR_DETECTEDISSUE}frtDetectedIssue, {$ENDIF}
{$IFDEF FHIR_DEVICE}frtDevice, {$ENDIF}
{$IFDEF FHIR_DEVICEDEFINITION}frtDeviceDefinition, {$ENDIF}
{$IFDEF FHIR_DEVICEMETRIC}frtDeviceMetric, {$ENDIF}
{$IFDEF FHIR_DEVICEREQUEST}frtDeviceRequest, {$ENDIF}
{$IFDEF FHIR_DEVICEUSESTATEMENT}frtDeviceUseStatement, {$ENDIF}
{$IFDEF FHIR_DIAGNOSTICREPORT}frtDiagnosticReport, {$ENDIF}
{$IFDEF FHIR_DOCUMENTMANIFEST}frtDocumentManifest, {$ENDIF}
{$IFDEF FHIR_DOCUMENTREFERENCE}frtDocumentReference, {$ENDIF}
{$IFDEF FHIR_ENCOUNTER}frtEncounter, {$ENDIF}
{$IFDEF FHIR_ENDPOINT}frtEndpoint, {$ENDIF}
{$IFDEF FHIR_ENROLLMENTREQUEST}frtEnrollmentRequest, {$ENDIF}
{$IFDEF FHIR_ENROLLMENTRESPONSE}frtEnrollmentResponse, {$ENDIF}
{$IFDEF FHIR_EPISODEOFCARE}frtEpisodeOfCare, {$ENDIF}
{$IFDEF FHIR_EVENTDEFINITION}frtEventDefinition, {$ENDIF}
{$IFDEF FHIR_EVIDENCE}frtEvidence, {$ENDIF}
{$IFDEF FHIR_EVIDENCEREPORT}frtEvidenceReport, {$ENDIF}
{$IFDEF FHIR_EVIDENCEVARIABLE}frtEvidenceVariable, {$ENDIF}
{$IFDEF FHIR_EXAMPLESCENARIO}frtExampleScenario, {$ENDIF}
{$IFDEF FHIR_EXPLANATIONOFBENEFIT}frtExplanationOfBenefit, {$ENDIF}
{$IFDEF FHIR_FAMILYMEMBERHISTORY}frtFamilyMemberHistory, {$ENDIF}
{$IFDEF FHIR_FLAG}frtFlag, {$ENDIF}
{$IFDEF FHIR_GOAL}frtGoal, {$ENDIF}
{$IFDEF FHIR_GRAPHDEFINITION}frtGraphDefinition, {$ENDIF}
{$IFDEF FHIR_GROUP}frtGroup, {$ENDIF}
{$IFDEF FHIR_GUIDANCERESPONSE}frtGuidanceResponse, {$ENDIF}
{$IFDEF FHIR_HEALTHCARESERVICE}frtHealthcareService, {$ENDIF}
{$IFDEF FHIR_IMAGINGSTUDY}frtImagingStudy, {$ENDIF}
{$IFDEF FHIR_IMMUNIZATION}frtImmunization, {$ENDIF}
{$IFDEF FHIR_IMMUNIZATIONEVALUATION}frtImmunizationEvaluation, {$ENDIF}
{$IFDEF FHIR_IMMUNIZATIONRECOMMENDATION}frtImmunizationRecommendation, {$ENDIF}
{$IFDEF FHIR_IMPLEMENTATIONGUIDE}frtImplementationGuide, {$ENDIF}
{$IFDEF FHIR_INGREDIENT}frtIngredient, {$ENDIF}
{$IFDEF FHIR_INSURANCEPLAN}frtInsurancePlan, {$ENDIF}
{$IFDEF FHIR_INVOICE}frtInvoice, {$ENDIF}
{$IFDEF FHIR_LIBRARY}frtLibrary, {$ENDIF}
{$IFDEF FHIR_LINKAGE}frtLinkage, {$ENDIF}
{$IFDEF FHIR_LIST}frtList, {$ENDIF}
{$IFDEF FHIR_LOCATION}frtLocation, {$ENDIF}
{$IFDEF FHIR_MANUFACTUREDITEMDEFINITION}frtManufacturedItemDefinition, {$ENDIF}
{$IFDEF FHIR_MEASURE}frtMeasure, {$ENDIF}
{$IFDEF FHIR_MEASUREREPORT}frtMeasureReport, {$ENDIF}
{$IFDEF FHIR_MEDIA}frtMedia, {$ENDIF}
{$IFDEF FHIR_MEDICATION}frtMedication, {$ENDIF}
{$IFDEF FHIR_MEDICATIONADMINISTRATION}frtMedicationAdministration, {$ENDIF}
{$IFDEF FHIR_MEDICATIONDISPENSE}frtMedicationDispense, {$ENDIF}
{$IFDEF FHIR_MEDICATIONKNOWLEDGE}frtMedicationKnowledge, {$ENDIF}
{$IFDEF FHIR_MEDICATIONREQUEST}frtMedicationRequest, {$ENDIF}
{$IFDEF FHIR_MEDICATIONSTATEMENT}frtMedicationStatement, {$ENDIF}
{$IFDEF FHIR_MEDICINALPRODUCTDEFINITION}frtMedicinalProductDefinition, {$ENDIF}
{$IFDEF FHIR_MESSAGEDEFINITION}frtMessageDefinition, {$ENDIF}
{$IFDEF FHIR_MESSAGEHEADER}frtMessageHeader, {$ENDIF}
{$IFDEF FHIR_MOLECULARSEQUENCE}frtMolecularSequence, {$ENDIF}
{$IFDEF FHIR_NAMINGSYSTEM}frtNamingSystem, {$ENDIF}
{$IFDEF FHIR_NUTRITIONORDER}frtNutritionOrder, {$ENDIF}
{$IFDEF FHIR_NUTRITIONPRODUCT}frtNutritionProduct, {$ENDIF}
{$IFDEF FHIR_OBSERVATION}frtObservation, {$ENDIF}
{$IFDEF FHIR_OBSERVATIONDEFINITION}frtObservationDefinition, {$ENDIF}
{$IFDEF FHIR_OPERATIONDEFINITION}frtOperationDefinition, {$ENDIF}
{$IFDEF FHIR_OPERATIONOUTCOME}frtOperationOutcome, {$ENDIF}
{$IFDEF FHIR_ORGANIZATION}frtOrganization, {$ENDIF}
{$IFDEF FHIR_ORGANIZATIONAFFILIATION}frtOrganizationAffiliation, {$ENDIF}
{$IFDEF FHIR_PACKAGEDPRODUCTDEFINITION}frtPackagedProductDefinition, {$ENDIF}
{$IFDEF FHIR_PARAMETERS}frtParameters, {$ENDIF}
{$IFDEF FHIR_PATIENT}frtPatient, {$ENDIF}
{$IFDEF FHIR_PAYMENTNOTICE}frtPaymentNotice, {$ENDIF}
{$IFDEF FHIR_PAYMENTRECONCILIATION}frtPaymentReconciliation, {$ENDIF}
{$IFDEF FHIR_PERSON}frtPerson, {$ENDIF}
{$IFDEF FHIR_PLANDEFINITION}frtPlanDefinition, {$ENDIF}
{$IFDEF FHIR_PRACTITIONER}frtPractitioner, {$ENDIF}
{$IFDEF FHIR_PRACTITIONERROLE}frtPractitionerRole, {$ENDIF}
{$IFDEF FHIR_PROCEDURE}frtProcedure, {$ENDIF}
{$IFDEF FHIR_PROVENANCE}frtProvenance, {$ENDIF}
{$IFDEF FHIR_QUESTIONNAIRE}frtQuestionnaire, {$ENDIF}
{$IFDEF FHIR_QUESTIONNAIRERESPONSE}frtQuestionnaireResponse, {$ENDIF}
{$IFDEF FHIR_REGULATEDAUTHORIZATION}frtRegulatedAuthorization, {$ENDIF}
{$IFDEF FHIR_RELATEDPERSON}frtRelatedPerson, {$ENDIF}
{$IFDEF FHIR_REQUESTGROUP}frtRequestGroup, {$ENDIF}
{$IFDEF FHIR_RESEARCHDEFINITION}frtResearchDefinition, {$ENDIF}
{$IFDEF FHIR_RESEARCHELEMENTDEFINITION}frtResearchElementDefinition, {$ENDIF}
{$IFDEF FHIR_RESEARCHSTUDY}frtResearchStudy, {$ENDIF}
{$IFDEF FHIR_RESEARCHSUBJECT}frtResearchSubject, {$ENDIF}
{$IFDEF FHIR_RISKASSESSMENT}frtRiskAssessment, {$ENDIF}
{$IFDEF FHIR_SCHEDULE}frtSchedule, {$ENDIF}
{$IFDEF FHIR_SEARCHPARAMETER}frtSearchParameter, {$ENDIF}
{$IFDEF FHIR_SERVICEREQUEST}frtServiceRequest, {$ENDIF}
{$IFDEF FHIR_SLOT}frtSlot, {$ENDIF}
{$IFDEF FHIR_SPECIMEN}frtSpecimen, {$ENDIF}
{$IFDEF FHIR_SPECIMENDEFINITION}frtSpecimenDefinition, {$ENDIF}
{$IFDEF FHIR_STRUCTUREDEFINITION}frtStructureDefinition, {$ENDIF}
{$IFDEF FHIR_STRUCTUREMAP}frtStructureMap, {$ENDIF}
{$IFDEF FHIR_SUBSCRIPTION}frtSubscription, {$ENDIF}
{$IFDEF FHIR_SUBSCRIPTIONSTATUS}frtSubscriptionStatus, {$ENDIF}
{$IFDEF FHIR_SUBSCRIPTIONTOPIC}frtSubscriptionTopic, {$ENDIF}
{$IFDEF FHIR_SUBSTANCE}frtSubstance, {$ENDIF}
{$IFDEF FHIR_SUBSTANCEDEFINITION}frtSubstanceDefinition, {$ENDIF}
{$IFDEF FHIR_SUPPLYDELIVERY}frtSupplyDelivery, {$ENDIF}
{$IFDEF FHIR_SUPPLYREQUEST}frtSupplyRequest, {$ENDIF}
{$IFDEF FHIR_TASK}frtTask, {$ENDIF}
{$IFDEF FHIR_TERMINOLOGYCAPABILITIES}frtTerminologyCapabilities, {$ENDIF}
{$IFDEF FHIR_TESTREPORT}frtTestReport, {$ENDIF}
{$IFDEF FHIR_TESTSCRIPT}frtTestScript, {$ENDIF}
{$IFDEF FHIR_VALUESET}frtValueSet, {$ENDIF}
{$IFDEF FHIR_VERIFICATIONRESULT}frtVerificationResult, {$ENDIF}
{$IFDEF FHIR_VISIONPRESCRIPTION}frtVisionPrescription, {$ENDIF}
frtCustom);
TFhirResourceTypeSet = set of TFhirResourceType;
type
TFhirResource = class;
TFhirResourceList = class;
TFhirDomainResource = class;
// This is the base resource type for everything.
TFhirResource = class abstract (TFhirResource4b)
protected
FId : TFhirId;
FMeta : TFhirMeta;
FImplicitRules : TFhirUri;
FLanguage : TFhirCode;
procedure SetId(value : TFhirId);
function GetIdST : String;
procedure SetIdST(value : String);
procedure SetMeta(value : TFhirMeta);
procedure SetImplicitRules(value : TFhirUri);
function GetImplicitRulesST : String;
procedure SetImplicitRulesST(value : String);
procedure SetLanguage(value : TFhirCode);
function GetLanguageST : String;
procedure SetLanguageST(value : String);
procedure GetChildrenByName(child_name : string; list : TFHIRSelectionList); override;
procedure ListProperties(oList : TFHIRPropertyList; bInheritedProperties, bPrimitiveValues : Boolean); override;
procedure listFieldsInOrder(fields : TStringList); override;
function sizeInBytesV(magic : integer) : cardinal; override;
function GetResourceType : TFhirResourceType; virtual; abstract;
function GetProfileVersion : TFHIRVersion; override;
procedure SetProfileVersion(v : TFHIRVersion); override;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(oSource : TFslObject); override;
function Link : TFhirResource; overload;
function Clone : TFhirResource; overload;
function setProperty(propName : string; propValue : TFHIRObject) : TFHIRObject; override;
procedure insertProperty(propName : string; propValue : TFHIRObject; index : integer); override;
function createPropertyValue(propName : string) : TFHIRObject; override;
function getTypesForProperty(propName : string): String; override;
procedure deleteProperty(propName : string; value : TFHIRObject); override;
procedure replaceProperty(propName : string; existing, new : TFHIRObject); override;
procedure reorderProperty(propName : string; source, destination : integer); override;
function getId : string; override;
procedure setIdValue(id : String); override;
procedure checkNoImplicitRules(place, role : String); override;
function Equals(other : TObject) : boolean; override;
function isEmpty : boolean; override;
function hasExtensions : boolean; override;
{$IFNDEF FPC}published{$ENDIF}
property ResourceType : TFhirResourceType read GetResourceType;
// Typed access to The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
property id : String read GetIdST write SetIdST;
// The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
property idElement : TFhirId read FId write SetId;
// Typed access to The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource. (defined for API consistency)
property meta : TFhirMeta read FMeta write SetMeta;
// The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.
property metaElement : TFhirMeta read FMeta write SetMeta;
// Typed access to A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.
property implicitRules : String read GetImplicitRulesST write SetImplicitRulesST;
// A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.
property implicitRulesElement : TFhirUri read FImplicitRules write SetImplicitRules;
// Typed access to The base language in which the resource is written.
property language : String read GetLanguageST write SetLanguageST;
// The base language in which the resource is written.
property languageElement : TFhirCode read FLanguage write SetLanguage;
end;
TFhirResourceClass = class of TFhirResource;
TFhirResourceListEnumerator = class (TFslObject)
private
FIndex : integer;
FList : TFhirResourceList;
function GetCurrent : TFhirResource;
protected
function sizeInBytesV(magic : integer) : cardinal; override;
public
constructor Create(list : TFhirResourceList);
destructor Destroy; override;
function MoveNext : boolean;
property Current : TFhirResource read GetCurrent;
end;
TFhirResourceList = class (TFHIRObjectList)
private
function GetItemN(index : Integer) : TFhirResource;
procedure SetItemN(index : Integer; value : TFhirResource);
protected
function ItemClass : TFslObjectClass; override;
public
function Link : TFhirResourceList; overload;
function Clone : TFhirResourceList; overload;
function GetEnumerator : TFhirResourceListEnumerator;
// Add an already existing FhirResource to the end of the list.
function AddItem(value : TFhirResource) : TFhirResource; overload;
// See if an item is already in the list. returns -1 if not in the list
function IndexOf(value : TFhirResource) : Integer;
// Insert an existing FhirResource before the designated index (0 = first item)
procedure InsertItem(index : Integer; value : TFhirResource);
// Get the iIndexth FhirResource. (0 = first item)
procedure SetItemByIndex(index : Integer; value : TFhirResource);
// The number of items in the collection
function Item(index : Integer) : TFhirResource;
// The number of items in the collection
function Count : Integer; overload;
// Remove the indexth item. The first item is index 0.
procedure Remove(index : Integer);
// Remove All Items from the list
procedure ClearItems;
property FhirResources[index : Integer] : TFhirResource read GetItemN write SetItemN; default;
End;
// A resource that includes narrative, extensions, and contained resources.
TFhirDomainResource = class abstract (TFhirResource)
protected
FText : TFhirNarrative;
FcontainedList : TFhirResourceList;
FextensionList : TFhirExtensionList;
FmodifierExtensionList : TFhirExtensionList;
procedure SetText(value : TFhirNarrative);
function GetContainedList : TFhirResourceList;
function GetHasContainedList : Boolean;
function GetExtensionList : TFhirExtensionList;
function GetHasExtensionList : Boolean;
function GetModifierExtensionList : TFhirExtensionList;
function GetHasModifierExtensionList : Boolean;
procedure GetChildrenByName(child_name : string; list : TFHIRSelectionList); override;
procedure ListProperties(oList : TFHIRPropertyList; bInheritedProperties, bPrimitiveValues : Boolean); override;
procedure listFieldsInOrder(fields : TStringList); override;
function sizeInBytesV(magic : integer) : cardinal; override;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(oSource : TFslObject); override;
function Link : TFhirDomainResource; overload;
function Clone : TFhirDomainResource; overload;
function setProperty(propName : string; propValue : TFHIRObject) : TFHIRObject; override;
procedure insertProperty(propName : string; propValue : TFHIRObject; index : integer); override;
function createPropertyValue(propName : string) : TFHIRObject; override;
function getTypesForProperty(propName : string): String; override;
procedure deleteProperty(propName : string; value : TFHIRObject); override;
procedure replaceProperty(propName : string; existing, new : TFHIRObject); override;
procedure reorderProperty(propName : string; source, destination : integer); override;
function isDomainResource : boolean; override;
function hasExtension(url : string) : boolean; override;
function getExtensionString(url : String) : String; override;
function extensionCount(url : String) : integer; override;
function extensions(url : String) : TFslList<TFHIRObject>; override;
procedure addExtension(url : String; value : TFHIRObject); override;
function Equals(other : TObject) : boolean; override;
function isEmpty : boolean; override;
function hasExtensions : boolean; override;
{$IFNDEF FPC}published{$ENDIF}
// Typed access to A human-readable narrative that contains a summary of the resource and can be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it "clinically safe" for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety. (defined for API consistency)
property text : TFhirNarrative read FText write SetText;
// A human-readable narrative that contains a summary of the resource and can be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it "clinically safe" for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety.
property textElement : TFhirNarrative read FText write SetText;
// These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, and nor can they have their own independent transaction scope.
property containedList : TFhirResourceList read GetContainedList;
property hasContainedList : boolean read GetHasContainedList;
// May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.
property extensionList : TFhirExtensionList read GetExtensionList;
property hasExtensionList : boolean read GetHasExtensionList;
// May be used to represent additional information that is not part of the basic definition of the resource and that modifies the understanding of the element that contains it and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions. Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).
property modifierExtensionList : TFhirExtensionList read GetModifierExtensionList;
property hasModifierExtensionList : boolean read GetHasModifierExtensionList;
end;
implementation
uses
fhir4b_utilities;
{ TFhirResource }
constructor TFhirResource.Create;
begin
inherited;
end;
destructor TFhirResource.Destroy;
begin
FId.free;
FMeta.free;
FImplicitRules.free;
FLanguage.free;
inherited;
end;
procedure TFhirResource.Assign(oSource : TFslObject);
begin
inherited;
idElement := TFhirResource(oSource).idElement.Clone;
meta := TFhirResource(oSource).meta.Clone;
implicitRulesElement := TFhirResource(oSource).implicitRulesElement.Clone;
languageElement := TFhirResource(oSource).languageElement.Clone;
end;
procedure TFhirResource.GetChildrenByName(child_name : string; list : TFHIRSelectionList);
begin
inherited;
if (child_name = 'id') Then
list.add(self.link, 'id', FId.Link);
if (child_name = 'meta') Then
list.add(self.link, 'meta', FMeta.Link);
if (child_name = 'implicitRules') Then
list.add(self.link, 'implicitRules', FImplicitRules.Link);
if (child_name = 'language') Then
list.add(self.link, 'language', FLanguage.Link);
end;
function TFhirResource.getId: string;
begin
result := GetIdST;
end;
procedure TFhirResource.setIdValue(id: String);
begin
SetIdSt(id);
end;
procedure TFhirResource.SetProfileVersion(v : TFHIRVersion);
var
i : integer;
begin
if Meta = nil then
Meta := TFhirMeta.Create;
for i := Meta.profileList.Count - 1 downto 0 do
if isVersionUrl(Meta.profileList[i].value, fhirType) then
Meta.profileList.DeleteByIndex(i);
Meta.profileList.Append.value := 'http://hl7.org/fhir/'+PF_CONST[v]+'/StructureDefinition/'+fhirType;
end;
function TFhirResource.GetProfileVersion : TFHIRVersion;
var
p : TFHIRUri;
begin
result := fhirVersionUnknown;
if Meta <> nil then
for p in Meta.profileList do
begin
if (p.value = 'http://hl7.org/fhir/1.0/StructureDefinition/'+fhirType) then
exit(fhirVersionRelease2);
if (p.value = 'http://hl7.org/fhir/3.0/StructureDefinition/'+fhirType) then
exit(fhirVersionRelease3);
if (p.value = 'http://hl7.org/fhir/3.4/StructureDefinition/'+fhirType) then
exit(fhirVersionRelease4);
end;
end;
procedure TFhirResource.checkNoImplicitRules(place, role: String);
begin
if implicitRules <> '' then
raise EUnsafeOperation.Create('The resource '+role+' has an unknown implicitRules tag at '+place);
end;
procedure TFhirResource.ListProperties(oList: TFHIRPropertyList; bInheritedProperties, bPrimitiveValues: Boolean);
begin
inherited;
oList.add(TFHIRProperty.create(self, 'id', 'id', false, TFhirId, FId.Link));
oList.add(TFHIRProperty.create(self, 'meta', 'Meta', false, TFhirMeta, FMeta.Link));
oList.add(TFHIRProperty.create(self, 'implicitRules', 'uri', false, TFhirUri, FImplicitRules.Link));
oList.add(TFHIRProperty.create(self, 'language', 'code', false, TFhirCode, FLanguage.Link));
end;
function TFhirResource.setProperty(propName: string; propValue: TFHIRObject) : TFHIRObject;
begin
if (propName = 'id') then
begin
IdElement := asId(propValue);
result := propValue;
end
else if (propName = 'meta') then
begin
Meta := propValue as TFhirMeta;
result := propValue;
end
else if (propName = 'implicitRules') then
begin
ImplicitRulesElement := asUri(propValue);
result := propValue;
end
else if (propName = 'language') then
begin
LanguageElement := asCode(propValue);
result := propValue;
end
else
result := inherited setProperty(propName, propValue);
end;
procedure TFhirResource.insertProperty(propName: string; propValue: TFHIRObject; index : integer);
begin
inherited;
end;
function TFhirResource.createPropertyValue(propName: string) : TFHIRObject;
begin
if (propName = 'id') then result := TFhirId.create()
else if (propName = 'meta') then result := TFhirMeta.create()
else if (propName = 'implicitRules') then result := TFhirUri.create()
else if (propName = 'language') then result := TFhirCode.create()
else result := inherited createPropertyValue(propName);
end;
function TFhirResource.getTypesForProperty(propName: string) : String;
begin
if (propName = 'id') then result := 'id'
else if (propName = 'meta') then result := 'Meta'
else if (propName = 'implicitRules') then result := 'uri'
else if (propName = 'language') then result := 'code'
else result := inherited getTypesForProperty(propName);
end;
procedure TFhirResource.deleteProperty(propName: string; value : TFHIRObject);
begin
if (propName = 'id') then IdElement := nil
else if (propName = 'meta') then MetaElement := nil
else if (propName = 'implicitRules') then ImplicitRulesElement := nil
else if (propName = 'language') then LanguageElement := nil
else
inherited deleteProperty(propName, value);
end;
procedure TFhirResource.replaceProperty(propName : string; existing, new : TFHIRObject);
begin
if (propName = 'id') then IdElement := asId(new)
else if (propName = 'meta') then MetaElement := new as TFhirMeta
else if (propName = 'implicitRules') then ImplicitRulesElement := asUri(new)
else if (propName = 'language') then LanguageElement := asCode(new)
else
inherited replaceProperty(propName, existing, new);
end;
procedure TFhirResource.reorderProperty(propName : string; source, destination : integer);
begin
inherited reorderProperty(propName, source, destination);
end;
function TFhirResource.equals(other : TObject) : boolean;
var
o : TFhirResource;
begin
if (not inherited equals(other)) then
result := false
else if (not (other is TFhirResource)) then
result := false
else
begin
o := TFhirResource(other);
result := compareDeep(idElement, o.idElement, true) and compareDeep(metaElement, o.metaElement, true) and
compareDeep(implicitRulesElement, o.implicitRulesElement, true) and compareDeep(languageElement, o.languageElement, true);
end;
end;
function TFhirResource.isEmpty : boolean;
begin
result := inherited isEmpty and isEmptyProp(FId) and isEmptyProp(FMeta) and isEmptyProp(FImplicitRules) and isEmptyProp(FLanguage);
end;
procedure TFhirResource.listFieldsInOrder(fields : TStringList);
begin;
inherited listFieldsInOrder(fields);
fields.add('id');
fields.add('meta');
fields.add('implicitRules');
fields.add('language');
end;
function TFhirResource.sizeInBytesV(magic : integer) : cardinal;
begin;
result := inherited sizeInBytesV(magic);
end;
function TFhirResource.Link : TFhirResource;
begin
result := TFhirResource(inherited Link);
end;
function TFhirResource.Clone : TFhirResource;
begin
result := TFhirResource(inherited Clone);
end;
procedure TFhirResource.SetId(value : TFhirId);
begin
FId.free;
FId := value;
end;
function TFhirResource.GetIdST : String;
begin
if FId = nil then
result := ''
else
result := FId.value;
end;
procedure TFhirResource.SetIdST(value : String);
begin
if value <> '' then
begin
if FId = nil then
FId := TFhirId.create;
FId.value := value
end
else if FId <> nil then
FId.value := '';
end;
procedure TFhirResource.SetMeta(value : TFhirMeta);
begin
FMeta.free;
FMeta := value;
end;
procedure TFhirResource.SetImplicitRules(value : TFhirUri);
begin
FImplicitRules.free;
FImplicitRules := value;
end;
function TFhirResource.GetImplicitRulesST : String;
begin
if FImplicitRules = nil then
result := ''
else
result := FImplicitRules.value;
end;
procedure TFhirResource.SetImplicitRulesST(value : String);
begin
if value <> '' then
begin
if FImplicitRules = nil then
FImplicitRules := TFhirUri.create;
FImplicitRules.value := value
end
else if FImplicitRules <> nil then
FImplicitRules.value := '';
end;
procedure TFhirResource.SetLanguage(value : TFhirCode);
begin
FLanguage.free;
FLanguage := value;
end;
function TFhirResource.GetLanguageST : String;
begin
if FLanguage = nil then
result := ''
else
result := FLanguage.value;
end;
procedure TFhirResource.SetLanguageST(value : String);
begin
if value <> '' then
begin
if FLanguage = nil then
FLanguage := TFhirCode.create;
FLanguage.value := value
end
else if FLanguage <> nil then
FLanguage.value := '';
end;
function TFhirResource.hasExtensions : boolean;
begin
result := false;
end;
{ TFhirResourceListEnumerator }
constructor TFhirResourceListEnumerator.Create(list : TFhirResourceList);
begin
inherited Create;
FIndex := -1;
FList := list;
end;
destructor TFhirResourceListEnumerator.Destroy;
begin
FList.Free;
inherited;
end;
function TFhirResourceListEnumerator.MoveNext : boolean;
begin
inc(FIndex);
Result := FIndex < FList.count;
end;
function TFhirResourceListEnumerator.GetCurrent : TFhirResource;
begin
Result := FList[FIndex];
end;
function TFhirResourceListEnumerator.sizeInBytesV(magic : integer) : cardinal;
begin
result := inherited sizeInBytesV(magic);
inc(result, FList.sizeInBytes(magic));
end;
{ TFhirResourceList }
function TFhirResourceList.AddItem(value: TFhirResource): TFhirResource;
begin
assert(value.ClassName = 'TFhirResource', 'Attempt to add an item of type '+value.ClassName+' to a List of TFhirResource');
add(value);
result := value;
end;
procedure TFhirResourceList.ClearItems;
begin
Clear;
end;
function TFhirResourceList.GetEnumerator : TFhirResourceListEnumerator;
begin
result := TFhirResourceListEnumerator.Create(self.link);
end;
function TFhirResourceList.Clone: TFhirResourceList;
begin
result := TFhirResourceList(inherited Clone);
end;
function TFhirResourceList.Count: Integer;
begin
result := Inherited Count;
end;
function TFhirResourceList.GetItemN(index: Integer): TFhirResource;
begin
result := TFhirResource(ObjectByIndex[index]);
end;
function TFhirResourceList.ItemClass: TFslObjectClass;
begin
result := TFhirResource;
end;
function TFhirResourceList.IndexOf(value: TFhirResource): Integer;
begin
result := IndexByReference(value);
end;
procedure TFhirResourceList.InsertItem(index: Integer; value: TFhirResource);
begin
assert(value is TFhirResource);
Inherited Insert(index, value);
end;
function TFhirResourceList.Item(index: Integer): TFhirResource;
begin
result := TFhirResource(ObjectByIndex[index]);
end;
function TFhirResourceList.Link: TFhirResourceList;
begin
result := TFhirResourceList(inherited Link);
end;
procedure TFhirResourceList.Remove(index: Integer);
begin
DeleteByIndex(index);
end;
procedure TFhirResourceList.SetItemByIndex(index: Integer; value: TFhirResource);
begin
assert(value is TFhirResource);
FhirResources[index] := value;
end;
procedure TFhirResourceList.SetItemN(index: Integer; value: TFhirResource);
begin
assert(value is TFhirResource);
ObjectByIndex[index] := value;
end;
{ TFhirDomainResource }
constructor TFhirDomainResource.Create;
begin
inherited;
end;
destructor TFhirDomainResource.Destroy;
begin
FText.free;
FContainedList.Free;
FExtensionList.Free;
FModifierExtensionList.Free;
inherited;
end;
procedure TFhirDomainResource.Assign(oSource : TFslObject);
begin
inherited;
text := TFhirDomainResource(oSource).text.Clone;
if (TFhirDomainResource(oSource).FContainedList = nil) then
begin
FContainedList.free;
FContainedList := nil;
end
else
begin
if FContainedList = nil then
FContainedList := TFhirResourceList.Create;
FContainedList.Assign(TFhirDomainResource(oSource).FContainedList);
end;
if (TFhirDomainResource(oSource).FExtensionList = nil) then
begin
FExtensionList.free;
FExtensionList := nil;
end
else
begin
if FExtensionList = nil then
FExtensionList := TFhirExtensionList.Create;
FExtensionList.Assign(TFhirDomainResource(oSource).FExtensionList);
end;
if (TFhirDomainResource(oSource).FModifierExtensionList = nil) then
begin
FModifierExtensionList.free;
FModifierExtensionList := nil;
end
else
begin
if FModifierExtensionList = nil then
FModifierExtensionList := TFhirExtensionList.Create;
FModifierExtensionList.Assign(TFhirDomainResource(oSource).FModifierExtensionList);
end;
end;
procedure TFhirDomainResource.GetChildrenByName(child_name : string; list : TFHIRSelectionList);
begin
inherited;
if (child_name = 'text') Then
list.add(self.link, 'text', FText.Link);
if (child_name = 'contained') Then
list.addAll(self, 'contained', FContainedList);
if (child_name = 'extension') Then
list.addAll(self, 'extension', FExtensionList);
if (child_name = 'modifierExtension') Then
list.addAll(self, 'modifierExtension', FModifierExtensionList);
end;
procedure TFhirDomainResource.addExtension(url: String; value: TFHIRObject);
var
ex : TFhirExtension;
begin
ex := extensionList.Append;
ex.url := url;
ex.value := value as TFhirDataType;
end;
function TFhirDomainResource.extensionCount(url: String): integer;
var
ex : TFhirExtension;
begin
result := 0;
for ex in ExtensionList do
if ex.url = url then
inc(result);
end;
function TFhirDomainResource.extensions(url: String): TFslList<TFHIRObject>;
var
ex : TFhirExtension;
begin
result := TFslList<TFHIRObject>.create;
try
for ex in ExtensionList do
if ex.url = url then
result.Add(ex.Link);
result.link;
finally
result.Free;
end;
end;
function TFhirDomainResource.isDomainResource: boolean;
begin
result := true;
end;
function TFhirDomainResource.getExtensionString(url: String): String;
var
ex : TFhirExtension;
begin
result := '';
for ex in ExtensionList do
begin
if ex.url = url then
begin
if not ex.value.isPrimitive then
raise EFHIRException.create('Complex extension '+url)
else if result <> '' then
raise EFHIRException.create('Duplicate extension '+url)
else
result := ex.value.primitiveValue;
end;
end;
end;
function TFhirDomainResource.hasExtension(url: string): boolean;
var
ex : TFhirExtension;
begin
result := false;
for ex in ExtensionList do
if ex.url = url then
exit(true);
end;
procedure TFhirDomainResource.ListProperties(oList: TFHIRPropertyList; bInheritedProperties, bPrimitiveValues: Boolean);
begin
inherited;
oList.add(TFHIRProperty.create(self, 'text', 'Narrative', false, TFhirNarrative, FText.Link));
oList.add(TFHIRProperty.create(self, 'contained', 'Resource', true, TFhirResource, FContainedList.Link));
oList.add(TFHIRProperty.create(self, 'extension', 'Extension', true, TFhirExtension, FExtensionList.Link));
oList.add(TFHIRProperty.create(self, 'modifierExtension', 'Extension', true, TFhirExtension, FModifierExtensionList.Link));
end;
function TFhirDomainResource.setProperty(propName: string; propValue: TFHIRObject) : TFHIRObject;
begin
if (propName = 'text') then
begin
Text := propValue as TFhirNarrative;
result := propValue;
end
else if (propName = 'contained') then
begin
ContainedList.add(propValue as TFhirResource);
result := propValue;
end
else if (propName = 'extension') then
begin
ExtensionList.add(propValue as TFhirExtension);
result := propValue;
end
else if (propName = 'modifierExtension') then
begin
ModifierExtensionList.add(propValue as TFhirExtension);
result := propValue;
end
else
result := inherited setProperty(propName, propValue);
end;
procedure TFhirDomainResource.insertProperty(propName: string; propValue: TFHIRObject; index : integer);
begin
if (propName = 'contained') then ContainedList.insertItem(index, propValue as TFhirResource)
else if (propName = 'extension') then ExtensionList.insertItem(index, propValue as TFhirExtension)
else if (propName = 'modifierExtension') then ModifierExtensionList.insertItem(index, propValue as TFhirExtension)
else inherited;
end;
function TFhirDomainResource.createPropertyValue(propName: string) : TFHIRObject;
begin
if (propName = 'text') then result := TFhirNarrative.create()
else if (propName = 'extension') then result := ExtensionList.new()
else if (propName = 'modifierExtension') then result := ModifierExtensionList.new()
else result := inherited createPropertyValue(propName);
end;
function TFhirDomainResource.getTypesForProperty(propName: string) : String;
begin
if (propName = 'text') then result := 'Narrative'
else if (propName = 'contained') then result := 'Resource'
else if (propName = 'extension') then result := 'Extension'
else if (propName = 'modifierExtension') then result := 'Extension'
else result := inherited getTypesForProperty(propName);
end;
procedure TFhirDomainResource.deleteProperty(propName: string; value : TFHIRObject);
begin
if (propName = 'text') then TextElement := nil
else if (propName = 'contained') then deletePropertyValue('contained', ContainedList, value)
else if (propName = 'extension') then deletePropertyValue('extension', ExtensionList, value)
else if (propName = 'modifierExtension') then deletePropertyValue('modifierExtension', ModifierExtensionList, value)
else
inherited deleteProperty(propName, value);
end;
procedure TFhirDomainResource.replaceProperty(propName : string; existing, new : TFHIRObject);
begin
if (propName = 'text') then TextElement := new as TFhirNarrative
else if (propName = 'contained') then replacePropertyValue('contained', ContainedList, existing, new)
else if (propName = 'extension') then replacePropertyValue('extension', ExtensionList, existing, new)
else if (propName = 'modifierExtension') then replacePropertyValue('modifierExtension', ModifierExtensionList, existing, new)
else
inherited replaceProperty(propName, existing, new);
end;
procedure TFhirDomainResource.reorderProperty(propName : string; source, destination : integer);
begin
if (propName = 'contained') then ContainedList.move(source, destination)
else if (propName = 'extension') then ExtensionList.move(source, destination)
else if (propName = 'modifierExtension') then ModifierExtensionList.move(source, destination)
else
inherited reorderProperty(propName, source, destination);
end;
function TFhirDomainResource.equals(other : TObject) : boolean;
var
o : TFhirDomainResource;
begin
if (not inherited equals(other)) then
result := false
else if (not (other is TFhirDomainResource)) then
result := false
else
begin
o := TFhirDomainResource(other);
result := compareDeep(textElement, o.textElement, true) and compareDeep(containedList, o.containedList, true) and
compareDeep(extensionList, o.extensionList, true) and compareDeep(modifierExtensionList, o.modifierExtensionList, true);
end;
end;
function TFhirDomainResource.isEmpty : boolean;
begin
result := inherited isEmpty and isEmptyProp(FText) and isEmptyProp(FcontainedList) and isEmptyProp(FextensionList) and isEmptyProp(FmodifierExtensionList);
end;
procedure TFhirDomainResource.listFieldsInOrder(fields : TStringList);
begin;
inherited listFieldsInOrder(fields);
fields.add('text');
fields.add('contained');
fields.add('extension');
fields.add('modifierExtension');
end;
function TFhirDomainResource.sizeInBytesV(magic : integer) : cardinal;
begin;
result := inherited sizeInBytesV(magic);
inc(result, FContainedList.sizeInBytes(magic));
inc(result, FExtensionList.sizeInBytes(magic));
inc(result, FModifierExtensionList.sizeInBytes(magic));
end;
function TFhirDomainResource.Link : TFhirDomainResource;
begin
result := TFhirDomainResource(inherited Link);
end;
function TFhirDomainResource.Clone : TFhirDomainResource;
begin
result := TFhirDomainResource(inherited Clone);
end;
procedure TFhirDomainResource.SetText(value : TFhirNarrative);
begin
FText.free;
FText := value;
end;
function TFhirDomainResource.GetContainedList : TFhirResourceList;
begin
if FContainedList = nil then
FContainedList := TFhirResourceList.Create;
result := FContainedList;
end;
function TFhirDomainResource.GetHasContainedList : boolean;
begin
result := (FContainedList <> nil) and (FContainedList.count > 0);
end;
function TFhirDomainResource.GetExtensionList : TFhirExtensionList;
begin
if FExtensionList = nil then
FExtensionList := TFhirExtensionList.Create;
result := FExtensionList;
end;
function TFhirDomainResource.GetHasExtensionList : boolean;
begin
result := (FExtensionList <> nil) and (FExtensionList.count > 0);
end;
function TFhirDomainResource.GetModifierExtensionList : TFhirExtensionList;
begin
if FModifierExtensionList = nil then
FModifierExtensionList := TFhirExtensionList.Create;
result := FModifierExtensionList;
end;
function TFhirDomainResource.GetHasModifierExtensionList : boolean;
begin
result := (FModifierExtensionList <> nil) and (FModifierExtensionList.count > 0);
end;
function TFhirDomainResource.hasExtensions: boolean;
begin
result := (ExtensionList.Count > 0) or (FModifierExtensionList.Count > 0);
end;
end.
| 39.182222 | 839 | 0.738339 |
c32e6ddbcef21847e49408e8fca7cfaef9382811 | 1,043 | dfm | Pascal | gui-example/ZxcvbnDemoForm.dfm | alphaflight83/ZXCVBN-Delphi-Pascal | 525211ad58895e8d0f55dad3bf5ff740ff11cb96 | [
"MIT"
]
| 19 | 2018-04-17T17:59:58.000Z | 2021-02-09T11:51:21.000Z | gui-example/ZxcvbnDemoForm.dfm | alphaflight83/ZXCVBN-Delphi-Pascal | 525211ad58895e8d0f55dad3bf5ff740ff11cb96 | [
"MIT"
]
| 2 | 2018-10-14T16:05:36.000Z | 2020-04-05T13:07:27.000Z | gui-example/ZxcvbnDemoForm.dfm | alphaflight83/ZXCVBN-Delphi-Pascal | 525211ad58895e8d0f55dad3bf5ff740ff11cb96 | [
"MIT"
]
| 10 | 2018-04-18T13:16:20.000Z | 2021-12-08T08:35:47.000Z | object MainForm: TMainForm
Left = 0
Top = 0
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle
Caption = 'zxcvbn-pascal Demo'
ClientHeight = 266
ClientWidth = 379
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 13
object labStrength: TLabel
Left = 16
Top = 59
Width = 94
Height = 13
Caption = 'Password strength:'
end
object labWarnings: TLabel
Left = 16
Top = 92
Width = 345
Height = 161
AutoSize = False
WordWrap = True
end
object pbStrength: TPaintBox
Left = 116
Top = 62
Width = 130
Height = 8
OnPaint = pbStrengthPaint
end
object edPassword: TLabeledEdit
Left = 16
Top = 32
Width = 345
Height = 21
EditLabel.Width = 50
EditLabel.Height = 13
EditLabel.Caption = 'Password:'
TabOrder = 0
end
end
| 19.679245 | 42 | 0.646213 |
479fb3c9ddd893bd9a2d9caf6258d6153a650b45 | 22,520 | pas | Pascal | Games/Sokoban/PathFUnit.pas | joecare99/Public | 9eee060fbdd32bab33cf65044602976ac83f4b83 | [
"MIT"
]
| 11 | 2017-06-17T05:13:45.000Z | 2021-07-11T13:18:48.000Z | Games/Sokoban/PathFUnit.pas | joecare99/Public | 9eee060fbdd32bab33cf65044602976ac83f4b83 | [
"MIT"
]
| 2 | 2019-03-05T12:52:40.000Z | 2021-12-03T12:34:26.000Z | Games/Sokoban/PathFUnit.pas | joecare99/Public | 9eee060fbdd32bab33cf65044602976ac83f4b83 | [
"MIT"
]
| 6 | 2017-09-07T09:10:09.000Z | 2022-02-19T20:19:58.000Z |
unit PathFUnit;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
uses
SysUtils, SokoEngine, types;
type
TMovePlayerProc = procedure(New: TPoint) of object;
T2DArrayOfBoolean = array of array of boolean;
T2DArrayOfInteger = array of array of integer;
{ TPathFinder }
TPathFinder = class
private
FSokobanEngine: TSokobanEngine;
FReachable: T2DArrayOfBoolean;
FDestField: T2DArrayOfInteger;
Visited: array of array of array[1..4] of boolean;
SVisited: array of array of array[1..4] of integer;
PVisited: T2DArrayOfBoolean;
// Identication-Data
FPlayer: TPoint;
FLevel, FPushes, FLevelHeight, FLevelWidth, ArrayPos,
NewCall, APosCount, Score, TrackLength, AbsoluteShortestPath: integer;
HasTarget, StopLoop: boolean;
FBoxPos: array of TPoint;
AList, SortedList: array[1..4] of integer;
function AllowNextStep(ANext: Tpoint; Dir: integer): boolean;
function AllowPNextStep(p: TPoint): boolean;
procedure CheckMove(p, d: Tpoint; dir: integer; APlayer: TPoint;
ACount: integer; const FSokobanEngine: TSokobanEngine);
procedure CheckNext(p: Tpoint; dir: integer; Field: TPuzzleField;
var ACount: integer; const GameData: TGameData);
procedure CheckPlayer(p, Old: TPoint; var Done: boolean);
function GetBoxPosCount: integer;
function GetBoxPos(index: integer): Tpoint;
function GetReachable(p: TPoint): boolean;
function IsReachableForPlayer(APos: TPoint; ADir: integer): boolean;
procedure SetBoxPos(index: integer; AValue: Tpoint);
procedure SetReachable(p: TPoint; AValue: boolean);
procedure SetSokobanEngine(AValue: TSokobanEngine);
procedure TrackBack2(const AVisited: T2DArrayOfInteger;
const PathLength: integer; const fMovePlayer: TMovePlayerProc; const d: TPoint);
public
procedure Clear;
procedure BuildDestField(const ASokobanEngine: TSokobanEngine);
procedure FindPath(BeginP, Target: TPoint; Field: TPuzzleField;
fMovePlayer: TMovePlayerProc);
function FindAllPos(p: TPoint; const Field: TPuzzleField;
const GameData: TGameData): boolean;
function MoveBox(Pos, Dest: TPoint; const FSokobanEngine: TSokobanEngine
): boolean;
function MovePathPlayer(p, d: TPoint; const Field: TPuzzleField;
const GameData: TGameData; fMovePlayer: TMovePlayerProc): boolean;
property SokobanEngine: TSokobanEngine read FSokobanEngine write SetSokobanEngine;
property Reachable[p: Tpoint]: boolean read GetReachable write SetReachable;
property BoxPos[index: integer]: TPoint read GetBoxPos write SetBoxPos;
property BoxPosCount: integer read GetBoxPosCount;
end;
implementation
{ TPathFinder }
{$IFNDEF FPC}
{$ENDIF}
function KDist(p1,p2:Tpoint):integer;inline;
begin
result := abs(p1.x-p2.x)+abs(p1.y-p2.y);
end;
procedure TPathFinder.FindPath(BeginP, Target: TPoint; Field: TPuzzleField;
fMovePlayer: TMovePlayerProc);
{Based on this article:
http://www.gamedev.net/reference/articles/article2003.asp by Patrick Lester}
type
TList = (lOnOpenList, lOnClosedList, lUndefined);
const
TileGCost = 10;
var
OnWhichList: array of array of TList;
GCost: array of array of integer;
ParentList: array of array of Tpoint;
OpenList, FCost, HCost: array of integer;
PathBank, Open: array of TPoint;
Parent, Path: TPoint;
PathLength, x, a, b, m, u, v, TempInt, OpenListCount, PathBankPos,
NewOpenListItemID: integer;
CanAccess: boolean;
procedure InitializeLengths(ALevelWidth, ALevelHeight: integer);
var
x, y: integer;
begin
x := ALevelWidth * ALevelHeight + 2;
SetLength(OnWhichList, ALevelWidth + 1, ALevelHeight + 1);
SetLength(ParentList, ALevelWidth + 1, ALevelHeight + 1);
SetLength(GCost, ALevelWidth + 1, ALevelHeight + 1);
SetLength(OpenList, x);
SetLength(Open, x);
SetLength(FCost, x);
SetLength(HCost, x);
NewOpenListItemID := 0;
PathLength := 0;
GCost[Beginp.X, Beginp.Y] := 0;
OpenListCount := 1;
OpenList[1] := 1;
Open[1] := BeginP;
for x := Low(OnWhichList) to High(OnWhichList) do
for y := Low(OnWhichList[0]) to High(OnWhichList[0]) do
OnWhichList[x][y] := lUndefined;
end;
begin
if Field[Target.X, Target.Y].FPartType <> ptNone then
Exit; // if the target pos isn't ptNone, there is no path
InitializeLengths(Length(Field), Length(Field[0]));
while (1 = 1) and (OpenListCount <> 0) and not
(OnWhichList[Target.x][Target.Y] = lOnClosedList) do
begin
Parent := Open[OpenList[1]];
OnWhichList[Parent.x][Parent.Y] := lOnClosedList;
Dec(OpenListCount);
OpenList[1] := OpenList[OpenListCount + 1];
v := 1;
while 1 = 1 do
begin
u := v;
if 2 * u + 1 <= OpenListCount then
begin
if FCost[OpenList[u]] >= FCost[OpenList[2 * u]] then
v := 2 * u;
if FCost[OpenList[v]] >= FCost[OpenList[2 * u + 1]] then
v := 2 * u + 1;
end
else
if 2 * u <= OpenListCount then
if FCost[OpenList[u]] >= fcost[OpenList[2 * u]] then
v := 2 * u;
if u <> v then
begin
TempInt := OpenList[u];
OpenList[u] := OpenList[v]; // swap the values
OpenList[v] := TempInt;
end
else
Break;
end;
for b := Parent.Y - 1 to Parent.Y + 1 do
for a := Parent.x - 1 to Parent.x + 1 do
begin
CanAccess := True;
if ((a = Parent.x - 1) and ((b = Parent.Y - 1) or (b = Parent.y + 1))) or
((a = Parent.x + 1) and ((b = Parent.Y - 1) or (b = Parent.y + 1))) then
CanAccess := False; // Don't accept diagonal tiles
if (CanAccess) and (OnWhichList[a][b] <> lOnClosedList) and
(Field[a, b].FPartType = ptNone) then
if OnWhichList[a][b] <> lOnOpenList then
begin
Inc(newOpenListItemID); // Create a unique ID
m := Succ(OpenListCount);
OpenList[m] := newOpenListItemID;
Open[newOpenListItemID] := point(a, b);
GCost[a][b] := GCost[Parent.x][Parent.y] + TileGCost;
HCost[OpenList[m]] :=
TileGCost * (Abs(a - Target.x) + Abs(b - Target.Y));
FCost[OpenList[m]] := GCost[a][b] + HCost[OpenList[m]];
ParentList[a][b] := Parent;
while m <> 1 do
begin
if FCost[OpenList[m]] <= FCost[OpenList[m div 2]] then
begin
TempInt := OpenList[m div 2];
OpenList[m div 2] := OpenList[m];
OpenList[m] := TempInt;
m := m div 2;
end
else
Break;
end;
Inc(OpenListCount);
OnWhichList[a][b] := lOnOpenList;
end
else
if GCost[Parent.x][Parent.y] + TileGCost < GCost[a][b] then
begin
ParentList[a][b] := Parent;
GCost[a][b] := GCost[Parent.x][Parent.y] + TileGCost;
for x := 1 to OpenListCount do
begin
if (Open[OpenList[x]] = point(a, b)) then
begin
FCost[OpenList[x]] := GCost[a][b] + HCost[OpenList[x]];
m := x;
while m <> 1 do
begin
if FCost[OpenList[m]] < FCost[OpenList[m div 2]] then
begin
TempInt := OpenList[m div 2];
OpenList[m div 2] := OpenList[m];
OpenList[m] := TempInt;
m := m div 2;
end
else
Break;
end;
Break;
end;
end;
end;
end;
end;
if OnWhichList[Target.x][Target.Y] = lOnClosedList then
begin
Path := Target;
while (Path <> Beginp) do
begin
Path := ParentList[Path.X][Path.Y];
Inc(PathLength);
end;
SetLength(PathBank, PathLength);
Path := Target;
PathBankPos := PathLength;
while (Path <> BeginP) and (PathBankPos > 0) do
begin
Dec(PathBankPos, 1);
PathBank[PathBankPos] := Path;
Path := ParentList[Path.X][Path.Y];
end;
a := 0;
while a <= PathLength - 1 do
begin
fMovePlayer(PathBank[a]);
// frmSokoban.Repaint;
Inc(a, 1);
end;
end
else
Beep; // path not found
end;
function TPathFinder.AllowPNextStep(p: TPoint): boolean;
begin
Result := (FSokobanEngine.PuzzleField[p.x, p.y].FPartType = ptNone) and
(PVisited[p.x, p.y] = False);
end;
procedure TPathFinder.CheckPlayer(p, Old: TPoint; var Done: boolean);
var
dd: integer;
begin
PVisited[p.x, p.y] := True;
if (p = Old) then
Done := True;
if not Done then
begin
for dd := 1 to 4 do
if AllowPNextStep(p + dir4[dd]) then
CheckPlayer(p + dir4[dd], Old, Done);
end;
end;
function TPathFinder.GetBoxPosCount: integer;
begin
Result := succ(high(FBoxPos));
end;
function TPathFinder.GetBoxPos(index: integer): Tpoint;
begin
Result := FBoxPos[index];
end;
function TPathFinder.GetReachable(p: TPoint): boolean;
begin
if assigned(FReachable) then
Result := FReachable[p.x, p.y]
else
Result := False;
end;
function TPathFinder.IsReachableForPlayer(APos: TPoint; ADir: integer): boolean;
var
i, j: integer; //Old player position
Done: boolean;
Old: TPoint;
begin
Result := False;
Old := aPos+Dir4[Adir];
if (Old.X > FSokobanEngine.PuzzleWidth - 1) or (Old.X < 0) or
(Old.Y > FSokobanEngine.PuzzleHeight - 1) or (Old.Y < 0) then
Exit;
if not AllowPNextStep(Old) then
Exit;
for i := 0 to Length(PVisited) - 1 do
for j := 0 to Length(PVisited[0]) - 1 do
PVisited[i][j] := False;
Done := False;
CheckPlayer(APos, Old, Done);
if Done then
begin
FPlayer := Old;
Result := True;
end;
end;
procedure TPathFinder.SetBoxPos(index: integer; AValue: Tpoint);
begin
FBoxPos[index] := AValue;
end;
procedure TPathFinder.SetReachable(p: TPoint; AValue: boolean);
begin
FReachable[p.x, p.y] := AValue;
end;
procedure TPathFinder.SetSokobanEngine(AValue: TSokobanEngine);
begin
if FSokobanEngine = AValue then
Exit;
FSokobanEngine := AValue;
end;
function TPathFinder.AllowNextStep(ANext: Tpoint; Dir: integer): boolean;
begin
Result := False;
if (ANext.X > FSokobanEngine.PuzzleWidth - 1) or (ANext.X < 0) or
(ANext.Y > FSokobanEngine.PuzzleHeight - 1) or (ANext.Y < 0) then
Exit;
Result := (FSokobanEngine.PuzzleField[ANext.X, ANext.Y].FPartType = ptNone) and
(Visited[ANext.X, ANext.Y, dir] = False) and IsReachableForPlayer(ANext, dir);
end; // the old box pos is the parameter
procedure TPathFinder.CheckNext(p: Tpoint; dir: integer; Field: TPuzzleField;
var ACount: integer; const GameData: TGameData);
var
dd: integer;
begin
if dir <> 0 then
Visited[p.x, p.y, dir] := True;
for dd := 1 to 4 do
if AllowNextStep(p + dir4[dd], dd) then
CheckNext(p + dir4[dd], dd, Field, ACount, GameData);
Reachable[p] := True;
Inc(ACount);
end;
// returns false if there is no pos
function TPathFinder.FindAllPos(p: TPoint; const Field: TPuzzleField;
const GameData: TGameData): boolean;
var
i, j, k, APosCount: integer;
begin
SetLength(Visited, GameData.FLevelWidth,
GameData.FLevelHeight);
SetLength(PVisited, GameData.FLevelWidth,
GameData.FLevelHeight);
for i := 0 to Length(Visited) - 1 do
for j := 0 to Length(Visited[0]) - 1 do
for k := 1 to 4 do
Visited[i, j, k] := False;
Field[GameData.FPlayerPos.X,
GameData.FPlayerPos.Y].FPartType := ptNone;
Field[p.x, p.y].FPartType := ptNone;
FPlayer := GameData.FPlayerPos;
APosCount := 0;
CheckNext(p, 0, Field, APosCount, Gamedata); // box pos
Field[GameData.FPlayerPos.X,
GameData.FPlayerPos.Y].FPartType := ptPlayer;
Field[p.x, p.y].FPartType := ptCrate;
Result := APosCount > 1;
end;
procedure TPathFinder.TrackBack2(const AVisited: T2DArrayOfInteger;
const PathLength: integer; const fMovePlayer: TMovePlayerProc; const d: TPoint);
var
Path: array of Tpoint;
Cur: Tpoint;
b: integer;
a: integer;
New: Tpoint;
begin
SetLength(Path, PathLength);
Cur := d;
Path[PathLength - 1] := d;
for a := PathLength downto 2 do
for b := 1 to 4 do
begin
New := Cur + dir4[b];
if AVisited[New.X, New.Y] = a - 1 then
begin
Path[a - 2] := New;
Cur := New;
Break;
end;
end;
for a := 0 to PathLength - 1 do
begin
fMovePlayer(Path[a]);
end;
end;
procedure TPathFinder.Clear;
var
i, j: Integer;
begin
for i := 0 to FLevelWidth-1 do
for j := 0 to FLevelHeight-1 do
begin
FReachable[i,j]:=false;
FDestField[i,j]:=0;
end;
end;
procedure TPathFinder.BuildDestField(const ASokobanEngine: TSokobanEngine);
begin
FSokobanEngine := ASokobanEngine;
if (FPlayer = FSokobanEngine.GameData.FPlayerPos) and
(FPushes = FSokobanEngine.GameData.FPushes) and
(FLevel = FSokobanEngine.GameData.FAktLevel) then
exit;
{ELSE}
// set identication -Data
with FSokobanEngine.gamedata do
begin
FPlayer := FPlayerPos;
self.FPushes := FPushes;
FLevel := FAktLevel;
self.FLevelWidth := FLevelWidth;
self.FLevelHeight := FLevelHeight;
end;
SetLength(FDestField, FLevelWidth, FLevelHeight);
setlength(FReachable, FLevelWidth, FLevelHeight);
end;
function TPathFinder.MovePathPlayer(p, d: TPoint; const Field: TPuzzleField;
const GameData: TGameData; fMovePlayer: TMovePlayerProc): boolean;
var
i, j, PathLength, AbsoluteShortestPath: integer;
Done: boolean;
APList, PSortedList: array[1..4] of integer;
AVisited: T2DArrayOfInteger;
CanReach: boolean;
procedure CheckPlayer(x, y, ACount: integer);
var
z: integer;
pp: TPoint;
function AllowPNextStep(x, y, Count: integer): boolean;
begin
Result := False;
if (Field[x, y].FPartType <> ptNone) or (Count >= AVisited[x, y]) then
Exit;
if CanReach and (Count + KDist(p,d) >= PathLength) then
Exit;
Result := True; { or
(Field[x, y].FPartType = ptReachable)}
end;
function BestFound2(Index: integer): integer;
var
i, j, k: integer;
begin
for i := 1 to 4 do
begin
Score := Kdist(point(x,y)+Dir4[i],d);
APList[i] := Score;
PSortedList[i] := i;
end;
for k := 2 to 4 do
begin
j := k;
while j <> 1 do
begin
if APList[j - 1] > APList[j] then
begin
i := APList[j - 1];
APList[j - 1] := APList[j];
APList[j] := i;
i := PSortedList[j - 1];
PSortedList[j - 1] := PSortedList[j];
PSortedList[j] := i;
Dec(j);
end
else
j := 1;
end;
end;
Result := PSortedList[Index];
end;
begin
AVisited[x, y] := ACount;
if point(x,y) = d then
begin
CanReach := True;
PathLength := ACount;
if ACount = AbsoluteShortestPath then
Done := True;
end;
for z := 1 to 4 do
if not Done then
begin
pp:=point(x,y)+dir4[BestFound2(z)];
if AllowPNextStep(pp.x, pp.y, ACount + 1) then
CheckPlayer(pp.x, pp.y , ACount + 1);
end;
end;
begin
Result := False;
if Field[d.x, d.y].FPartType <> ptNone then
Exit;
SetLength(AVisited, GameData.FLevelWidth,
GameData.FLevelHeight);
for i := 0 to Length(AVisited) - 1 do
for j := 0 to Length(AVisited[0]) - 1 do
AVisited[i][j] := MaxInt;
AbsoluteShortestPath := KDist(p,d);
Done := False;
CanReach := False;
//Field[x, y].FPartType := ptCrate;
CheckPlayer(p.x, p.y, 0);
if AVisited[d.x, d.y] = MaxInt then
Beep
else
begin
TrackBack2(AVisited, PathLength, fMovePlayer, d);
Result := True; // MovePlayer has found a path
end;
//Field[x, y].FPartType := ptReachable;
end;
procedure TPathFinder.CheckMove(p, d: Tpoint; dir: integer; APlayer: TPoint;
ACount: integer; const FSokobanEngine: TSokobanEngine);
var
i, bfDir: integer;
pp: TPoint;
function IsReachableForPlayer_(AXPos, AYPos, ADir: integer): boolean;
var
OldX, OldY, i, j: integer;
Done: boolean;
APList, PSortedList: array[1..4] of integer;
procedure CheckPlayer(x, y: integer);
var
z: integer;
pp: TPoint;
function BestFound2(Index: integer): integer;
var
i, j, k: integer;
begin
for i := 1 to 4 do
begin
case i of
1: Score := Abs(x - OldX) + Abs(y - 1 - OldY);
2: Score := Abs(x + 1 - OldX) + Abs(y - OldY);
3: Score := Abs(x - OldX) + Abs(y + 1 - OldY);
4: Score := Abs(x - 1 - OldX) + Abs(y - OldY);
end;
APList[i] := Score;
PSortedList[i] := i;
end;
for k := 2 to 4 do
begin
j := k;
while j <> 1 do
begin
if APList[j - 1] > APList[j] then
begin
i := APList[j - 1];
APList[j - 1] := APList[j];
APList[j] := i;
i := PSortedList[j - 1];
PSortedList[j - 1] := PSortedList[j];
PSortedList[j] := i;
Dec(j);
end
else
j := 1;
end;
end;
Result := PSortedList[Index];
end;
begin
PVisited[x, y] := True;
if (x = OldX) and (y = OldY) then
Done := True;
for z := 1 to 4 do
if not Done then
begin
pp := point(x,y)+Dir4[BestFound2(z)];
if AllowPNextStep(pp) then
CheckPlayer(pp.x, pp.y);
end;
end;
begin
Result := False;
OldX := AXPos;
OldY := AYPos;
case ADir of
1: Inc(OldY);
2: Dec(OldX);
3: Dec(OldY);
4: Inc(OldX);
end;
if (OldX > FSokobanEngine.PuzzleWidth - 1) or (OldX < 0) or
(OldY > FSokobanEngine.PuzzleHeight - 1) or (OldY < 0) then
Exit;
if (FSokobanEngine.PuzzleField[OldX, OldY].FPartType <> ptNone) then
Exit;
for i := 0 to Length(PVisited) - 1 do
for j := 0 to Length(PVisited[0]) - 1 do
PVisited[i][j] := False;
Done := False;
//!! FSokobanEngine.PuzzleField[x, y].FPartType := ptCrate;
CheckPlayer(APlayer.X, APlayer.Y);
if Done then
begin
FPlayer.X := OldX;
FPlayer.Y := OldY;
Result := True;
end;
//!! Field[x, y].FPartType := ptReachable;
end;
function AllowNextStep(ANext:TPoint; Dir: integer): boolean;
begin
Result := False;
if (ANext.X > FLevelWidth - 1) or (ANext.X < 0) or (ANext.Y > FLevelHeight - 1) or
(ANext.Y < 0) then
Exit;
if HasTarget and ((ACount > TrackLength) or
(Acount + Kdist(ANext, d) > TrackLength)) then
Exit;
Result := (FReachable[ANext.X, ANext.Y]) and
(SVisited[ANext.X, ANext.Y, dir] > ACount) and IsReachableForPlayer(p, dir);
end;
function BestFound(x, y, dx, dy, Index: integer): integer;
var
i, j, k: integer;
begin
for i := 1 to 4 do
begin
case i of
1: Score := Abs(x - dx) + Abs(y - 1 - dy);
2: Score := Abs(x + 1 - dx) + Abs(y - dy);
3: Score := Abs(x - dx) + Abs(y + 1 - dy);
4: Score := Abs(x - 1 - dx) + Abs(y - dy);
end;
AList[i] := Score;
SortedList[i] := i;
end;
// Bubble-Sort
for k := 2 to 4 do
begin
j := k;
while (j > 1) and (AList[SortedList[j - 1]] > AList[SortedList[j]]) do
begin
i := SortedList[j - 1];
SortedList[j - 1] := SortedList[j];
SortedList[j] := i;
Dec(j);
end;
end;
Result := SortedList[Index];
end;
begin
if dir <> 0 then
begin
SVisited[p.x, p.y, dir] := ACount;
end;
if HasTarget then
Inc(NewCall);
if p=d then
begin
{ if HasTarget and (ACount >= TrackLength) then
begin
end
else
begin }
HasTarget := True;
TrackLength := ACount;
ArrayPos := 0;
NewCall := 0;
SetLength(FBoxPos, TrackLength);
//if TrackLength = AbsoluteShortestPath + 1 then // check if it is the
// StopLoop := True; // shortest path
// end;
end;
for i := 1 to 4 do
begin
if not StopLoop then
begin
bfDir:=BestFound(p.x, p.y, d.x, d.y, i);
pp:=p+dir4[bfDir];
if AllowNextStep(pp, bfDir) then
CheckMove(pp , d, bfDir, FPlayer,
ACount + 1, FSokobanEngine);
end;
end;
if HasTarget and (NewCall = 0) then
begin
FBoxPos[ArrayPos] := p;
Inc(ArrayPos);
end;
if HasTarget and (NewCall > 0) then
Dec(NewCall);
end;
function TPathFinder.MoveBox(Pos, Dest: TPoint; const FSokobanEngine: TSokobanEngine): boolean;
var
i, j, k: integer;
tb: Tpoint;
begin
tb := Pos;
SetLength(SVisited, FSokobanEngine.PuzzleWidth,
FSokobanEngine.PuzzleHeight);
SetLength(PVisited, FSokobanEngine.PuzzleWidth,
FSokobanEngine.PuzzleHeight);
for i := 0 to Length(SVisited) - 1 do
for j := 0 to Length(SVisited[0]) - 1 do
for k := 1 to 4 do
SVisited[i, j, k] := MaxInt;
FPlayer := FSokobanEngine.GameData.FPlayerPos;
APosCount := 1; // count the steps
NewCall := 0;
HasTarget := False;
StopLoop := False;
TrackLength := 0;
AbsoluteShortestPath := KDist(Dest,tb);
CheckMove(tb, Dest, 0, FPlayer,
APosCount, FSokobanEngine);
{ SetLength(FBoxPos, TrackLength);
TraceBack(x, y); }
Result := TrackLength > 0;
end;
end.
| 26.216531 | 96 | 0.571581 |
c34d734ed128fa98554108d87d44a652ae006101 | 20,766 | dfm | Pascal | Module_VAchar.dfm | mickyvac/fc-measure | 0b6db36af01f25479a956138cfceddd02a88d14d | [
"MIT"
]
| null | null | null | Module_VAchar.dfm | mickyvac/fc-measure | 0b6db36af01f25479a956138cfceddd02a88d14d | [
"MIT"
]
| null | null | null | Module_VAchar.dfm | mickyvac/fc-measure | 0b6db36af01f25479a956138cfceddd02a88d14d | [
"MIT"
]
| null | null | null | object FormVAchar: TFormVAchar
Left = 320
Top = 18
Caption = 'VA characteristic module'
ClientHeight = 955
ClientWidth = 1220
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -10
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poMainFormCenter
OnCreate = FormCreate
OnDestroy = FormDestroy
DesignSize = (
1220
955)
PixelsPerInch = 96
TextHeight = 13
object Label11: TLabel
Left = 16
Top = 239
Width = 76
Height = 13
Caption = 'FileName Suffix:'
Color = clSkyBlue
ParentColor = False
end
object Label46: TLabel
Left = 88
Top = 151
Width = 33
Height = 13
Caption = 'Preset:'
Color = clSkyBlue
ParentColor = False
end
object Label19: TLabel
Left = 248
Top = 639
Width = 85
Height = 13
Caption = 'Turn Voltage [mV]'
Color = clSkyBlue
ParentColor = False
end
object Label20: TLabel
Left = 440
Top = 639
Width = 20
Height = 16
Caption = 'mV'
Color = clSkyBlue
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object Label6: TLabel
Left = 48
Top = 63
Width = 676
Height = 13
Caption =
'Postup v jednom kroku: Ceka se stabilisation time, pak se zmeri ' +
'HFR, pak se meri a ceka po averaging time (ulozi se prumer za ce' +
'lou tuto dobu)'
Color = clSkyBlue
ParentColor = False
end
object Label9: TLabel
Left = 256
Top = 767
Width = 75
Height = 13
Caption = 'HFR frequency '
Color = clSkyBlue
ParentColor = False
end
object Label16: TLabel
Left = 680
Top = 15
Width = 116
Height = 13
Caption = 'Estimated remaining time'
Color = clSkyBlue
ParentColor = False
end
object Label22: TLabel
Left = 912
Top = 15
Width = 13
Height = 13
Caption = 'ms'
Color = clSkyBlue
ParentColor = False
end
object Label23: TLabel
Left = 40
Top = 727
Width = 92
Height = 13
Caption = 'Aquire Refresh time'
Color = clSkyBlue
ParentColor = False
end
object Label24: TLabel
Left = 232
Top = 727
Width = 13
Height = 13
Caption = 'ms'
Color = clSkyBlue
ParentColor = False
end
object Label27: TLabel
Left = 80
Top = 48
Width = 160
Height = 13
Caption = 'TODO: VA CHAR preset manager'
end
object Label3: TLabel
Left = 48
Top = 103
Width = 457
Height = 13
Caption =
'Two way: kdyz klesna napeti pod hranici, nastavi se priznak - al' +
'e dokonci se jeste soucasny step'
Color = clSkyBlue
ParentColor = False
end
object Label14: TLabel
Left = 48
Top = 87
Width = 618
Height = 13
Caption =
'Two way turn condition: nastavi se take kdyz je aktivovano SW un' +
'dervoltage protection, nebo kdyz je dosazen nejaky globalni limi' +
't'
Color = clSkyBlue
ParentColor = False
end
object Label13: TLabel
Left = 16
Top = 263
Width = 86
Height = 13
Caption = 'Next file full name:'
Color = clSkyBlue
ParentColor = False
end
object Label28: TLabel
Left = 48
Top = 119
Width = 492
Height = 13
Caption =
'Aquire refresh time: aquire interval - have affect on the SW und' +
'ervoltage protection - how fast is updated'
Color = clSkyBlue
ParentColor = False
end
object Label29: TLabel
Left = 240
Top = 239
Width = 122
Height = 13
Caption = 'Current values in mA/cm2'
Color = clSkyBlue
ParentColor = False
end
object Button1: TButton
Left = 7
Top = 7
Width = 176
Height = 26
Caption = 'Hide'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 80
Top = 186
Width = 249
Height = 25
Caption = 'Run'
Font.Charset = DEFAULT_CHARSET
Font.Color = clGreen
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 1
OnClick = Button2Click
end
object Button3: TButton
Left = 344
Top = 186
Width = 73
Height = 25
Caption = 'Stop'
Enabled = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clRed
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 2
end
object Edit6: TEdit
Left = 112
Top = 231
Width = 97
Height = 21
TabOrder = 3
Text = 'VA'
end
object CheckBox5: TCheckBox
Left = 32
Top = 623
Width = 201
Height = 34
Caption = 'Two way IV char'
Color = clSkyBlue
ParentColor = False
TabOrder = 4
end
object ComboBox6: TComboBox
Left = 160
Top = 143
Width = 153
Height = 24
Color = clMoneyGreen
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 5
Text = 'ComboBox6'
end
object Button12: TButton
Left = 344
Top = 143
Width = 49
Height = 25
Caption = 'Save'
TabOrder = 6
end
object Button19: TButton
Left = 424
Top = 143
Width = 49
Height = 25
Caption = 'Delete'
TabOrder = 7
end
object Edit8: TEdit
Left = 336
Top = 631
Width = 97
Height = 21
TabOrder = 8
Text = 'Edit8'
end
object CheckBox1: TCheckBox
Left = 32
Top = 663
Width = 201
Height = 50
Caption = 'SW UnderVoltage PROTECTION'
Color = clSkyBlue
ParentColor = False
TabOrder = 9
end
object CheckBox2: TCheckBox
Left = 32
Top = 751
Width = 201
Height = 42
Caption = 'Measure HFR during current steps'
Color = clSkyBlue
ParentColor = False
TabOrder = 10
end
object Edit7: TEdit
Left = 344
Top = 759
Width = 65
Height = 21
TabOrder = 11
Text = '50'
end
object Button4: TButton
Left = 192
Top = 8
Width = 225
Height = 25
Caption = 'Stop'
TabOrder = 12
end
object PanFlowStatus: TPanel
Left = 430
Top = 8
Width = 243
Height = 25
Color = clGreen
TabOrder = 13
object LaFlowStatus: TLabel
Left = 8
Top = 8
Width = 30
Height = 13
Caption = 'Status'
end
end
object Edit13: TEdit
Left = 808
Top = 15
Width = 65
Height = 21
TabOrder = 14
Text = '50'
end
object Edit15: TEdit
Left = 160
Top = 719
Width = 65
Height = 21
TabOrder = 15
Text = '50'
end
object PanPlot: TPanel
Left = 616
Top = 416
Width = 535
Height = 465
Anchors = [akLeft, akTop, akRight]
Caption = 'PanPlot'
TabOrder = 16
object Label33: TLabel
Left = 17
Top = 8
Width = 54
Height = 13
Caption = 'Plot Control'
end
object Chart1: TChart
Left = 1
Top = 75
Width = 533
Height = 389
BackWall.Brush.Color = clWhite
BackWall.Brush.Style = bsClear
Legend.Visible = False
Title.AdjustFrame = False
Title.Text.Strings = (
'TChart')
Title.Visible = False
View3D = False
View3DWalls = False
Align = alBottom
TabOrder = 0
object Series1: TFastLineSeries
Marks.Arrow.Visible = True
Marks.Callout.Brush.Color = clBlack
Marks.Callout.Arrow.Visible = True
Marks.Visible = False
LinePen.Color = clRed
XValues.Name = 'X'
XValues.Order = loAscending
YValues.Name = 'Y'
YValues.Order = loNone
end
end
object ComboBox18: TComboBox
Left = 76
Top = 4
Width = 365
Height = 21
ItemIndex = 0
TabOrder = 1
Text = 'Monitor U, I: last 10min'
Items.Strings = (
'Monitor U, I: last 10min'
'Monitor U, I: last 1h'
'Monitor U, I: last 24h'
'Monitor U, I: all'
'----files----'
'')
end
object Button15: TButton
Left = 616
Top = 8
Width = 153
Height = 25
Caption = 'Plot Multiview'
TabOrder = 2
end
end
object Panel1: TPanel
Left = 600
Top = 168
Width = 713
Height = 220
Caption = 'Panel1'
TabOrder = 17
DesignSize = (
713
220)
object LaMonPow: TLabel
Left = 21
Top = 80
Width = 297
Height = 25
Alignment = taCenter
AutoSize = False
Caption = 'LaMonPow'
Color = clBlack
Font.Charset = DEFAULT_CHARSET
Font.Color = clFuchsia
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object LaMonVref: TLabel
Left = 360
Top = 80
Width = 280
Height = 25
Alignment = taCenter
AutoSize = False
Caption = 'LaMonVref'
Color = clBlack
Font.Charset = DEFAULT_CHARSET
Font.Color = clHotLight
Font.Height = -21
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object LaMonVolt: TLabel
Left = 5
Top = 45
Width = 382
Height = 35
Alignment = taCenter
Anchors = [akLeft, akTop, akRight]
AutoSize = False
Caption = 'LaMonVolt'
Color = clBlack
Font.Charset = DEFAULT_CHARSET
Font.Color = clRed
Font.Height = -32
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object LaMonCurr: TLabel
Left = 21
Top = 6
Width = 382
Height = 35
Alignment = taCenter
Anchors = [akLeft, akTop, akRight]
AutoSize = False
Caption = 'LaMonCurr'
Color = clBlack
Font.Charset = DEFAULT_CHARSET
Font.Color = clLime
Font.Height = -32
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object Label25: TLabel
Left = 16
Top = 110
Width = 425
Height = 37
Alignment = taCenter
AutoSize = False
Caption = 'Label25 FLOW'
Color = clBlack
Font.Charset = DEFAULT_CHARSET
Font.Color = clYellow
Font.Height = -32
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object CheckBox3: TCheckBox
Left = 48
Top = 162
Width = 201
Height = 34
Caption = 'Turn condition detected'
Color = clSkyBlue
ParentColor = False
TabOrder = 0
end
end
object Panel2: TPanel
Left = 16
Top = 296
Width = 545
Height = 164
Caption = 'Panel2'
TabOrder = 18
object Label17: TLabel
Left = 288
Top = 7
Width = 51
Height = 13
Caption = 'Start value'
Color = clSkyBlue
ParentColor = False
end
object Label58: TLabel
Left = 464
Top = 7
Width = 20
Height = 16
Caption = 'mA'
Color = clSkyBlue
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object Label75: TLabel
Left = 464
Top = 31
Width = 20
Height = 16
Caption = 'mA'
Color = clSkyBlue
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object Label21: TLabel
Left = 288
Top = 23
Width = 113
Height = 17
AutoSize = False
Caption = 'Step'
Color = clSkyBlue
ParentColor = False
end
object Label41: TLabel
Left = 288
Top = 47
Width = 113
Height = 17
AutoSize = False
Caption = 'End value'
Color = clSkyBlue
ParentColor = False
end
object Label76: TLabel
Left = 464
Top = 55
Width = 20
Height = 16
Caption = 'mA'
Color = clSkyBlue
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object Label26: TLabel
Left = 472
Top = 87
Width = 20
Height = 16
Caption = 'mA'
Color = clSkyBlue
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object Label18: TLabel
Left = 0
Top = 15
Width = 73
Height = 13
Caption = 'Control variable'
Color = clSkyBlue
ParentColor = False
end
object Label15: TLabel
Left = 24
Top = -1
Width = 187
Height = 13
Caption = 'Sequence control - step setpoint values'
end
object RBSeqIteration: TRadioButton
Left = 8
Top = 48
Width = 257
Height = 25
Caption = 'Iteration'
TabOrder = 0
end
object RBSeqUser: TRadioButton
Left = 8
Top = 112
Width = 257
Height = 25
Caption = 'User sequence'
TabOrder = 1
end
object ESeqUser: TEdit
Left = 112
Top = 120
Width = 353
Height = 21
TabOrder = 2
Text = 'User sequence of steps'
end
object EValStart: TEdit
Left = 344
Top = 7
Width = 113
Height = 21
TabOrder = 3
Text = 'EValStart'
OnChange = EValStartChange
end
object EStep: TEdit
Left = 344
Top = 31
Width = 113
Height = 21
TabOrder = 4
Text = 'EStep'
OnChange = EStepChange
end
object EValEnd: TEdit
Left = 344
Top = 55
Width = 113
Height = 21
TabOrder = 5
Text = 'EValEnd'
OnChange = EValEndChange
end
object CBControlVar: TComboBox
Left = 88
Top = 15
Width = 121
Height = 21
Style = csDropDownList
ItemIndex = 0
TabOrder = 6
Text = 'Current'
Items.Strings = (
'Current'
'Voltage')
end
end
object Panel3: TPanel
Left = 16
Top = 800
Width = 457
Height = 140
Caption = 'Panel3'
TabOrder = 19
object Label34: TLabel
Left = 40
Top = 80
Width = 89
Height = 17
AutoSize = False
Caption = 'Current limit low'
Color = clSkyBlue
ParentColor = False
end
object Label67: TLabel
Left = 248
Top = 33
Width = 20
Height = 16
Caption = 'mA'
Color = clSkyBlue
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object Label68: TLabel
Left = 248
Top = 57
Width = 20
Height = 16
Caption = 'mA'
Color = clSkyBlue
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object Label69: TLabel
Left = 248
Top = 81
Width = 20
Height = 16
Caption = 'mV'
Color = clSkyBlue
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object Label71: TLabel
Left = 256
Top = 105
Width = 20
Height = 16
Caption = 'mV'
Color = clSkyBlue
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentColor = False
ParentFont = False
end
object Label43: TLabel
Left = 40
Top = 56
Width = 89
Height = 17
AutoSize = False
Caption = 'Voltage limit low'
Color = clSkyBlue
ParentColor = False
end
object Label45: TLabel
Left = 40
Top = 32
Width = 89
Height = 17
AutoSize = False
Caption = 'Voltage limit high'
Color = clSkyBlue
ParentColor = False
end
object RadioButton3: TRadioButton
Left = 8
Top = 8
Width = 257
Height = 25
Caption = 'Use global limits'
Checked = True
TabOrder = 0
TabStop = True
end
object Edit18: TEdit
Left = 136
Top = 28
Width = 105
Height = 21
TabOrder = 1
Text = 'Edit18'
end
object Edit24: TEdit
Left = 136
Top = 76
Width = 105
Height = 21
TabOrder = 2
Text = 'Edit24'
end
object Edit23: TEdit
Left = 136
Top = 52
Width = 105
Height = 21
TabOrder = 3
Text = 'Edit23'
end
object Edit22: TEdit
Left = 136
Top = 100
Width = 105
Height = 21
TabOrder = 4
Text = 'Edit22'
end
end
object PanFullPath: TPanel
Left = 109
Top = 264
Width = 388
Height = 22
BorderStyle = bsSingle
Caption = 'Pan'
Color = clWhite
TabOrder = 20
end
object Panel4: TPanel
Left = 16
Top = 475
Width = 417
Height = 137
Caption = 'Panel4'
TabOrder = 21
object Label1: TLabel
Left = 24
Top = 20
Width = 78
Height = 13
Caption = 'Stabilization time'
Color = clSkyBlue
ParentColor = False
end
object Label2: TLabel
Left = 184
Top = 20
Width = 13
Height = 13
Caption = 'ms'
Color = clSkyBlue
ParentColor = False
end
object Label4: TLabel
Left = 24
Top = 68
Width = 70
Height = 13
Caption = 'Averaging time'
Color = clSkyBlue
ParentColor = False
end
object Label5: TLabel
Left = 184
Top = 76
Width = 13
Height = 13
Caption = 'ms'
Color = clSkyBlue
ParentColor = False
end
object Label7: TLabel
Left = 24
Top = 44
Width = 44
Height = 13
Caption = 'HFR time'
Color = clSkyBlue
ParentColor = False
end
object Label8: TLabel
Left = 184
Top = 44
Width = 13
Height = 13
Caption = 'ms'
Color = clSkyBlue
ParentColor = False
end
object Label10: TLabel
Left = 16
Top = 100
Width = 87
Height = 13
Caption = 'Total time per step'
Color = clSkyBlue
ParentColor = False
end
object Label12: TLabel
Left = 200
Top = 100
Width = 13
Height = 13
Caption = 'ms'
Color = clSkyBlue
ParentColor = False
end
object Edit1: TEdit
Left = 112
Top = 20
Width = 65
Height = 21
TabOrder = 0
Text = '50'
end
object Edit4: TEdit
Left = 112
Top = 68
Width = 65
Height = 21
TabOrder = 1
Text = '50'
end
object Edit5: TEdit
Left = 112
Top = 44
Width = 65
Height = 21
TabOrder = 2
Text = '50'
end
object Edit11: TEdit
Left = 128
Top = 100
Width = 65
Height = 21
TabOrder = 3
Text = '50'
end
end
object FormRefreshTimer: TTimer
Left = 1104
Top = 8
end
end
| 21.563863 | 75 | 0.528364 |
47f01ebd5f9f507762d97d453539c4cfec2a39e4 | 2,345 | pas | Pascal | UCmdExecBuffer.pas | CloudDelphi/CompInstall | ebcb05124ddc71b00cabffddd822e0a3c1a3db69 | [
"MIT"
]
| 2 | 2019-05-01T13:11:49.000Z | 2020-08-29T03:04:03.000Z | UCmdExecBuffer.pas | fhasovic/CompInstall | c12a81badaf0fae8e0e54040ba45cb6f824f3799 | [
"MIT"
]
| null | null | null | UCmdExecBuffer.pas | fhasovic/CompInstall | c12a81badaf0fae8e0e54040ba45cb6f824f3799 | [
"MIT"
]
| 1 | 2020-08-29T03:04:04.000Z | 2020-08-29T03:04:04.000Z | unit UCmdExecBuffer;
interface
{The TCmdExecBuffer class executes command line programs in cmd.exe
and allows to retrieve line by line output using OnLine event.}
type
TCmdExecBufferEvLine = procedure(const Text: String) of object;
TCmdExecBuffer = class
public
OnLine: TCmdExecBufferEvLine; //event to retrieve line by line output
CommandLine: String;
WorkDir: String;
Lines: String; //all output lines
ExitCode: Cardinal;
function Exec: Boolean; //function to execute the program
end;
implementation
uses Winapi.Windows;
function TCmdExecBuffer.Exec: Boolean;
var
SA: TSecurityAttributes;
SI: TStartupInfo;
PI: TProcessInformation;
StdOutPipeRead, StdOutPipeWrite: THandle;
WasOK: Boolean;
Buffer: array[0..255] of AnsiChar;
BytesRead: Cardinal;
Handle: Boolean;
aLine: String;
begin
Result := False;
Lines := '';
//ExitCode := (-1);
with SA do
begin
nLength := SizeOf(SA);
bInheritHandle := True;
lpSecurityDescriptor := nil;
end;
CreatePipe(StdOutPipeRead, StdOutPipeWrite, @SA, 0);
try
with SI do
begin
FillChar(SI, SizeOf(SI), 0);
cb := SizeOf(SI);
dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
wShowWindow := SW_HIDE;
hStdInput := GetStdHandle(STD_INPUT_HANDLE); // don't redirect stdin
hStdOutput := StdOutPipeWrite;
hStdError := StdOutPipeWrite;
end;
Handle := CreateProcess(nil, PChar('cmd.exe /C '+CommandLine),
nil, nil, True, 0, nil,
PChar(WorkDir), SI, PI);
CloseHandle(StdOutPipeWrite);
if Handle then
try
repeat
WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);
if BytesRead > 0 then
begin
Buffer[BytesRead] := #0;
OemToAnsi(Buffer, Buffer);
aLine := WideString(Buffer);
Lines := Lines + aLine;
if Assigned(OnLine) then
OnLine(aLine);
end;
until not WasOK or (BytesRead = 0);
WaitForSingleObject(PI.hProcess, INFINITE);
GetExitCodeProcess(PI.hProcess, ExitCode);
Result := True;
finally
CloseHandle(PI.hThread);
CloseHandle(PI.hProcess);
end;
finally
CloseHandle(StdOutPipeRead);
end;
end;
end.
| 24.946809 | 74 | 0.635394 |
fcb22e7aec904e8fd7981039a6689d459768a0b4 | 273,455 | dfm | Pascal | Source/HighDPI/CodeCoverage.Images.DM.dfm | interestingitems/DelphiCodeCoveragePlugin | 2bb32123ae1ea575f072d452d71fe68661a2b0c4 | [
"MIT"
]
| 5 | 2021-10-21T04:30:29.000Z | 2022-01-20T20:37:53.000Z | Source/HighDPI/CodeCoverage.Images.DM.dfm | interestingitems/DelphiCodeCoveragePlugin | 2bb32123ae1ea575f072d452d71fe68661a2b0c4 | [
"MIT"
]
| 3 | 2021-10-21T09:20:10.000Z | 2021-11-09T13:14:35.000Z | Source/HighDPI/CodeCoverage.Images.DM.dfm | interestingitems/DelphiCodeCoveragePlugin | 2bb32123ae1ea575f072d452d71fe68661a2b0c4 | [
"MIT"
]
| 1 | 2021-10-21T04:32:39.000Z | 2021-10-21T04:32:39.000Z | object dmCodeCoverageImages: TdmCodeCoverageImages
Height = 336
Width = 536
PixelsPerInch = 144
object Images: TVirtualImageList
AutoFill = True
Images = <
item
CollectionIndex = 0
CollectionName = 'NoCoverage'
Name = 'NoCoverage'
end
item
CollectionIndex = 1
CollectionName = 'CodeCoverage'
Name = 'CodeCoverage'
end
item
CollectionIndex = 2
CollectionName = 'RunCodeCoverage'
Name = 'RunCodeCoverage'
end>
ImageCollection = MainImageCollection
Scaled = False
Left = 208
Top = 136
end
object MainImageCollection: TImageCollection
Images = <
item
Name = 'NoCoverage'
SourceImages = <
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000100000001008060000001FF3FF
61000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000004
20494441547801001004EFFB01FFFFFF00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000960F0F22960F0F2200000000000000000000
0000000000000000000000000000040000000000000000000000000000000000
00000000000000AA000006EE0E0E7B06010078FBFEFEF2000000150000000000
0000000000000000000000000000000200000000000000000000000000000000
00000000990F0F32EF0F0DCD180E0B7E3E211C06000000140000000000000000
0000000000000000000000000000000004000000000000000000000000AA0000
06EE0E0E7B0503017A2B1E1D041B0C0A00FFF9FA000000000000000000000000
0000000000000000000000000000000000040000000000000000980F0F34EF00
FE9F1914112C2E211C0006FFFF00FFF9FA000000000000000000990E0DFF0000
0000000000000000000000000000FFFF00BE01AA000006F00E0E7D060503782B
2923041C161200FFF8FA00FFF9FA00FFF9FA00FFF9FA00FFF8FA00FFF9FA00FF
F9FA00FFF9FA0000FCFD0000000000BAFAFA0004EF0E0DBD1A17133C2E2B2400
07060500FFFCFC00000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000020000000701020100010000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000353F9FAA3F1FBFC0AE1E5
E9370B0A08010D0A080000FCFD0000FDFD0000FDFD0000FDFD0000FCFD0000FD
FD0000FDFD0000FDFD0000FEFF0000000000DDFDFD000100000000000000009B
0E0E38FE00FF9E191613292E211C0005FEFE00FFF9FA00FFF9FA00B6D9DF0000
00000000000000000000000000000000000000000000C6010000000000000000
000000009F000008F90F0D83070404722D1F1A02180A0900FFF9FA00B6D9DF00
67F2F30100000000000000000000000000000000000000000200000000000000
0000000000610000F868F1F375FCFBFD3BCDDCE2D7CDE1E600FAFDFD00000000
0000000000000000000000000000000000000000000000000001000000000000
0000000000000000000000000000000000009F000008FA0D0D7D07040376F9FD
FDF267F2F3130000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000990D0D289C
0E0E2400000000000000000000000000000000000000000000000001FFFFFF00
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000010000FF
FF9D2D9F0174066E870000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D
F8000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000009
28494441547801001809E7F601FFFFFF00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000002000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000020000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000200000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000004000000000101010000000000000000
00000000000000000000000000000000000000000000000000000000009B0E0E
38FE00FE95000000EC67F2F44700000000000000000000000000000000000000
00000000000000000000000000FFFFFF00040000000000000000000000000000
000000000000000000000000000000000000000000009212120E07FCFA850504
036A2C171602CDE5E90000000000000000000000000000000000000000000000
0000000000000000000000000000000000000400000000000000000000000000
000000000000000000000000000000000000009A0D0D5100FDFB931D13121B28
17130005FEFE0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000004000000000000000000000000
000000000000000000000000950B0B18030402960B0808512E201B0012080700
FFFCFC0000FEFE00000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000040000000000000000000000
000000000080000002190F0C650301028A231D190E251A160002FDFE00FFFBFC
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000400000000000000000000
0000960D0D270201009B110F0D3D302923000D070600FFFBFC0000FDFE000000
0000000000000000000000000000990E0DFF0000000000000000000000000000
0000000000000000000000000000FFFF00BE0000004301FFFFFF00AB010106EE
0E0C760604047D29262006201D1A0001FEFD00FFFBFC00FFFBFC0000FBFC00FF
FBFC00FFFCFC0000FBFC00FFFBFC00FFFBFC0000FBFC00FFFBFC00FFFCFC0000
FBFC00FFFBFC000000000000000000BAFAFA0066F1F2010400000000EF0E0DBD
1916133C2E2A2300090807000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000200000000000000
0702020100020101000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000020000000006F2
F33EE6E7EC86BDC4CDFCE1E4E800000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000001FFFFFF0001
01010000000000970C0C2C0302019D13121036302922000A050400FFFBFC0000
FBFC00FFFBFC00FFFCFC0000FBFC00B5D8DE0000000000000000000000000000
00000000000000000000000000000000000000000000C666F1F23B01FFFFFF00
01010100000000000000000080000002190E0E6C03020185261F1A0C23191500
01FCFD00FFFBFC00FFFCFC0000FBFC00B5D8DE0067F2F3010000000000000000
000000000000000000000000000000000000000000000000FFFFFF0002000000
00000000000000000000000000800000FE67F2F292F902FA2AD7DFE4B3C1D0D8
00F0F5F600000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000020000
000000000000000000000000000000000000000000006BEEF7E367F2F34EF3F7
F656C4D5DCEAD5E4E800FCFEFE00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000200
0000000000000000000000000000000000000000000000000000000000000067
F1F4AB05020327DFECEE9FC2DAE000E9F4F60000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000001
FFFFFF0001010100000000000000000000000000000000000000000000000000
00000000000000000000000099100C4100FE0195010000EE66F2F33C00000000
00000000000000000000000000000000000000000000000000000000FFFFFF00
01FFFFFF00000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0002000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000020000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000200000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000010000FFFF0CC1DDF205D08E320000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7A
F4000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000010
30494441547801002010DFEF01FFFFFF00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000002000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000020000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000200000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000002000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000020000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000400000000000000000101010000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000009B0E0E38FE00FE95000000EC67F2F44700
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000FFFFFF000000000004000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000991A1A0A00F4F2870504036C2C171702CDE5E80000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000040000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000009A0E0E47FFF4F49B1C12101D2A17150005FFFF0000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000400000000000000000000
000000000000000000000000000000000000000000000000000000000000990D
0D140001008E0907055D2E1F1A00140A0900FFFCFD0000FCFD00000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000004000000000000000000
0000000000000000000000000000000000000000000000000000009A0E0E5B00
010090221A1614281A170001FEFE0000FDFD0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000040000000000000000
00000000000000000000000000000000000000009512091D04FC04990E0C0A49
2F251F000F0A080000FCFD00FFFE000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000400000000000000
0000000000000000000000000080000002190E0E6A03FE018727251D0C231C18
0001FDFE00FFFDFD000000000000000000000000000000000000000000000000
00990E0DFF000000000000000000000000000000000000000000000000000000
0000000000000000000000000001FF00C0000000410000000001FFFFFF000000
00000101010000000000970C0C2C0102019B15121038302C24000B070700FFFD
FD0000FCFD00FFFDFD0000FCFD00FFFCFD0000FDFD00FFFCFD0000FCFD00FFFD
FD0000FCFD00FFFDFD0000FCFD00FFFCFD0000FDFD00FFFCFD0000FCFD00FFFD
FD0000FEFE000000000000000000BAFAFA0066F1F20100000000040000000000
000000AA000006F00E0C780404047B2B2722061E1C18000101000000FDFE0000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000400000000
00000000EF0E0DBD1917133C2F2A240007070600000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000002000000
0000000000000000070100010000010100000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000020000
00000000000006F2F33EE6E8EC86BDC3CCFCE3E5E90000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000200
00000000000000610000F867F3F37BFDFEFA33CED3DACCC6CBD300F6F7F80000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000001
FFFFFF0000000000010101000000000000000000800000021A0D0D7202040281
29231F0A211B170001FDFD00FFFDFD0000FCFD00FFFCFD0000FDFD00FFFCFD00
00FCFD00B5D8DD00000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000C666F1F23B00000000
01FFFFFF000000000001010100000000000000000000000000000000009B0F0F
21FEFFFF9B100D0A43302620000D08070000FCFD00FFFCFD0000FDFD00FFFCFD
0000FCFD00B5D8DD0067F2F30100000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000FFFFFF00000000
00020000000000000000000000000000000000000000000000000000000065F1
F1DF67F2F244F0F2F560C1CED6F0D8E1E600FEFEFF0000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000020000000000000000000000000000000000000000000000000000000000
0000000000000067F3F3A1FBFCFD29DBE3E8ADC1D3D900EDF3F5000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000200000000000000000000000000000000000000000000000000000000
0000000000000000000000006BF5F5E867F3F354F3F7F950C8DBDFE5D3E3E800
FCFEFE0000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000002000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000068F3F3B1F803052AE1ECEF
99C1DBE0FEE9F4F5000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000001FFFFFF0000000000010101000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000099100C4100FE0193010000F066F2F33C0000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000FFFF
FF000000000001FFFFFF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000002000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000020000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000200000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000002000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000020000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000010000FFFFB9691E4039A1CEC10000000049454E
44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000300000003008060000005702F9
87000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000024
40494441547801003024CFDB01FFFFFF00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000002000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000020000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000200000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000002000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000020000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000200000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000002000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000020000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000FFFFFF00FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000980D0D4F980F0F450000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF0004000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000980E0E25010000970E080643F2F8F8F600
00000B0000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000040000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000009F000008FA0D0D7D04030174271613061F100E00B6D7DD0A
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000400000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000009A0E0E49FA00FF951A100E21291915000803020000FDFE00000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000004000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000009709
091B02040491090705532D1E1900150B0A00FFFEFE0000FEFE00000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000040000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000080000004190E0E6C03
0201832319150C241815000200FF0000FDFE0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000400000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000009B0E0E38FEFFFF9915100D2E
2D221C000B050500FFFEFE0000FEFF0000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000004000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000009C0E0E12FCFFFF88050604632C241E021A1210
0000FEFE0000FDFE000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000040000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000990D0D5FFE01FF8C231D191428201B0004020100FFFD
FE00000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000400
0000000000000000000000000000000000000000000000000000000000000000
000000970C0C2C01020196110F0D3D2F2A23000E0B090000FDFE0000FEFE0000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000990E0DFF000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000001FF00C00000004100000000000000000000000001
FFFFFF00000000000101010000000000000000000000000000000000991A1A0A
00F5F37F050404722A2620041F1C190001FFFE00FFFEFE0000FDFE0000FEFE00
FFFDFE0000FEFE0000FDFE00FFFEFE0000FEFE0000FDFE00FFFEFE0000FEFE00
00FDFE00FFFEFE0000FDFE0000FEFE00FFFDFE0000FEFE0000FDFE00FFFEFE00
00FEFE0000FDFE00FFFEFE0000FEFE0000FDFE00FFFEFE0000FDFE0000FFFF00
000000000000000000000000BAFAFA0066F1F201000000000000000000000000
04000000000000000000000000000000000000000000000000980D0D4F00F4F4
931D1A161D2C282200060605000000000000FF00000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0004000000000000000000000000000000009C10101FFDFEFD930D0C0A4D2D29
2300151310000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000004000000000000000080000004190F0D740000FF7D2A26200A23201C0002
0201000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000040000000000000000190E0DBF1714123C2E2A23000A09080000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000002000000000000000000000007020201000101010000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000002000000000000000006F2F33EE8E9EC7FBEC4CEF8DDE0E500FFFF
FF00000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000020000000000000000610000F866F2F482FCFDFE2CD5D8DDBBC0
C6CF00EEF0F20000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000020000000000000000000000000000000067F1F1DD66F2F446
F1F4F458C4CAD1E5CFD3DA00FAFBFC0000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000020000000000000000000000000000000000000000000000
0068F1F4A9F802052AE2E5E892BDC3CCFEE3E5E900FFFF000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000001FFFFFF00000000000101010000000000000000000000
00000000000000000000000000009A100B3000FE029912110F362E2922000D0A
080000FDFE0000FEFE00FFFDFE0000FEFE0000FDFE00FFFEFE0000FEFE0000FD
FE00FFFEFE0000FEFE0000FDFE00B5D7DD000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000C666F1F23B0000
0000000000000000000001FFFFFF000000000001010100000000000000000000
0000000000000000000000000000000000000080000002190F0C650100028823
1E1910271F1B0003010000FFFDFE0000FEFE0000FDFE00FFFEFE0000FEFE0000
FDFE00FFFEFE0000FEFE0000FDFE00B5D7DD0067F2F301000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000FFFFFF0000
0000000000000000000000020000000000000000000000000000000000000000
0000000000000000000000000000000000000000800000FE67F1F499FFFEFF25
DCE1E6A3BEC9D100E7ECEF000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000200000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000067F3F3
EC67F2F35EF6FAF844CBD5DCD6CAD6DC00F7F9FA000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000002000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000068F1F5BD11F2F331E9EFF179BFD0D7F8DCE6EA00FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000020000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000560000FA67F1F388FFFE002AD7E3E7B5C2D5DC00ED
F3F5000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000200000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000065F1F1DF67F2F34CF4F6F852
C7DAE1E3D0E2E600FAFCFD000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000002000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000066F3F3
AF000C0C28E4EFF18AC0D9DEFCE2EEF100FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000001FFFFFF0000000000010101000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000009B110B2EFDFD02941109073DF0F7F9F867F2F3090000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFFFF000000000000000000000000000400000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000065EFF5D2800000400101FF53000002F60000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000001FFFFFF000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000020000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000200000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000002000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000020000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000200000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000002000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000020000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000200000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000010000FF
FFB55EB9563C24396C0000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000040000000400806000000AA6971
DE000000097048597300000EC300000EC301C76FA86400000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000006
15494441547801EC5A5F4C5B5518FFEEED1F4AD77B5B4AC74AF9370603061DD3
9898A9D10767A22F9AE892259A2C710F42DD4C4CF6E2D332125D628C2E198932
36E3E293893E98E89331DB74E874232CCC6D6CCAD890316080D0DEDB527A0BF7
FA9D5B0E94B291B2F6B617DA9B36E7DC7BCEF9CEF7FB9DEF7CF7FB4ECB288A02
B97CB1B90C9E60CF1390B7801C6720BF0572DC00F24E30BF05F25B20C719C8F9
2D602406C0304CD6ECE034CFEF9641F90CB5B8DA2A0807B5562431F7C99A057C
C9F3CE4E3BF795D964F8DDEB763D0BA0ECD51AFCC3E4AB16F0B006AD9EB561FE
51CA71FB71D53FDDEA74B8EA4B8A419E9B87EB63935A4DB9AADC8C12D061B379
1996F9C2612D7CBEB96C0B70163380AC8004F3AB2AA965634608E8F478AC1012
8F9A58C3E186B21263A5D3010C025714594B6C49C9D69C80531CF7BA120C9E28
7715553496BBC1CCA2C345F07AB93423E0B4DD5E2D2BF2099BD5F2AAB7AA0C8A
6D56F473085CCEFEAAC7939F7602BE05304FDBB9C30C0B4777947B2C35A59B81
41DC8ACE805312D24AC049FBA63DD30ADBEE763A1ABDDB2AA0D06C8AADB88ECF
1DD3424027C7B98081E38566F3FE9DB555E02E76C4565CC7C0D362016DF84EF7
F0361F8692C76AAB3C8EBA4A0F184854B90E80A74CC029C7A62740663B9D45FC
D3CD0DDB80B316C6CC5D471E9E825CAD5CF31668773AF98239E94393D1FC9EB7
BE9AAD282D211E0E3F29BFDA5C9D3C37B69AB2A9B6A161FE80325AE2E5302439
4836193AC9F36F1A18E57845B9DBDD54570D2613F24780530288A757EF31C821
75B215169E25DE937E6A20444AEC23497380B5C5FE3199A82A95438226225BFD
52D944466C7EFA5CBD277DC8F3B84BC2FAC56874BC25206C897B0C49590002DF
8E3BBBC3CE5BF7EC6ADA0E45762E5E46CA75928B16180D3130C487A8EF4D0614
5292461510622204A95F52903AB13C2C4827D20FC7AAB0493DF14A208436AF4A
C019008BC471474C260C616BAB2CD595A5495B0B9D40EFE5230938C5F32F4BA0
7CEE71BB6A7636D48085242E1BF05A4140476161196B349EB05A0BF63637D642
89AB6803C25E82B448401B80B194E70F1A587CA76F2BB7D56124C7B2593B2F59
D250E39A4A008267DD3CD7B5B9D8B17B57530D6C22EFF41CB9D4256EC4D547C7
59C973562828D8987BFD51EBA912B00FF05046815D0383F7BF3ED7D503230FB2
733CF52825B57CBEB8C95B4571B25510DF8E84232F74F7DEBCFE67CF759809CF
6A39B72E642F1240B5794714BB4603E2930FC6A73F406B98F9E7CE3D0CC6D4F0
8276D950E50A0208BA368039B4884F22ACD4D0D73FF8FDB9DF7A60E23F3F69DA
70D74309A0280F4D85EFF902E21BC150F8B58BDDD7FEEDB97A0B225294366F88
72550228429F28FE6816C486E191898FCF5EE896EE0E8D24E61AB4EBBA2BD794
0D1274276DB6468665DB1D78FC4522C522CE8689C9423ABC90F9117612B3BFC4
7B92E0D06C508A46E102FA1A9AE72CB1B8E07B96174BCD6440B2EE0975921438
DF22082FC609C0BC0B1B924D87E30762AEB01F471FDF5A51EADA51530146D680
C9D942CABA5602705BFDDC3F38C9CECBDEF839D25DBF1F0A4D1C4DF831E2B109
20CA9D71381C11593E66311B7D4DDBB7B2E525CE85D4758D161023601C5FC3CB
72F5741340E4A9E705718293F20171FD97550FF8FD7E9F201C0A4B73CF5CB971
BBF762EF4D08CEACAFD8212502281BEF0AC2E55141786A725A7CFFD79E6BC2CD
C161DC0DEA4905EDA2DB322D0410746D68FCF8FB7E7B243A5F7F7B68E49BF357
FA607C5AD02D70AA58DA08A0020F8542632D42F0AD5024FCD2A5BEDBFDDD7FDF
85B08E6387B4134089F00542673176681E9DF21F39FFD7ADD981D189150E88F6
CD66A9190104D40180599F10FC685E066FDFF0E84F5D7D0330159CC926DE1573
6B4A009DAD35101840225E1166C3FBFEE81FBCDF8B9164743E7B7F8AA07A9132
2304D0095B03C1EFA2664BC3F094BFFD975B77E6EEA1934C3690A332D25DA614
08A5A20CF9694D96D90EA7D5B2BBCEE5844B4323EB2F104A8580167FA8774C10
9FF387675B2E0F8D4CA129DC4845DE638F4D0C0D1F5B500A03C99F2ADA32B41D
09DEF8AFBA0552D07DDD0FCDA813D4235B7902F4B82A99D4296F0199645B8F73
E52D408FAB92499DF2169049B6F53857CE5BC0FF030090D2B22D14C0033C0000
000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000080000000800806000000C33E61
CB000000097048597300001D8700001D87018FE5F16500000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC54600000C
B7494441547801EC5D6B4C1CD7153EB32C18C33E00830DD8801DF08B00495B35
6A15456A955495FA50D426ADD4AAE9DB81A4497EA495AA2A8A8214258AA22855
1EAE4DF2C3ED8FAA7F5AF557D53FB1EBDA29B1E3E0778C5F18C718DBC104CC2C
CF0566FA9D59EEB22CAF9861CDCEDE736573E7BE66EEF9CE3767EEDC7BEEAC61
DB3649D017019FBEA28BE48C801040731E080184009A23A0B9F8620184009A23
A0B9F8620184009A23A0B9F8620184009A23A0B9F8620184009A23A0B9F86201
84009A23A0B9F8620184009A23A0B9F8620184009A23A0B9F8620184009A23A0
B9F8620184009A23A0B9F862013427803F517EC33012935A1DBF130A3D6691FD
A4615337046F6A8C447A330180C5F67DCC204026087CBB32EC0A04EA7C86F1A6
4DF6D71DFAF39FD85E99476FF75C5EACAF2D015ACACBF32812799E0C7A168ACB
C9C9CAA2CAC2105DECEDE7DD125BBDA8CCA5F4594B02EC0E06BF4B8391B7A0FC
2ABEE12B0AC3B46DED1A1A1D1F8F116029487AB48D5604D859B4BA227BC2FF16
2CFCC3ACAF50EE2AAA2F5F4B0588398C8E3B91567FB420403391BF2C187C9626
EC17A0FC3C7F166CFCBA62AA2A2A208337C76ABC4136E309F06E30F880E5A33F
61605747B0F9EB0B42B4BDBC84566541748D15AFCC5CC612A025182C86BE5FB3
887EC6A3FAFC553954B7A1944A0279D03BDFF50A02BDE38C2300CCBDAF3C1CFC
1574FC2A545BE0F319B4795D09559714111FCB5D3F93F0194580770AF2EFB52C
DF2E28FF2B2C66492840F515659497932D8A9FA9F7782A2308B0B3A424E01F1B
79C9B68C27718FFB73A1F0BB2B4AA9AC201C53BC3CEBE30A4F3EF03C015AC281
1F5074F48F18E0ADE7A9EC8D789FDFBA611DF9795A5B9EF3C9FA9E95F62C015A
C2E16ADB9EDC49B6F14D96AA1083BB864D1B28B83A57EEFA596A9E3FC37304D8
43943B160AFC8E6CEB39838CDC6C7F16D55696530506793CABB7D8E2C7FC50E8
59E22902EC0E87BF11B5AD9D50F4665657C5DA22AAAD5A4F3C8F2FA3FBA511D8
1304D8999F5F9A9D65BC6EDBD68F58CC60DE6A6AA8AEA0A2607EEC392F83BCA5
691FADD29A00CD78A72F0B859E82965FC4782E94E5F3D196AA72AAC6FC3D9B7B
B9EB190477216D09B02B14BA0FEE4A2DD0F2BD2C62E99A02AAAFAEA45CCCE839
8A97BBDE9DE6A75AA71D01F61414148C59D64B06D94DE8A36F35AFD8D5545169
51D851BCBCD92D8BDEE327492B02B05B56D49A7C1DE6BD98A76DAB318BB70523
7C36FD62EEE33A5BD683B420C0EE40A0D6F0F9D82DEB4196AE189E39F55B363A
83BD98B95F5699E5640908AC2801F89D3E1A0CBE80111DDCB2EC9C9CEC6CAADB
52451B4A8B91442FE5399FA0AAD41CAE1801D82D2B6AD05B10AB8A676DABD697
526D4D25F9F99D5EE67053A3ED39CE7AC709C06E595993FE37E07EFD3DEE4F18
EFF2F7D4D6502156EEF88E9799BC39B494C2AC3B4680E604B72CC893E7C714EE
F6CD1B6913067A18F1A7D74D6F530D1C4A4EA410F7D49FDA30DA2DCB7A0617EA
59E862778400B3DCB2CA4AA87EDB5DB42AFE4EBF501757A42C17AC6C58912B2F
DB45ED069FCFC7232967F674BED3A69400B3DCB230857BCFDDD554B2A670BEFE
AC687E3EFC081EC08A627C00EA0C421943043528E53CFE37A32C96E70C5A553D
54E2C3E9BCA9E35863277F5679BCCC6918ABE35452E751092E9F3F0CA36F2726
26B0426ED7CD5F2B56921202344FBB65BD82CB148189B41573F73500978FD335
608710851CAB34A560A564C6DD513C0E9C38B17C7699AAEBA82BDE2EB95E3241
D4B939668462E9A5F82F624CFDB9C3B213E0DDC2FC86C9495F0BE476DCB2D616
1752030679F97958A7979076082C1B01945B963539E596959B83E77C3595F33B
BD84B445605908F04E38F0881D1D7D43B9656DAA2CA3ED98C98BBDD3A7ADECD2
3120E08A00CA2DCB566E590541BCD36FA67008EBF4123C81C09208B087A770C3
D86A655BCF3B6E59D97EBA7BCB26AAC4C60B9ED593E01D046E9B00BBC3F90F46
6DDF2E0C52636E59EBD751DDD64DD85F0DDF7B099E43E0731360DA2DCB702616
42817C6AC03BFD1A6CAD96E05D0416254073B25B16EFAC858346CDC6F530F762
EFBDABFA58CF1724C02CB72C6CBA68A8AD26F6D291901908CC498064B7ACBCD5
70CBDA5E43A570C396905908CC22404B28F46DB865FD19C63DE696B57103A671
2B290BA65F42E6213083007CE743F97F8798B9C5F87A467DED5DC4833D09998B
C08CDB3A6A1821563E0FEECA4BD750305F949FB9AA8F493683008DFDFD57B00E
BE8757A04E9EE9A083878ED3AD81C14CC7406BF966108091681C88FC12EE5ADF
C7BC7E57FF40840E1C3AE690616262526BA03255F8590460411F8F44FE4981C0
36588357610C263AAF5CA3F70E1CA1ABD76F662A0EDACA352701188DC66BD786
610D7E6F59F617E09A70702C3A4E6D27CE52EB915334343CA22D609926F8BC04
50823E313878FA8619F91AE6FE7F8EBCDE9B9FDDA27DEFB751FBF9CB04A74355
4D628F22B0280158AE66220B5FCFFE4B16195B799008AB609DBFD4457B0FB6D1
A737FB3D2ABA749B11F85C045050FDDA34FB7890E823E37E588493C323A374A8
ED341D39D64E23A363AA9AC41E42E0B608A0E4DA619A87AE47225FC200F1B7C8
1BBCF6692FED8335E8B8DC0D7F488C1824780681251180A56B269A688A445EB7
C627B6C11AFC636272924E9FBD44FB5B8F51DF2DD33300E8DED125134001F7C4
C84837C6078FC233E85BC8EB302343F4FEE11374ECD4798A8EC3375D425A23E0
9A004ABAC74DF3DF3966A40ED6E0653C05A257BA3FA5BD983BE8422C4F058552
FAC5CB460016ED17F8E43EACC1733619D89162EC650B701496E07F1F9E24B60C
12D20F8165258012AFC9342F349AE64320C28F9177E3B3FE01676C70E65C274D
4ECADC81C2291D62FC5EC2F4A83D152E5E6F161585564D445F8445780A02C7BE
F9B3BD9ACAD6AD89C9CFD777FE238938D61FCE8BA513CB9C726E156F9354CF29
52E74B2AE3361CD4353899781E2487C6A274F4EA0DAEE55CDE398827A6DAC733
E7AC345D3AA37A4222E170BA321FA160CEB2F9F267B64E4CF1AA0DEF0F44687D
7CC0BC3FB12CF938E5045017C41E822F1AB6B50BDDBA8FF3D6E1CB9EEC5E96C7
EE658E2290A994A3C0882B2856E69473E378FE14382AED14719EFA9F5477AAAD
43325499AEC709A208E6320E60822B33823D6C18F6C33B6E0DBEB7903C778C00
DC8966DE341A0A34E1D1F01292F896FFD4A6517CED9337663A0A66E5AD3C012E
FAB2AC47D011CF066B75F822AFE7245AF8B984B9A304501DC06FF5ADC557C05E
43FA31CE0BE4E3CB9FF85E40095CCC57F21110B700069DC68C67BDEAAF97E3C5
08909241E062806181A9A7D18CFCD436AC8750F7DCE0D008B5B67D4C6DA72F10
AF3A4AB87308AC080194784D03437B0BCD48031698FE80BCD1AB376ED2BE0F8E
53270662CE93405594386508AC280158AA1F1245616E5FF119BE5A24FF358E2F
5B9C3A7799DEC722D32D993B4899E2D589579C00AA233B06063AF158F84EDC1D
CD1CA48320C1A90B9F10AF3348480D0269430025DE2C77349E523E7C92BA7BFA
541589971181B42300CB36CB1D0DBFE9DB76B6835A31AD3C041F0409CB87405A
12408997EC8ED68B65E6FD785B38FB49B7B8A329905CC6694D0096AD39D91D0D
3F1B72A1EB06FDE7D819EAE9375D8A2FCDD39E004A45CA1D0D83C40730517872
78344A87DB3BE8A3F39D342273070AA6DB8E3D430025190689AD89EE68D7E1A5
BCFF443B5DC29E85C566BDD439249E46C07304E0AE374FB9A34DF8276A610DE0
8E66D1C7D8BC72E0F479EA1F1C9E964E8E1645C093045052FDA66FA42BC11DAD
D31C1EA5D63317E944E7551A97AD6C0AA605634F13404936E58EC6D6E065AC25
46BB7AFB691FACC1553C1E620BBDAAA6C4C90864040158A8647734B600C72F5F
A50F30483465EE2059EFF174C610404994E48ED6D38731C141B8A2B55FEBA149
D9CAA6608AC7194700251988F0B7317F36BE6568BF8DB703ABA3E733DADF7E89
6E60CBBB8469043296002CE2337D7D66A339F83419BE2FC3DFE8C3114C297F84
DD4B47F0681896B9038705194D00C5F3C68181A3D7CCC857E198FA34F26EF598
43F45F8C0D2EDEEC234B73C7032D08C04468E62965D37C1B3B9BB7C2F7F8AFAC
F873D8D378A0E30AF5C22349D7A00D019482D91DADC91CFC8972476357F0C358
5C3A8E65E7A8867307DA11401121C11DED39E48D766370F861D775A718C6419B
2F63694B00D6F4943BDACBCA1D6D6A3C3088EF1F343B4CD0E10F2FA0A8FF3AC8
BB908CFCA396FCD3370BD5F15A99D2ED7CF18C7D015E134EFAEB1E01AD1F01EE
E1F3FE198400DED7A12B098400AEE0F37E632180F775E84A0221802BF8BCDF58
08E07D1DBA924008E00A3EEF371602785F87AE241002B882CFFB8D8500DED7A1
2B098400AEE0F37E632180F775E84A0221802BF8BCDF5808E07D1DBA924008E0
0A3EEF371602785F87AE241002B882CFFB8D8500DED7A12B098400AEE0F37E63
2180F775E84A0221802BF8BCDF5808E07D1DBA92E0FF030037DA73E0770A7458
0000000049454E44AE426082}
end>
end
item
Name = 'CodeCoverage'
SourceImages = <
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000100000001008060000001FF3FF
61000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000002
4E494441547801A4535F48535118FFDDBBBBDDADCCFD891264290BB22834A38C
8A20B197562C378B7A8855B8355A98469304970DA90D07EBC551C430DF16814C
27631846A5F4121844CD302330AC87164405B270BB77A773AF3A119A0F790E1F
DF81EFFB7EDFEFF79D73184208D6B2384F646C4D089CD43DE83CF25F243AFAC6
C1814A10F30457EFC611F65811FADAB92A58BB3150C8956A99B67B4F89DFD9B0
6A51B1A0B7EF39385110208A04EDBDC308B536229CF6AEC857B31A94A9CAA1E3
F420F30487371CC7E36729D8CD75906A3951142050093D2D2765EFDE74A700C0
308052C1E0FD640AFE4010EF52291AEB464D75356AB774A0749D72910105F0DE
4FC07FC582C88FAE024085DA04FE8B16BE4B219C69BE0EF7ADB01C7B353E0A87
D30547DB4D70794A43C853DCCB16D937EB6F1700344A16EE5E179AEC2D68B259
51B9919763E5062B845C16A3F128584982740BBE0709D9F7FFECC292BDCC0C62
E2F504F61EAC074BF57CFB9D934D3AEF3BD4804FD31F240922043AC44EC709D9
9F2BE92E3028E11550A982D0F27910BAB3346F6969D579709C62818134C4C0C3
A43CC4E89C0F92C5323D78931B81694705C64662282B55AEB017C90154EDDCBD
3C44CF05B32CE1B4DA0705CB603DCF627AF22D484E83F8D0107D71024ED91A65
0283F104928924EACCE7C19CBD1159E6B5C8AFA6CA48EFFD0F9E2413387ACC82
E158147AAD019F673ECA19A66DBBA0ABACC55C960153EC37EE39509FBEE86ADD
3CF0A83F3D3335B59F5172B30CBBD0811006F362067C9E2F0E60DCBADDAED519
AEFD4A7FB7D1B2590A807F01FC1D00A4D901A1332A515D0000000049454E44AE
426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D
F8000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000003
4A494441547801B4546B48145114FE66774D5D75CDDA2DD255C230B5DD54045F
24650F482B7F45B23D9444329122C91FD2534BA9ECA1913F6AD32C8B4A222ACC
3422A217A261948B94A5448521ABA8158452ED4CF7DC7537C75A54D00377E6DC
39F77CDF79CD152449C2748A623AC1097BDA0954C4927FFEF1B4D4E9547692C0
092451C4A9ED2B886BCA24DFFC886371029111D858B38BCDF510D9BB302715A5
9FF74C8AAC20E8A8CC9F30499C19D05E1425D0548DD8264530D69FAAE2247064
B0377B1DFF48D9EC0E38322902F219ED2FCB40146DB0B1E8A75208934456A2E3
D5F778890AB2D6A1C2BA6F5C3E1FA506F3DCF5F054A8B164460A1E36BF61BD14
909A140D2A913E38CC4EE0281135987A40E98E27B3DCB458A85E84D6BA76DCAE
69445F4F0977D16A75F8D99F8D10BD3FDF3BA7887A92BF752DFF487A8ED6EEF0
3F228500B8AB14D87F603F5A2D1DC8C82D46B83102145647BB05555565080A0A
FC4B20D9580F2610B5834CA91450DF700FCD2FDB5174FA220C7A0DFCBC94DC1C
3237160B422B71282F93F669B20CCE5C69E425DA95B10617060F38F0FE792FF6
8E86F9E2256CC8CC43A0D60B0A76E17C1B1A692A4B2F70B69AD976A0ECE0CE7C
27016530D11E0810F0A9B31B61C6284EFE7D04DC198920D86D9260E404D4711B
AB7BEEE6147E86F474CD61E7F9B18A97BB026E6EA5F0769330FC4B04F5846172
A14AD3C47BA95846027EF3DB946696FEE2C9ACC8C808BC6F6B869F5A095F4F25
341EF6453A7DEBB4BC20C2665989CCD7EEB34804646F5C8DDA1F453CA2B10F9A
7D83320A9A005F9CAD28C7B2C438E8743AD931ABD5CA6C65B0FD964A78065422
1A4DFB3D64D7651E231B020F551BF0AAF12D628D4B919CB206A6B434D4DDBA81
C1DE2F7C91BEC96442647C12793D936590654AE650D4F0F51E855C773C54ACD0
3EAC0C0F1AEFA2E57E17E213F5B07E1D82694B069E3C6FC1B9CA6A7E342C7C11
8A4F94E372C36BBE17286A534125FD232EC54FA3468C613EBABB2CB0B4B52126
61191AEED4C218B70AFD3F3D5CFA3DBD7E52E0042E4F8C32E88343D3E3972CAF
8949582AD4DDBC3AFCF1C3BB95CCDC347B8E1E037D3DB229B2B18952B1C06D4C
E13D1885E352F5D70795C7C4CBC15D1E1E6598700601C121A97E3375C706077A
B731FF2607C67819FC19004D34B3A6918184DC0000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7A
F4000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000004
AE494441547801EC566D4C5B55187E6E5B68693B26A8B3C8C706F2D1C28004D1
6CD16568A202630BCE3F03B31F8B8E2C66CE849121D36C9AB9A944DD62587463
4C4D580415B30142C081449165CB4412A36EC900096E42429422746D29F77ADE
D3DD5368BA940F277F3C497BCE3DE73DEFF39CE7BCEF7BAFA4280A96B3699613
9CB0FF27A053AF60EFC9AEFF3418DE2DC991085B10A0877776E65077C75B5975
97C09843405E868CF023001C3AD90C45567060D766540E5708A64B19EC8B7D73
8EDFD9BEE664015780A940FDBFA906F9A24305F22B149065991900153B0B3841
1A97461F994D76D163F2B5BFC4E797B0D426082844C037AFAEDF919EB0D42608
C8F20C97E8ED9AAF40E5F9E5E70BF0FEC82BAADD92FA3D96C398ED97B0D42662
802B70AB12307C7E1DAAD1527AADA46307023F94EAF7360A500C28D8BB239FE3
D1F885556F2C0A5BC34A8C96FD49AC67FF18B7DBBD31C088CCD0E1D815646767
73DFE20A8815315C6A23E010AD84EFBA7BD070B60983C3A390341A9605321256
47616B61016C7177E3E22D204140CD82A31FB770B94A776CC289B15717C4E7DE
D0FB90A8B5A1FE580746AFBB919C96854DEBF2600833C279D3811BC343F8E0F4
6788BCCB4C7E8DECE71004780CB07C211178BE52EE2CA019B526C41B92F0C5B1
2E4C4D18F154E13378382B1DF74784C218AA81C32DE3C65F0FE1526F0ABEEF68
85648EAA6148458280AAC09EED791C96F09F8B38346F0A7A9D84BEBE5E0CF7FF
8DDCC22DD8B83E13310C5C6D26BD06491603C2D8BC3C23C33E3EB66DE4FA6FA7
0501AEC052828045DCD9C616245A339191B91611461DA65CBE7C5789D03CAD5F
BB928991DF87760B02AA02C76B5B7930EE664A7C623FA0EE0BDA67981FC4D581
413C9EBF0E267D6070D509AD47C5C421CC687A541050151031B008355CCE6998
4C613C866E4ECF40C75391BFF6393615380FBB5B8A31B2D36A75118280AAC0AE
E25C6E4C31F0EC8AD755D2417BB35E8B70F3D77039A6A00FF1821298B716B042
C43CA81FC0B44E76D3D3EE3F04016F1604C5B9AD81875598B4D4640CF45F83FE
C90D30E87D01E8BFC9E97263B0BF1F2E97A34310F02AA0A0BAAE8D332D29CA45
BDE335FFBD019FA9DAC5CB89C8CA5F83EA23ADE8B9701985791B02DAD26467D7
655CFDE547459AC67B82803706BC7B482ABA82F934025F156A81458A45555503
32D39270AEB191CDCA783AF711988D06E166D2E144436B379A9A5B303E367A98
2DF449EABD1455D428075F2A16C6F31DE8751AE83533D857568A1511163C96B3
119F379CC3F8841DF10FD8909E66E395EFCFF149FCF4F3150C0DFC8A84642B3E
7CAB5CCB30E4390A2C34F00D213EF0F0C828245BD7E2CC995AC4C6AD4659D98B
38DFD68E0BDDE7619F98C4CA7033526D566C2FDE8FE375DFD0F97891100A6C2B
AF9EA7E8EC0DC7423BCE12892C6B346A4F5521363E898377B637C3645E09E59E
D4A002D65796F054110482EEF0336024426312AC0D9BB71615A4D8D2D1D9D684
DE4B3D95CCAC7C4D4A06A61C93D031A21A9D0E21217A96722EC81E0F3C4C660D
9BFFE1DB16EE515C819FFFA08F0CFCD32D0C3C99C0DB7DE04137FA19882F22BF
F9A08F66A3697D54741C036F46EF45EFC9836E0A60B0680558943FF1D189A375
6EA7F34B16150703F89ED7D43F0300BFAD1616CF294A6D0000000049454E44AE
426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000300000003008060000005702F9
87000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000007
4B494441547801EC5809509465187EFEBD59965D58441141904318745446416B
32A9A631039B9AA6F24AB30CCC9C32AFD4BCF26CCCB2A9CC33D351478AA6C1C1
8BC98304154F120F400EB905012F966B97DDEDFBFE7F7FDC9F1559613775C66F
D8FDFFEF7E9EF77DDEF7FB58C66C36E3692EA2A7193CC5FE8CC0E3F6E0330F3C
F340172DF0D44B48626D80599B539F8A43E1BBB86886C72D20401BD7C645F37D
4FE473F6E654012E01017A2A3FE90773DB9BC303083CD92AEA9080C9827FF9E6
7D3093CAE2A9A35997AD299D2F709DB32B73FD56B35B2CDB980C46C460515C2C
5B7F2801984CAD12A2E01FA7A47829B3188C56D22618AD8BAD84C0B96061BC85
B1A53EDB7795F53CA7BF13C8EC1E8B2C0AE0EB0FF5C0E3B4B8BD16E990001F03
ABB79218204658F031E78975150BECDDC321E3BEF0E13CBE6ACB3E3024EBCF9F
62470C98CD563140C09B1E635AE5638062A06AE2EB14A375693706E64D8961C7
F1DAFBBCE74AEB794E7FE7F7E515C0D7ED9690D3117672830E09F0AEFA76DB7E
368DCEFD88D3DECF555F7572CBCE4D9BDE83F3F89A5F690C3098F3A145113C40
CBB2020911D1B3A0691F65CAC50011E0FF5CC40C8545B17071485F5A2DCF6719
0B260101EB209E3D9967CC8D9CE6B5C2A934C4E4B4155B2EF70C18DCB977176E
2A372C8C1B4DED0A236B5C6A5813A246106C8D1C9C360488D59D0AD37671821B
123183069D0E49C9FB713CFD34F2F30B21914A6130E811D0DB17C38646E2AD37
63A1D576BBEF09CB5236047889ADDB7E801D3CD3E2894D350B6D77EF628B46E2
8150653F5C3B5E81844D07E1AEED052F6F02F8A570C8150A18F47AE8EAEE20ED
CC6542EE20268E7F1761FE3EC8B4DAF7010438CDF3FA6FD59ED52447BCAAC46E
047C384E2566E3C8DEF3081F301CBD8342D02724149E5EDDA1908A6120B2A9B9
598DD2EB05282EB8863D7FEE437050A0607B1B027C8CCC98F43A3B90AF4FD12E
174CEC6A452E11E1447A3AFE4E3A8B4151D18818FA3CC24283D1A79B1C9EAE12
F6F4A57BDCF155A2C8DF1B79FE0190C915F8F7CC3FB4791EF97C435F6C08F012
A29DCE2A34608D44DF3F6ED882B0FE911838642806848720A487022292329B5B
3815D0FD15521142BD15904BFC48ED45343735E2C2A9C34B8D68D94E1A2ADB10
205709CB2DF0A79D07490C009F4D1C45C601DB6E2F669F8EF80A760943CD493D
18B102BDFC0311DCB72F7CB5320BF0FBE0ADF7F2D64851E7E783D2C010549416
CACB8BF26690FE79C25F255A5315CDBFF7EF428EF68A42E482F3E9D96CC0FA07
06C34329869E58BDC9607AE847EB2A46407008BA75F701C9B431E4632B215EF3
D3277096E7EB9334CBAC0DD2A577A54C841D9547E1E5E707774F4F92FF1934EA
3B4EE0F444D67868A154A9E9FE610D35F5B6041C6DEDF698EA7475E8299142A3
52406F3491A015B144DA1B4F0F3203F9CF4CAD94422693412C9650F9ABDAC400
8D004E83BFEC3EC49E039F5A3CB1F3DE92F6D67EE4F6FEAE117051CBD8838A69
D1939FC895301009B51049D0838DFCB15FD498140DFBB458562E32A3B9B91946
A3A18974E9DA1030B1DAA7F369FEA7737809D1364715BDB9197E813D505B750B
B5D555F0F5D6DAB1344B0BC525375077F716C1C664B978BAB62FA1A9E3B818B0
10C738D5D7766C62DF1019B93AA8A2CF63ED0F1B70F94A0E860D0E676F9CF6CC
BE987505D59565D44B89747C1B0F7056B767A1AE8CA15E8D1A321832729815E6
E7E1C4A90B18191DD5E192E72EE620272717D5374A6E37D4D66FA4131E4080AA
0ED89C90C2CA287EEC6B6C3DA16129FBECEA979B588D70D78148FDED12946E1E
C8CFCEC41125910249E831AF449140166676BA1F45743C230B4987D29073E92C
8C403C69D2D13E0101FABB109FCCB81870ECED9482A797B78B29B9B890568015
8BE6A0ACAC04DF7CBF1E8DF575B87AAD082F44F64370800FD42A25740D8D282C
A9444626B17C6E1E722F9FC3A0C8E790917E8C958F0D013E7069C794319CE5F9
1878C765296DEE749190F4A252889072601F36ADDC8D7193E271A3EA267AF4F4
81772F7FDCAD29456A6901AE5CBE04378D07A472397B1BADAFBB8BDA9B15904B
81593367203135578041E001DEEA82110EA850F0AE720A3E19CB97AFC4F80F3E
2120DD71342D03D9D9398819F52A46C5BE81AB973271EA64060A8B8A71EB762D
DCD51AF4F6EF8DD891EF11CB0F23B95F0AF3B11C01221B028E4E9BF49F1557B9
18290793B1A215BC061565C5D89FF43B9690B64151C3D14C841D141EC17E0408
AD2A141B35B27561AC1BC67CB945D86B3DB213EF1E6A2522FB05A02C3F0BBBB6
6FB5589E822F41F25F7BF0F2E831B86DD43CF2CAF9A7F7324DE41A418B80C023
AFD4C104DFC0503AE27D1717D71D13264F63DC8824CACB4BB0377197A1B149F7
36E94BA60382FA46202D25119123C8D96316717701869A9B74D29FE5C84B634D
315CB4FEB49B368227609BB368BFE34A87E0BBBA955309900BDAFAB113E31895
5A8D8A8A521BCB77153C9DEF540226B32921F5F00194971423E98F9D02D93802
3C5D4390851CB528BF4EC5F56B53193363BA9E9F37DAC4B44C25EDACE6F97E47
3C9D1AC48E00D8D11AFF0D0033DC6AD64AFFF1A10000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000040000000400806000000AA6971
DE000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC54600000A
ED494441547801EC590B5094D715FE964558DE2CEF97222A0FDF488C2388D19A
C457346AAD699A9A8E4D67EC749AC6A456EB23D3D11A9B994C4DD2348F9A495B
1B6D6A9A3AD198D862524D132A2A54115159DEC85B5E02020BCBEEF69CBBFCEB
B2FBAF6C90851DF4CEDCFF711FE79EEFBBE7DC7BFEFB2B8C4623EEE5E4762F83
67ECF709B86F01F73803F75DE01E3780FB8BA0BBB5056C7EF7CB511D18ECDBB8
506189D98600AEA446966D46CD334DAE0D16590246B5095851204FC03DC4801D
02EE1D06E409B03293D1FC2A4F808501E46A2A71E068260C54F6CC9A7424278E
157CBC52B9DDA578D93AF665A18FA42FBF6C587D5B5F7BCA0E1809FE99C037B5
76A0A5AD037FFAF86B7B725CA69C75647D393BA2EF8016608DCC558F0FECE965
AF5CC26563017C406299373C3E0F41013E08F4F3C60F57A59BEB2401AE729774
661D595FB57F7F7DA57A6B7D6D2D8009B06835837CFED52D4F9A4BA4BACDD1BF
3197B9C283A4973D7D858E32E66043808929578034F43A3036EB244F8075AB51
F2EE3801B6448D0A0A1C228056395A036E339057588943C7CF88C5EF695A1067
2498E280DFD5EE7429523645EE15FA48FAF2CBFA9569667D45A58C0BD8D905C0
3C887CF093336816714027DE3FF65F73B910E84217495FD691F5E56CA9AFA9FE
F6C44AAACBAF01B6EDA4F68200F38B0B3DC84CAED0CEB25CCE05E42D80BA3207
9CBFBF220D6ADA5703280E58BF729EB95C4877A18BA42FEBC8FA06521C60A9AF
A8B764A34F7785352BCFBE7EC2F8D2C6C52E046D6055BAB55AD1C853A5BA63E3
17DF3D898CC36F9A4F848ACE9E80BC0BDC51CCC8561A0C06E45FB98AACACF3B8
7031170D8D0DD06A754229956A0C42434291322B19A9A973306DEA14B8B9DD36
72EBC9E64EF204B0BDB860CACC3C83F70F7D80A69676048745411D1E87F0F1D3
A0549A60E8F5BDD076752027AF08195FFC07C16A3FFC60FD53484F4F13681C23
80BC5CC65546948E5BB76E61DF6B6F20EF4A01C64D48424C7C84AC3E4C848F6F
80C831E3E3D1DC5887577FFF077C71EA4B6C7EE1394666D3CFC602F8C3DFB259
7E51253E3C9145A418F1E4636998166F8A03F637BE6823CC19055DCD3A64ED2B
8797211C33673F040599B49B5289C8E8B188888E41805A0D4F959718BA5BDB85
D69616D45557A1B6BA12412111500785A14493875F6CDD01FFF8F9362ADA10C0
402D4DE53081BF4967019CFEF6D919BCB4E9091B21CE2AD075E80578B5671C62
C6278861A2C6C62271DA0C78797BC3CBC30D413EEE508D31F9B956E789E6005F
8447452361EA7468F2F35053598149939351555E88A2F32758863FE536218C2E
F20448B532774BEB90A91ED2A2DC033550E9C30478854241C06762424222FCBD
949818AA42A0B75276BC9B9D7A943428E135672E028382702D2F57C8E8EAEC80
B6BDE53DA3516F9EC5DB4B649F2876005E03A4FCC4B254DA537DE0EFEB85EF2E
4F3397CB8E3C84857517DBD19CDF8B49493385549E75061FA3F6C0F4686F787B
BAA1476F94CD5CC76DB8EDF84909823816C2B2545E3EEBE871B9104A171B0B60
840C5E4A5326C660D7B3DCC794A4BA1FA9F748454EB9FFECE8F3889D3859F83C
9BF484842484FB8F4154A0077404DC91646E4BC4B53435A0BEA65AC8D4E4E7EC
85CE28FCC1D6029800923E92B9B4B40CF5371A11141A0936FDC93392859F4704
8C919D717B96C0E591011EA22FCB60592C93AC20992072B6B500EB45901B0D77
3A979D4D8A46088543C223E0EDE38B50BF317D33EFD8EC5BEACC7DB53A5FB0AC
86BA5A21BBBAAB84DD20D7252D202FF712D4C1E1024354CC388AE614F0745708
02D8FCBF69E6BE2C83657162D9F40DB0849F65D700CB40E05A4915FE917196D6
0523D62D4DC5645A13381D68FD95B83BE35276A30893131608D17E0101F0549A
C0DFCD582C836571527979D3552180C85880A19FFF7FF42F531CD0DADE89BFFF
930222EAFACD8D9087753C75B7EA31C6C3F461E3EFEB030F7737F3EEC38BF060
32CB60599CFA648B70D2C6024C6B807D6579706727056DEF46A381867183BB9B
D898D1DE4DA4D02CBA93292BE96EFEA4BB8332BD14D5F6F6B90C4B61599C4CB2
D1CBCF3216C0DBE0EDFCEDC5144CF899E280B54BE69AEBB8B3B3928A57FB6EAD
106FE8ED21FF672214343684FF6B7B0CE8D6510CD06B5A0F18A40494CBB84E4B
5947CFDC87FBB20C96C5A94F761D3FDB5800F7B09CE424F2F9ED3F31F93D7790
EAD6FBEDE657A7A4B2F0DDE2ABCECBDB174D0D3710151EECF838FD4CA3DF0B7D
1C350839DAAE4E5A02709D5FEC58C0E0FC8CD91E8A9CF2C003686EA815CA5654
54C29362FDA1C8E5E50233C9AE61453FB54F00D5F04C8F544E99FD2029590F3E
FCA8A9AD475363A3D806793B1B6C6E26192C8B65B26C1814C7ED13C06E308239
2C2C0C0989F114BA56B08E38FDD539F0071FFBF16032F73D453238B14C5D8FF6
143D96F2FB806B80A6B41AC73E3F2708594D0B62E28468EE87C31DBBC4DD5917
F5AA4E685EA9A2E82D1AB5F58D38793A0BAB97A60F6AB863195942864ED783CA
328DD160D46F91B69101D780A39F9F456B7B07DA6E75E2E3937C3062F2F34169
E260276DAB0EC507BBE964C70F9ACBD93092D9FE2F4F834F3232694577DC12B8
EDF19399C8B9A411320AF373D0DBD3B38FD4B820A93220015243E9EE6C02749D
3A9CDE7D0D2A8F00FC7AE7664C181785E2825C01209B80BC79E028CAAED75070
A4B863E636DCF67CAE093CCBD01995E86C2ADFA96DAE02674E362E207C5F424B
F7C71F9E8BE3FF3E27168F558FA49AB7418B2643F6C8E03FDD9A8586829B98BA
2219519191789A0E35DFDEFF1EF22F9E41D2F407515DD784770E7D26B6C6E949
E3312E321401F40F80531B45AB15350DB85C508E9AFA2651A6EBE9460159515C
5C2C6E798C4563F1395330206A693764C096E97BDBFF68DCB5E929CBA26179E6
D39A5F3EFF53145CBD8CD9A90BE01F1804BDAE1BABD7ACC5F99C5CE4649F4547
7B2BA263E3113936CE7C126C4F393E21AEAD2C436D5529963FB6026BD6AEC39E
B73EC4E5E3AF998383FCFC7C5B0B6027EF4F89BD2186AE9CC16FEB033F276D21
810F4627957551C0F2CEDB6FC14F1D8EC8C868ACDFB60D478F7C849CCC93E28B
2E30380C2A6FFA56E8FB6EE8E9D1A29BFAB434D6D301483D925352B0F1C77B31
2E36D6A4ACD56473A1BC0B0C23030C7EFB0BA6999F336F1102D54104BE937E76
685155514ADBD6757C6BF10A6CDDB11D4A77773CF7F32D686B6BC3A58B17909F
77098D14DDD5DF6C11000302D508A11F230B1E5A8D99B352E0EFEF2FCA25DCD6
D62E4B80E8314C174BF073E73F4C47DC3CF30CBE8BC09708F08F2E5B81CD3B76
F7FBC3C3C0E62F5828F2DDAA6AB30BDCAD4047FB5B824F9DFF089DDF878A59D7
7675A1B2BC98CEF62B2007DE51F98EB6B37101EEB8FBF5438EF61F543B3D0524
57BE3E828E963AA42D78948EAE43C18448E06BAB2A101A3B051D3E09D8F3C607
831AC3D14E36BB80A31D07D38E435C4ABE1E3E41194AA55BDABC854B68310B11
66DF45A65F56A241CDF5528E3AFF525D5EF80CB535588E332B7D09DCE9F7572F
05466E0A373A33A45A72703EECE4247C9C9ED9E70D749EE04E7F91F4063D94D4
36FBAB4E4C9DCAAD4C5F84FCC4BBC070BB8019FCFC454B111C1246B3AE15335F
515A7847F0ACB033D2B0124033FF579EF9F98B96D17FBB70B1D8F182575E5228
163DDA800FCACDBC33804B32879500FA0059149F340D216111027C176D7565C5
0504BE98620F025F56B88114EB67F692A2CEBA0F2F0146E311CDD53C14155C11
2B7E59D135B1E28F1478265576177016DB64DE1BA3E31283F22E9C5D194C3F3E
9A1AEA466CE6258CC36B01741E595DA6F90EADD2FB9B6ED4969012BF1D09B397
C0F37D58B741CB815DE5F9FF0300C594AF89CE9F9C0A0000000049454E44AE42
6082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000080000000800806000000C33E61
CB000000097048597300001D8700001D87018FE5F16500000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC54600001A
61494441547801EC3D097855D599FF4B5EF684EC212B2101C2BE47F193C50822
8A82621D69B5CCD86FB0D4C1F9D4B123B6B4AE3376A6533AB5B533AD552B1D1D
AB6D2D20A05147C226200142200B81EC3B09D9D79797BCF9FF73DFB9EFDEFBEE
7BF78635EFBDFBE73BEF9C7BD6FFFCFF7FFEB39F986C361B18E0BB14F0F3DDAA
1B35270A1802E0E37260088021003E4E011FAFBEA1010C01F0710AF878F50D0D
6008808F53C0C7AB6F680043007C9C023E5E7D43031802E0E314F0F1EA1B1AC0
10001FA7808F57DFD0003E2E0066ADFA3FF3469E7160408B4863387CDB77734C
EED03334803BEAF84098A606E0344049E24EC3F6000AA0E6D685A5A1017491C9
7B231902E0BDBCD55533DD5D80717654173D3D2E92A1013C8E65571761FD1AE0
EA966BE4364628A05B00008CE58031C2B3AB8A866E0130C6005795EE63263363
0C306658716310D1AF016E0C7E46A9D79802BA05C0DD10A0B1B5133EC83D0E67
2FD4C3C8880DE664A5C2FA553741525CA413FAFF5EFB03273FC3C341812D693F
717CD85DA3A1AF53620D0FDD02E06A08D884CC7FE1BF7642DF80452C2ABFA80A
CE9EAF87579EB81F125584408C68389C28A0A4B32BFA1661637B79F395D3F78A
C700D4F2A5CCE7351AB00CC1FB9F7ECD3F0DFB3229E08ABEFD83434CEB5E66B6
6232FD1A40299AF62CA8A5BB020A33660FAEA8A3EEAFA4973BFA1696D55D317D
AF5803A857C3F0F5140AE8160052006A66E6E41497759D3D25D5298DCBC84600
A38092C6A3A52F4FAF979CDA02403A89E9259EB5DC5E7FD74D101A1CE8541EF9
3DB42A1BFDE5F19D221A1E0A0AC8E945341C1D7DEDE945BE29B2577C6A8E0128
3B0265DF24F80224C48C83E7BFB716FEF4D97128AE6864DE333293E06FEEBC09
C6C746BA4CC7D31BB69C024A3A130D2F87BE9C6FF2DC9DBF3405400F0769AAF7
8F0FDFE19CBB8ACF3329AFAAF81A5EEE28301AFA8AF92825490C903B3405804B
12B7E5C98DAFB14A01BDFCD214003D1A60AC12C1A7F1BA5A1A4024A25E911213
180E4FA080A606E0EF081AFCF704763A70E47C73F8A8BBB4A781EAE90C5F2FA1
80A606E063009D5D8A9790C50BAAA193619A02E050FD0E971790C7EBABA0975B
9A0220ACE4F15F75BAD196E5479FE7E34250033B0F300B97871F5899ADBA15FC
5AE356F54C0C5F46812793FED5891252FA52E08CCC6497F47524D627029A0220
6A1217F9355FEA8457DFF858B6257CB2A41A8ACA1BD80A16AD6419300A0A28E8
EC8ABE25D8D87EB4692D5B6D55CB5DE49B5AA0C44FC7209030B239ADE80BBE00
7FC696AF761E6010CF03D0F2308FC76D49D9865385029C4EDC76455F3A0F4061
3C9ED2167436F9BA074D0DC04A70934731B67457E02ECC551AC35F4E017734A4
53412E419BF72CA9A600086DDFFD18C0251218A0130F7759F854D868E9E52A3E
E79B16F1B4BB002AC18D993129D965196C2F5B99D6656C2380514041AF51D357
915E8BAADA0260E7BE325FFEFDC04AD7E701D6DD91ED243B5A08F97A38A72BB7
8986AECE03A8D197A773B45AF714D514001A4DBA1B51D27980E736AE81F9D3D3
21040F810407053037F9193300F7C4D7134A3494D297684CB4D6A2AF16DF78D9
9A6300DE8BBB15024472D3432B789EA2AD96667382F33C574C6038541B5BC228
E8EB2021E9026DD014000713F565A85DA411434981BEFE3E18181884EEEE1E16
1411110EC1C141101A12AA8CAAFB9BF3EDA665ABA1DF3AE294EEEC579F323F4D
01103580531686C7E550A0B3AB0B0A0BCFC2D9B3455076BE1C1A1B9BA0BDA343
35ABE8A828484A4A846953B360C68C693067CE2C881C374E35AEB3A7BE06AB2D
00FAF2712EDFF011296019B440DEC143B03FEF209C3A5D08C3C3C3621839FCFD
CDE0E7EF0F018141CC7FC8320823188704834C7149297CB46317C6F387F9F3E7
C2ED394B61D9E2C51018E47C1857CC5827DF340580CF27B94A110B301C9A14E8
EFEF871DBBF6C0AE5DBBC5566E32F941544C024446C7414464348484868B8C57
664882D0DFD703DD9DEDD0D9DECA4C7EFE4920F3E6DBDB61EDBDF7C2FD6BEF81
90901065529C7DE993004D01D0998F1302BEEC31323202FBF2F6C3EFDEFC3D74
74763152848F8B82C49489101B9F0CFE666DB25322D20864C645C5424AFA6418
B65AE1524B0334D557417B5B076CFFC3BBB073E72E786CE37760C5F2DBE524D7
C77FD0C4844B92CEFCE448F8E0577B5B3BFCF467FF0905A8EA0988791332A731
FB4AC941829390348199AE8E4B5053510A1D68FFC7B6D7E0F32FF6C1B3DF7F1A
A263A259319C6F5A656AAE0338ADE4902418469506274F16C0A6C79F60CCA796
9B357321CC5AB05837F3692C40460F906051DE5406954502F70F4F3C0984838C
3F1A99E9284D68FBEE34006D59EEFAF2049CA3F3003858983E2905D62E5FA8BA
10F4DBD61F69A0E499C135873AA0E0F7781976D806D1B1E361CA8C05600E0850
AD8C9F9F1F760509109B301EC7023110161181D33E793F3E30D00FBDDDDDD8EF
B7C1A58BCDA8FA2FE2590BE7E95CDCF81436A6385F7C12DA2F35C3F32FFE0B3C
F5E4662CD71DC71C68690A80D6E1C28B97BAE0676FEF867EC9FB00A74BABA114
8561CBC6B59010AB77DAE240CAD35CE5B997E0ECFBC2ADA8D489594CE5ABD521
342C1C32A66441CA84892E8583A723812043829299350DAC4343D0505B0D5517
CE434FB730AEE07149D0A6CDB9196A2BCF415D55196CFBF92F2175E62D909031
8B4771696B0A004FE94A1076FEDF7119F3797C3A0FB0E38BE3F0D843CBB99757
DA75473B44E64F9A3617C627A73BD533283818A6CF9907C969CE61D2C84166A1
47B6A01651D29B983C217332332408258505303830202637994C4CF0825068CA
4B4F436DD1510808926B1531B2C4A12D001AF3BFD24A41F225798ACED24AD767
05C4481EEC682DE98193BF13F6E433B266AB323F353D0366CCC3EE4031F20F0B
F287F80833C48499212CC80F82EDCCE7E418B4DAA0677018DA7AADD0D26D855E
747320414A484A81E2829350575DC9BD994D02485D4565D919A83C95477E8BD1
1C26871A680A00EF49B8AD96893BBFCB4DE72ECFB11066E91986FCDFE0030DD8
5A53D3A740526A860C2DEAE767CECF86B4890E7F6AA571E166488F0D84712172
D263363230FB9B202AD4CC4C663C4057BF15AA2F59A0B5C7CAB40309D49CEC9B
21263E1ECE9ECC978D0F0897A1C101148EF30026BF0F01466663E66DB202EC1F
722CD462686880A919495078AE462D254CC3C38BDE0AA7DEAC85C14E2B1BE1A7
E1344F0A345D5B78CB62881B9F287A538B9F323E182243FC99DF303EA6351AA0
F4339243501086A1AC7940D408A4618271CFE0C491436C9D80E749387575B601
4E17934303FDB7DB6C236BF20F38BA0C1E4FE874F8971B9BE440CDDCB7229B6D
032B93D2B6E59AE5781E40914E19CF13BF9B4E754353410F2EE80440D6AC6CA0
96CD815AFEFC45B7CA989F181900F3D2422102553DBDA27625261CF3A0BC284F
0E71389B58806552D91C0827C28D704435702FFEACE66152DB9142EA2B71D360
4439209104435CF438F8A747EF813953274008AE4D0705063037F9D159016F83
11DC593BF34761DC430B3C81380797C2F439F321213149F44A8F0D82CCF86036
2923357F350CE90ECA93F2E6108F65D258430A841BE1C8C0E4FF1ADA4E1ADFC9
439A815E37ED57FFFD83CB7545DF18F38AAE786335526EEE67D0D75C0CA16111
6C69578A67624A1AA44F9A2C7AA54607B2963A5A752F66A0E1202D4079D7B55B
58CC091993A0B5B919978A6BC594B4FC4C4BC7FDBDDD93B39785FD5DFE813D6F
8981E8D0AD0194AADC17BF878747E0AFB8F64E90963155A6FA03020261D6FC85
2C8C7E68749F1819880CC2567F0D0D95416571201C08170E6C7A88B83230C1F7
D196F1DC9192A7306C9714282A2A82FABA7AA0B9764CBC43CD5382293367E1F6
ACA09203FCFD202D86984FCAFADA0395D53D30024328698403E14253440E842B
E13C38D03F6DFEB2D54BD0FF000F934903F794D9F6A64E55F175F3E5BEFD8C34
B421231DF811D1D326668A644B8E120668B42C7E3D0C15CCCB243775058141C1
E46440B812CE0466136C3875602F73D38FA60070A6FB3AFB474686E1C8D1A38C
70B4FE2E853424381DD620080AF0838860FF6BAAF6D5BA142A93CA26A0D9405A
864320C94FC4D9060F5014F223D0EE02480320D82DE6F6C59FEAEA1AE8EBEDC5
3977183BC421A5412AAEED7388C5FEF87AA97E5E26B7A9EC860E6140989A3E11
97848B7910C399701FE8EF8D59B0F42EDA2428A4404D0110D82FE6E3B38E8282
D3ACEEB40D2B85D0F070B69B477EA46A4303FDD8544F1AE77AB943718D8070A0
697B587804106E7D3D3D62F1843B0A00367FFFE5E8A94F0078D3F77541A8AAAA
6684540A404C1CAED3DA212400898FEE1BA501080DC2A1CF22708B70530AC0C5
C61A5C1DB6CDB5A3ACAD01784477DBCB17DB3A616FDE4928AB6A64D237352319
56E72CC085A048313977BCD3F93C777A945D5857C1F025352A85E8188746A0DD
3C5AE5BB914038F45946180AD1B171B83D5C29A2C371B7816932F7D4EE02F818
80A750D82D6D5DF0CB3FEC956D099F29AB41616880A71E5D03F15EB21AD8DB22
F4AD349D9242041ED3F633093E01B8817383F90F8403C727020F9A4841C4DD06
C2940003C5D1A034E268DC7BF24EC898CFD30E5AACB07B5F3EFFF478DB3624B4
2AE581CE609C02FA23C5C9F8A1A1F67F230DE1C0F121DCA4C071A7A10AF7D7D4
00E218C085663B8F2DDD15085D82AB50CFF2B7F4090260669B2B0EDC8370FFC3
8C4417C1059DC4F0EBE0E0F8D0ED222948708FE3FE9A023006EAC371BDA1B609
552BEDFDD3085BBA08847BEDB8062008001DE0A0D61788AB2DA48A3923AE35E2
B42E60C11F0B1E22A10128C7076C82D0AA946FE57E3ABA0041A1D13163B5BF29
1393795E4E360D0695699C2279884760A8402AEB903016E0689B6CC3C8689C4F
DB0D750243B863D887C2D033300CFD3820A36F5A11242051B952434248CBBE03
D82DD149A1DE412B2B83CAE678904DB849812E9A30B0D9DAB8BFB606D05001F7
E42C84F2EA26E8C7EB4F52A0ADE1BB6F5B20F5F268B7190F640C760F83D53A24
BBC9D3DFD707B1F6B3F86A1524C65B880FA83D4873506F8116DA26C1A644E4C7
120B7EC4604676FC219B6447585276B85974FB0F691D35E8EBEB957913EE0298
7A7880A600688D0162A22260F386D5F0E9FE9370A1A689A9C829E9497017329F
CE0A10F2DE00614981D0DB6A610B29749D8B437767279827A4F24F7DB69DA114
59DE46DD138BD8CC85474F413D7811550AB408C4C00465DC5F5B00784C37364D
F536ACCB7113C311F4ED88971C1F1EE4B2A4BD059F9CC1E96E6F0F3BF7CF516F
6EBE08F3E6CEE29F63CA26DCA440B813A098E1614101340580D411817BD91432
F3E6DFC95959007BF7B20B9AC9132689556D6E6E017F9372602806DF3007F1AD
A9492E0074C19400C3845D2D746B0A004BC152892E9F74CC9E399BD59B0E5A12
71F94CC062B14003DEF19F90963CA6E8525BD704841B07C2997027F0EB872FB9
BF0E01303400112B323A0A925352A0A1BE9E6981A818C71E4071491964A6CBB7
8839816F945D52226A7986025D261DA641A0CD465B844D1C2F9C2CB807EA01C8
1800B064E952468696A63A19392AABEAA0B7A797CDFB69EE7FA30DE1525E5923
C3B1A5A9967DE3CAC0FB2392D56C4D01107A7F615A4272E0CB66C9D265480113
5ED6AC07714E8D3E7413E7C8D7A77011085FFB18038670915E241DC2B58BD6E6
066AC823C3969177D13061A01F6D01F0658E2BEA9E80E7EF17666733E236D655
8A4424475129BEF78383AE1BDDFA0907C2450A8DB51588334D386D1FE34F9534
4C5300942B79BEFE7DDFBA758C7E4454A91620CFDDB907F1FD1F2B5B8AA5E5D8
EB6DA8EC3D9F1D92F297E148B8128C0CDBFECD0FF122C3417B10A86300D08A5B
C2B9074FE18A60235BB1A2E5E1554BE7439CCA56F01F7B5FE4657BA68D63BDC4
79E1EC6650D58522F60E00AF487B6737ECFCE4007C73DD1DF6953D1E72ED6D52
561FA300B67574C90AAB2E2F6142890D77070688D33F1E498706B0F7FB58021F
104A6D3A0FF0DFEF7D02C5E76B80AE840F0D5999FBD7FFB307284C1A57872C71
BCC6B43D69051E09C725391A0CB65F92CFB54B2F54C39ECF0F5FF7B1C0DE2FBE
82E2B22A19DD08373A01849C1BB00D5B9E349986106DC1F0889A02207290A750
D89F61CB1F50EC0350140B0A42EE81938AD89EFF597FB413AAFE6C83A868611A
78BEE804CEB7ED9B2CF6EA1D2F28859D9F1E623B83D77A4C40FB00BB720FC3D7
A74A64C4259CE8D510021CF26D458B24C109B4BB00A724728F0B6ECE035CC02E
C19BA0F6701B347C128C376FCCF8C45B0C582D03D0D3D30525A78FB2F77AA4EF
FB1C3F7D0EBABA7BE19175CBF1F2AC7C5FFE6AD1A41F5F17FDDF1DFBA0B45C98
E2F17C692C4038D9772E3F3DB17FEF2F7898D2D6D400B4822418F52E4099A1EC
5BA5DB90857BD047E3994B50BBDB2C5EBB8A080F835F6D7B1992F125CFDEEE4E
282DC4FF8EA278C3E75C451D6C7BE32F507AA1E6AACF0E284F96B782F984C3B9
33F90C2773309E0AB6581F4132A31250074D01504FE6F09D9CEE7A097432EE0A
7A03349DBD047B9E3B021525A7D8808A98FFD296EF416A5212BCB0F559F67C6B
677B0B14151C61E1D23A77A21678EB835C78E3FD4FA0A6E122DBCDA31DBDCB35
B58D2D2C2FCA93F29602B5FC626CF91D6D17C13F301852672DA1E036691CA55B
B30BA0D64F20FC2A9303ACC4D17E456D93D3382018CF03DCB96C81CB74CE398D
4D1F62FEEE2D47C08A2F74F4F4B74345E929786FFB5B10858741BB7AFBD9434E
4F6CDE04AFFFFAB7D089CBAD674E1C8269B36F668F36486B5472A116C84C4C1D
0F37CFCD82B9D333202C34581AC5A5BBB76F000A4BABE058C139A8AA6B568D87
F7FEB0E51FC707A43A20263616C2D2E68139305435AED4D3C4192CF594BA1FFE
E1DB8CF72F3EF9B0D45BE66E6DEF82CF7130585123F4F99913929860D0790025
FCA9FF45A5D798FD96329F90A43B80B72E5BC95EF8FAE7A71EC7A99E09BA7BFB
A0BBA71FEA1B9BE1DDF7DE858EF6769CFF9B61F2F479F80C9C6BED48F92525C4
C084E47888C7EBF5511161EC6D05F2A7D95407B66E9A5E57D75F84C68B6E1B31
AE4C36C285D202B6D69F949C045BB63E0FAFBFF739650585791F9A8A8EE432B7
F487F35D5303B05900A6E409A49970772C1E0AF9E69A65FC53B4D5D23C18FC82
183E961D45670AE09D2D9B59CB273C89F98B6FBB138243C3707165085EF9C9CF
61D3C647D91DC06ED40426FF00983B7F117C7DEC30DDC5877367F3D9B9818CAC
59EC3A995A5D89B15ACC554BC7FDE88047D5F922686B15F676B26F5E041B373D
0E616161C2808D4774636B0A802BD5EF264F8F0F22E66F796A339EFEE9637561
CCCF59858F3223F3715D9D8E56E18630BCF6FA6F60FDFAF5783ECF862F7A9741
456515C425A43035DC857BEFF47063E7B116BC9899CADEFA959E24BA1222D103
D20D35E5B80E51CB96A543F0AEC2B7366C80DB57AC14B3D5CB374D0110358098
B5773B88F9CFC9981F0C4B88F9D4F219F3AD28006486D8AAE7F6EDEFC08CD90B
A10A2F8F72888D89831FBFF8027CF4E10770E8C07EB618430B32F4423809434C
7CA2389BE069B46C2ABB1D5B7A4B336E47B7B5D8A39B60C9B21CF8D6B737005D
5091315DE7AA9BB60070CC64B9734FEFB219F39F96B67C64FEED9CF94376C673
0110EC96E646D85BFE3E4C9DB388F5FDC3560B3CB3F539A686BFFBF866B8FF1B
0FC2EE9D3BE0F0C13C768E804EE59497027B6286D612A84B090909672F889BED
2F7BD0BE3DBD0CDADFDF030378B0B31B0F72F461B7C281D621162FCD817BD6DC
07E3131305EFCBE48FA600F07EFC32F3E7388F799B98FF0305F3972EBF1B5B7E
28B6FC21F6041BB57ADEFAC96E6EA84523B4FC7385C7601ABECAF5DCD61F2273
C3C4D6188F3B88DF796C13AC7FE46FE1C4F16370ECE861282D3ACB182A65AA16
8188E9D3F0E58F45F8FCDCC29B16416868084BE28A2F9C6F5AF96A0A805606DE
10AEC6FC652B90F9D4E7DB994E4220657E9384F94483F489E9F0E3975E605D85
1A4D88614B6FCB6166D83A0CD55515505959014D8D8DA8D69B601097D3BBBA3A
59D271E322816E1CC5E33B8389B8D690818F3DA4E30B24FE667FB5ACAFC8CFE7
05408DF9B711F3F1E837633EEE69903A26E6D34617D94DF535D05C5F2D127E26
BE03FCEAB6D75D325F8C6877102333274F61461976BDBF7D5A0094CC0FC27775
96DDB19A319F319D319EB77C2BEB069AEAAA51002E9FF9D79BC15AE55DF152B0
560163355C8DF9B7ADBC870DCEE85FB338FA7BEE1E8246643C190EA36DF93CDD
58B27D5200D4989FB3F25E647E38633CEFF7853E5F50FB8DD8F21BEBAA44DE79
03F3A932BABB80977EF1AE58794F7674B5D643D1C1BFC0080EEE0848EDE7DCB9
86319FCFF3E51A005BBE82F91171C91091B9147EFAC65F3D99140C779FD200EA
CC5FCB1E54E2033D61B0C7FB7DFC2F1DC8FC86DA4A91D1C4FC994BBE01FE92D7
38C5400F74686E0679609D18CAA9A993C086F7F42570ABC9CF9C8B3EE1E4472D
FFF655C87C54FB34C523B54F6BFCA405D837FA11E3EB6B2AC42CF064C4214B4F
FBDDE8D1237A2A1CE333E78029201877E282C06C1D84411882205300B4E34B9E
91EC152F1BE4EFEF83ECA541F85893992DB49AF06A19D8E872B730ABA74D26BC
DB8D61F6DBC22356C83F3808D9B78532BFCEC111880EC6F788F07AB81FDE031F
C1E7EBFCC2435898B5AB0FFCF17F12586DFEF828E4300C0CFB83BBCD205FD100
4ECC5F7E97D0F287D8800FFB79C588BFA1B66AD4CC57C882477CEA1E0378446D
D49194331FFF7FCF8ABBEE63A37DE7153E61C44FAD7EB42D5FBDE8B1EFEBED1A
C089F977DC7D3FF6F9E3ECD33C41F54B47FBF535A357FB639FCDAE31F46601C8
92F5F9D8F257DEBDCECE7C616A478C978EF8EBAACBF1FFEC386ED5E8E9F35D93
D63342BCB60B300506FC0A59200CF870BF7CE5EA754CEDB3051ED6DF0B42C0D7
F87D91F924A25EAC016CEC88123D9BBE72F5036CAAC7B759AD7878D22A59E3AF
AD2A87DAAA0B6293F58596CF2BEBBD026033B1E33C7436BEB3A38D6DE2A88DF8
7D99F9DEAD014C36B64C47D7A40FE7E5421D0EEEA4FD3DF5FFD4EA6BABCEF3C6
40F370CD79BE18D94B1C5EAB01BA86FA9EC5959122E21309C1D75FE5E1EB1ED5
4C1310F36B90F93595BECD7CA28DD70A00D6AD6DC402395C08E8C64CC1F123D0
DC58878C47E6579451FD19F862CBE775F7DA5980BD82AD24047E81B63CBC8A33
13FF7B2614179E409910965C298E2F339FEAEFCD1A80EA47C08440D40412E623
F7F3B4D6F6852CBCF7D717048009C1606FFB2D28042F63EB3F8A32B00FCDD375
55E75661A0CB8D1DEF65BBA3665EBB1BE8A8A2E17247015FD100EE68E0D361FF
3F00FF2271829B3E1F290000000049454E44AE426082}
end>
end
item
Name = 'RunCodeCoverage'
SourceImages = <
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000100000001008060000001FF3FF
61000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000004
20494441547801001004EFFB01FFFFFF00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000004739AC0FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000040000000089643F00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000779CC1000400FFFF00FDFEFF006D8DB00093735000
8CE47A0000000000000000000000000000000000000000000000000000000000
741C86006D8DB0009373500000FFFF00016F95BBFF8564420000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000007B9CBE0004FDFCFC00FDFDFF007492B1008C6E
4F0093E97B000000000000000000000000000000000000000000000000000000
00006D1785007492B1008C6E4F00FDFCFC0001698EB3FF846648000000000000
0000000000000000000000000000000000000003020100030200000100000000
000000FF000000FEFF0000FCFDFF007C9AB80004FDFCFC00FDFEFF007B96B300
856A4D009AED7D00000000000100010017061A0020062400B9BDB700C1CCBE00
ECF0EA001C131F00312046007D5B7C00FFFEFD00016486ABFF826A4F00000000
00000000000000000000000000040201000201FB00618E5000EB01E5002F3C2F
000E120E00F2EEF200CEC1CF0019041F003B1F730002FDFDFC00FDFEFF007F98
B300FDFEFF009EEF7D009EEF7D00C3F8A90086B37400E8FFE200374B37006A31
73000A020B00090F08003B4E3900E5FADF00E2F1BB00015E7FA4FF816C540000
0000000000000000000000000000000C0703004B803300254220000C110C0098
3AA500F8FDF700B2E2AB00BFE7BA00F1EEF200DBBCE10002FDFDFC00FCFEFF00
869DB500FCFEFF00A5F47F00A5F47F00C7F9AF00E6EDE200040A0300F8F9F700
000000000803090056215E00561F5D0004080200EDF3E70004FEFCFC00FDFEFF
00735F4900FDFEFF0054087F00000000000E05030019128200EFECF000090D08
0000000000F8FDF700A8DAA200B9E2B200F4EFF500110B170004FEFEFE007F8F
A400000000000000000000000000000000002A221900321F4100C7D2B4002033
1F00C8E7C3009BD29400ECF8EB0000000000E1D4E2002F19490001FFFFFF0000
00000000000000000000000000000000000000000000001656160C070AFBBD0F
1A0E3614241400070B0600F9F3F900EADBEB00F3E8F4C60402104301FFFFFF00
000000000000000000000000000000000000000000000000165616000511050A
03FAF57BFFFE015B0001001F000000DBFF0000A905011085000000F8010000FF
FF18DFF8200AB227620000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D
F8000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000009
28494441547801001809E7F601FFFFFF00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000002000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000020000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000400000000739AC0FF0000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000008D6640010400000000FFFEFE008D674200000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000007399BE00000000000400000000FEFEFE00FDFFFF008198
B300020101007D674C0089E27900000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000771E87008198
B300020101007D674C00FEFEFE00000000000400000000FFFEFE00FEFE0000FF
FEFF00FD00FF00FEFE0000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000FEFE0000FF
FEFF00FD00FF00FEFE0000FFFEFE00000000000400000000FEFEFE00FDFFFF00
7B674D0000000000FDFFFF00721B860000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000FDFFFF00
7B674D0000000000FDFFFF00FEFEFE00000000000400000000FEFEFD00FEFEFF
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000FEFEFD00000000000400000000FFFEFE00FDFE
0000899DB4000101010076624B0093E97B000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000006D17
8500899DB4000101010076624B00FFFEFE00000000000400000000FEFEFE00FD
FFFF00FEFFFF0000FFFF00FDFFFF000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000FD
FFFF00FEFFFF0000FFFF00FDFFFF00FEFEFE00000000000400000000FEFEFE00
FEFE000074614C0000000000FEFE000068148400000000000000000000000000
0000000000000000000000000000000002020100040200000100000000000000
000000007A654D00FEFE0000FCFEFF00FEFEFE00000000000400000000FFFDFD
00FDFFFF00000000000000000000000000000000000000000000000000000000
000000000000000000010000000403010001FFFA00A8C1A300B0C8A900DFE8DC
000000000023192500503A5A0050385B0008040200014101000400000000FEFE
FE00FEFE000091A2B600010101006E5D49009DEF7D0000000000000000000000
000000000000010001001C081F0016FB190087998300E800E4000F290B001337
0A0000000000E9EDDF008ABF7A00ACC3A300482C7800000000000200000000FE
FEFE00FDFFFF00FEFFFF00FDFEFE00FDFFFF0000000000000000000000000000
000000000000000F0411001B041E0086978200EF15EA00174112008945960010
0A1200010501000818070017421200E40FDC00ACCB8000000000040400000000
FFFEFE00FEFE00006C5C4A0000000000FEFE00005E0E82000000000000000000
000000000000000009060200ACC49D00E801E50016281000FEFCFE0041164700
301034008DD68100C0E9BA00000000000F2B0B00E9EBDF001B1E0F6302000000
00FEFEFD00FDFEFF00FDFEFF00FDFEFF00FDFEFF00FDFEFF00FDFEFF00FDFEFF
00FDFEFF00FDFEFF0000FF0000B0C6A6000D270900FEFDFE00FEFDFE00000000
001106130084309200822E8F000A020C00FEFDFE000C26080001010162040000
0000FEFEFE00FDFFFF0099A6B8000101010066594700A8F58000000000000000
000000000000000000002E003300DCE8D90013310C00FEFCFF00000000000000
00000000000000000000421949002F12340089D17E00C0F7BB00000000260400
000000FFFEFE00FEFE0000FFFFFF0000000000FEFE0000000000000000000000
00000000000000000000000000000000000000FEFCFE0001FF01000000000000
0000000000000000000000000000000301040002FF0200FEFCFE000000000204
00000000FEFEFE00FDFFFF006358480000000000FDFFFF0053087F0000000000
0000000000000000000000000E04030021169200EAEEE1000511040000000000
000000000000000000000000BEE4B80086CD7B00F0F9EF00FAEEFC00000000DA
0400000000FFFEFE00808FA40000000000000000000000000000000000000000
00000000000000000000000000251E16002D1D4100B2DD98000E300A00000000
0000000000F0F9EE0085CA7B00BDE3B7000000000000000000F5DDF700010001
9E01FFFFFF000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000021612108FCFFF0CA0B25072D081E
06008C3F980084C87A00F0F9EE000000000000000000F7DFFA00F6DEF9CF0FF6
F03801FFFFFF0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000021612100FAFEF11E0201FFB405
14042D081C0500030D030000000000FDF2FD00F8E4FB00FBEDFCD00103044B0E
F3ECE60400000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000E204011036
FAEDF068FBECFC5B0000002A00000000000000D4000000A50401109AFD00F4F8
00000000010000FFFFFE63A99908E9FC8B0000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7A
F4000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000010
30494441547801002010DFEF01FFFFFF00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000002000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000020000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000200000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000040000000000000000739AC0FF000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000008D66400100000000040000000000000000000000008C65
4000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000749BC000000000000000000004000000000000000000000000FE
FFFF000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000004000000000000000000000000
FEFF0000839AB400000000007D664C008AE37900000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000761D87008298B300
010201007D664C00000000000000000000000000040000000000000000000000
00FEFFFF00FDFDFE0000000000FEFFFF00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000FEFFFF00FEFFFF
0000FDFF00FEFFFF00000000000000000000000000040000000000000000FEFE
FE00FEFF00007C674D0000000000FEFF0000721B860000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FEFF00007C67
4D0000000000FEFF0000FEFEFE000000000000000000040000000000000000FF
FEFE00FEFE000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000FFFEFE000000000000000000040000000000000000
FEFEFD00FEFFFF00899DB5000000000077634B0092E87B000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000006E188500
889CB4000101010077634B00FEFEFD0000000000000000000400000000000000
00FFFEFE00FEFF0000FEFEFF0000000000FEFF00000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000FEFF00
00FFFF0000FFFFFF00FEFF0000FFFEFE00000000000000000004000000000000
0000FEFEFE00FEFFFF0075634B0000000000FEFFFF006A168400000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000FEFF
FF0075634B0000000000FEFFFF00FEFEFE000000000000000000040000000000
000000FFFEFE00FFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000FFFEFE0000000000000000000400000000
00000000FEFEFE00FEFF00008FA0B6000000000071604A0099EC7C0000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000C030D001706190009020B000201020000000000FE00FE00
410C5400A0AFC200EAEDF30070604A00FEFEFE00000000000000000004000000
0000000000FFFEFE00FEFEFF00FDFEFE0000000000FEFEFF0000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000501050017061A001C071F00D8E1D600C2DAAD00DCEADB00F2F8F100100911
00B418B500270F3A00260E2F00FFFFFF00FFFEFE0001810100FF7FFF00040000
000000000000FEFEFE00FEFF0000705F4B0000000000FEFF0000631183000000
0000000000000000000000000000000000000000000000000000000000000101
000006030100EAF5E30072B16100DDF5D8000D170A00092505000B041200FEFC
FE00CFF2C400C3DEBA00260B2D0039F89E000806040000F70000000000000200
00000000000000FFFEFE00FEFFFF00FEFFFF00FEFFFF00FEFFFF00FEFFFF00FE
FFFF00FEFFFF00FEFFFF00FEFFFF00FEFFFF00FEFFFF00FEFFFF00FEFFFF0003
020000EBF6E3005AA84600E809E000172A12000A130800030603000102010003
0603000B140800172A1200E408DB0056A74200231F0400000000000000000004
0000000000000000FEFEFE00FEFF000095A4B700000000006B5C4900A1F17E00
000000000000000000000000000000000000000000000000000000000D030E00
2B0B300083B07E00FE14FB000C130900FEFDFF00852F930090D88400EBF9E900
0000000000000000000000000B140900F4FEF600B2E8890000000002000000FE
020000000000000000FFFEFE00FEFFFF00FDFEFF00FDFEFF00FEFFFF00000000
0000000000000000000000000000000000000000000000000000000000170619
00D5E0D400E7F8E4000B120800FFFDFF00FFFDFF003E164400A53BB600541C5C
0001FE0100FFFDFF00FFFDFF00FFFDFF000B130900E3FBD7001F07134F000000
00040000000000000000FEFEFE00FEFF00006A5C490000000000FEFF00005B0D
8100000000000000000000000000000000000000000000000000000000000C07
030070DA59000B140800FEFEFE0000000000000000000000000009030A006F29
7B004A1B520089D47D00D6F0D20000000000000000000A140800FAE3F35E0000
00AF020000000000000000FFFEFE00FEFE0000FEFE0000FEFE0000FEFE0000FE
FE0000FEFE0000FEFE0000FEFE0000FEFE0000FEFE0000FEFE0000FEFE0000FF
FF0000D4E9D00005080300FFFDFF00FFFDFF00FFFDFF00000000000000000000
000000250E29009A39AA0072297D000A010B00FFFDFF000508040000FF013200
000000040000000000000000FEFEFE00FEFFFF009BA8B9000000000065584700
A9F6800000000000000000000000000000000000000000000000000000000000
2E013300F1F7EE0016011100FEFDFF0000000000000000000000000000000000
00000000000000000201020054215D003113370062C15300F701F60000000016
00000000040000000000000000FFFEFE00FEFF0000FEFEFE0000000000FEFF00
0000000000000000000000000000000000000000000000000000000000000000
00FF00FF000D080E00FDFAFE0002030100000000000000000000000000000000
000000000000000000FEFFFE00B0DFA90095D48A00F7FBF600FEFCFE00000000
EA00000000040000000000000000FEFFFE00FEFFFF006358480000000000FEFF
FF0053087F000000000000000000000000000000000000000000000000000000
00000D0403002C16A900D4F5CA00060B05000000000000000000000000000000
000000000000DBF0D80086CD7B00D3EDCF000000000000000000F9F5FC00FF00
01D200000000040000000000000000FFFEFE00FFFF0000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000FAFCFF004A285500CBC1C30004080300000000000000000000000000F8
FDF70099D39100A4D89C00FDFFFC00000000000000000000000000F8F1F90000
00009E00000000040000000000000000000000008190A4000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000001010000352C200016041F00F0F2E500060B050000000000C0E3BA00
89CB7F00E8F6E60000000000000000000000000000000000F9F4FB0019042200
C3F2C9B10000000001FFFFFF0000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000181010023071524FC01FDC7090F0714060A0400000000
000000000000000000000000000000000000000000FAF5FB00F7F1FAEC0100FE
35E0F9F0E0FF7FFF000200000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000DCFE02FD38F8F0F9D2F5ECF700FBF5
FC00FEFBFE00FFFDFF00FEFBFE00FBF5FC00F5EBF700F8F2FAD000FCFD360000
00E0000000000000000004000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000DDE0F9EE311F001159FE
FAFE59FF00003400000017000000E7000001CC0000FEA7E0F9EFA91F030FFE00
000000000000000000000001FFFFFF0000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000010000FFFFEF3865EFCE0798BD0000000049454E
44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000300000003008060000005702F9
87000000097048597300000EC400000EC401952B0E1B00000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000024
40494441547801003024CFDB01FFFFFF00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000002000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000020000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000200000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000002000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000020000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000200000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000002000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000040000000000000000000000
00739AC0FF000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000008D66400100000000000000000400000000000000000000
0000000000008D66400000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000739AC00000000000000000000000000004000000000000000000
000000FFFFFF00FEFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000FFFFFF00000000000000000000000000040000000000000000
00000000FFFFFF00FFFFFF000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000FFFFFF000000000000000000000000000400000000000000
0000000000FFFFFF00FFFF0000000000008198B300020201007D664C00000000
0089E37900000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000771D8700000000008198B300020201
007D664C0000000000FFFFFF0000000000000000000000000004000000000000
00000000000000FEFE00FE00000000000000FFFFFF00FEFE0000FE0000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FE00000000000000FFFFFF00FEFE
0000FE0000000000000000FEFE00000000000000000000000000040000000000
00000000000000FFFFFF00FFFFFF00000000007D684D0000000000FFFFFF0000
000000741C860000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000FFFFFF00000000007D684D0000
000000FFFFFF0000000000FFFFFF000000000000000000000000000400000000
0000000000000000FFFFFF00FFFF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000FFFFFF0000000000000000000000000004000000
000000000000000000FFFFFF00FFFF000000000000859BB400010100007A644C
00000000008EE67A000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000721A860000000000859BB4
00010100007A644C0000000000FFFFFF00000000000000000000000000040000
00000000000000000000FFFFFE00FEFF000000000000FEFFFF0002000100FEFF
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000FEFF000000000000FEFF
FF0002000100FEFF000000000000FFFFFE000000000000000000000000000400
0000000000000000000000FFFFFF00FF00FF00000000007A654C0000000000FF
00FF00000000006F198500000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000FF00FF00000000007A
654C0000000000FF00FF0000000000FFFFFF0000000000000000000000000004
000000000000000000000000FFFFFF00FFFF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000FFFFFF00000000000000000000000000
04000000000000000000000000FFFFFF00FEFF0000000000008A9DB400010101
0075624B000000000094E97B0000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000006C178500000000
008A9DB4000101010075624B0000000000FFFFFF000000000000000000000000
000400000000000000000000000000FEFF00FFFF000000000000FEFF00000200
FF00FFFF00000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFF00000000
0000FEFF00000200FF00FFFF00000000000000FEFF0000000000000000000000
000004000000000000000000000000FFFFFE00FF00FF000000000076634B0000
000000FF00FF00000000006A1684000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000FF00FF0000
00000076634B0000000000FF00FF0000000000FFFFFE00000000000000000000
00000004000000000000000000000000FFFFFF00FFFF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000FFFFFF000000000000000000
0000000004000000000000000000000000FFFFFF00FEFF0000000000008E9FB5
000101010071604A000000000099EC7C00000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000020103
000F0310001305140007020900020102000100010000000000FE00FE00410C54
00FEFE00008EA0B600FDFEFF0071604A0000000000FFFFFF0000000000000000
000000000004000000000000000000000000FFFFFF00FFFFFF0000000000FEFF
FF0001000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000001000100100412001A07
1D0009FE0A00D5E2D400CADFC700E4EFE300EFF5EE0002010100110B1200B814
B8004022480029241D00F0F1FD00FFFFFF0000000000FFFFFF002C8101000000
0000D47FFF0004000000000000000000000000FFFFFF00FFFF00000000000072
604B0000000000FFFF0000000000006512830000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000100000004030100FF00FA00A6
D09B009BCC9100FC09F80009100800061C040012060B0000FFFF00FCFBF500CB
F5C000C2C9B90006F80A0065356F0001013400FFFF0400FFFFFF000000000000
0000000000000004000000000000000000000000FFFFFF00FE00000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000100000004040100F0F9EA006DAF5D00
DEFBD70011260D00040708000000000000000000000000000000010002040200
050904000B140900FBF8FC0094D28700B8D9B200914FA4000806040000FA0000
000000000000000004000000000000000000000000FFFFFE00FFFF0000000000
0092A2B600010101006D5D4900000000009EEF7D000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000010001001B071E0017001A007BAE7600FE10F8
0015201000000000000000000000000000000000000000000000000000000000
0000000000000000000508040015261000E3E6DA005BA8460057228900C0D200
0000000000000000000200000000000000000000000000FEFF00FFFFFF00FFFF
FF00FEFFFF00FEFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000110513001C0620008DB68700FE0FF8000D17
0A00FFFEFF00FFFEFF00822C900011041300FFFEFF00FFFEFF00FFFEFF00FFFE
FF00FFFEFF00FFFEFF00FFFEFF00FFFEFF000D180A00F60DEF00B2E886000000
0006000000000000000004000000000000000000000000FFFFFF00FFFF000000
0000006E5D4A0000000000FFFF000000000000600F8200000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000001000000090602009FCE9000E5FBE200131D0E00FF
FEFF0000000000000000003F1646003312380095D98A00B6E6AE00FEFFFE0000
00000000000000000000000000000000000000000000000D170A00E6F3DB00F9
06126E0AFA038C0000000002000000000000000000000000FFFFFF00FEFF0000
FEFF0000FEFF0000FEFF0000FEFF0000FEFF0000FEFF0000FEFF0000FEFF0000
FEFF0000FEFF0000FEFF0000FEFF0000FEFF0000FEFF0000FEFF0000FEFF0000
FEFF0000FEFF0000FEFF000001010100F6FBF2009CCB92000E1A0B00FFFE0000
FFFE0000FFFE0000FFFE0000000000000C040E00772B84008F339F001D092100
FFFE0000FFFE0000FFFE0000FFFE0000FFFE0000FFFE0000FFFE00000F1B0C00
FF0200790000000C0000000004000000000000000000000000FFFFFF00FF00FF
000000000095A4B700010101006A5B480000000000A3F27F0000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000024092800E5E2E6000009FC0003040900FFFEFF
0000000000000000000000000000000000000000000000000032123700A03BB0
00A1DC9800A5DE9B00FBFEFB0000000000000000000000000000000000030502
00080D0612F4FFF94F000000A502000000000000000000000000FFFFFE00FFFF
0000FFFF0000FFFF0000FFFFFF00FFFF0000FFFF000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000008020900C5DCC200080F0600FFFEFF00FFFE
FF00FFFEFF00FFFEFF00FFFEFF00000000000000000000000000000000000602
070065266F009E3BAE002A0F2F00FFFEFF00FFFEFF00FFFEFF00FFFEFF00FFFE
FF00080E0600000101500000000004000000000000000000000000FFFFFF00FE
FF000000000000695B490000000000FEFF0000000000005A0C81000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000C0703008CF0890004160300FFFFFF0000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000220D2600993AA800AEE0A50098D88E00F5FCF4000000000000
0000000408030001FF002C0000000002000000000000000000000000FFFFFF00
FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000
FFFF0000FFFF0000FFFF0000FFFF000000000000ECF5EA0001020000FFFEFF00
FFFEFF00FFFEFF00FFFEFF00FFFEFF0000000000000000000000000000000000
0000000000000000000000000201020054215D00A540B6003D164300FFFEFF00
FFFEFF0002020100000100180000000004000000000000000000000000FFFFFF
00FF00FF000000000099A6B800010101006659470000000000A8F58000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000002E013300FF00FE00FFFE0000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000401040001000200FFFE00
0000000000FFFF000000000000000000000400000000000000000000000000FE
FE00FFFF000000000000FFFFFF0000000000FFFF000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FE00FE00100A1100FBFBF6000305
0200000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000FEFFFE00B0DFA90093D48800F5FBF4000000
000000000000FDFAFE0000FF00EA0000000004000000000000000000000000FF
FFFF00FEFF0000000000006559490000000000FEFF0000000000005509800000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000C0403002411AC00D3F8C80002
0305000000000000000000000000000000000000000000000000000000000000
0000000000000000000000DFF2DC0087CD7B00CFECCB00000000000000000000
00000000000000FBF8FC00000100D40000000004000000000000000000000000
FFFFFF00FFFFFF00000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000FBFDFE0043244D00CCC8C300
0509040000000000000000000000000000000000000000000000000000000000
00000000FBFEFB00A0D797009ED69400FBFEFB00000000000000000000000000
0000000000000000F9F4FB00FFFFFFAE00000000040000000000000000000000
00FFFFFF00FFFF00000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000F9FBFE003B1F480004C37C
00FDFBFD00020402000000000000000000000000000000000000000000000000
00D1ECCD0085CB7A00DDF1D90000000000000000000000000000000000000000
0000000000FDFBFE00FAF7FBF001F9FFB5000000000400000000000000000000
0000000000008090A40000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000282118004119
5700B9EBA2000B14090000000000000000000000000000000000F5FBF40092D0
8900ACDCA500FEFFFE0000000000000000000000000000000000000000000000
000000000000F6EEF90000FDFF87000000F00000000001FFFFFF000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000001B811B0000
00000A0607F9C408100631070C050000000000000000008E3F9A0088CB7E00EA
F6E8000000000000000000000000000000000000000000000000000000000000
000000F9F3FA00F9F1FACDFFF90E3C000000F8DF7FDF00040000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000F60402FF4EF8F0F9CB00FFFF18060B05000000000071BF650000000000
0000000000000000000000000000000000000000000000000000000000000000
FAF4FB00F7F2FAE40103034C000000F800000000000000000200000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000E404020035F8F2F9CEF6EEF800FDFBFE00FFFEFF00FFFEFF
00FFFEFF00FFFEFF00FFFEFF00FFFEFF00FFFEFF00FFFEFF00FDFBFE00F6EEF8
00F7F1FACCFE020237000000E800000000000000000000000002000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000E4FAF8093DFDF9FE7DF4ECF7F4F7F0F900FBF6
FC00FDFBFE00FFFDFF00FFFDFF00FDFBFE00FBF6FC00F7EFF900F5EBF7F2FCF9
FC7901FA0E3D000000E600000000000000000000000000000000040000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000F60000008401F8FE94FDFE0055FC
F8FE4DFF00FE290100011A00000000FF00FFE6010000D5FFFF01B301FAFEAD00
0801F000000000000000000000000000000000000000000000000001FFFFFF00
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000010000FF
FF8DB1E93BB98585C20000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000040000000400806000000AA6971
DE000000097048597300000EC300000EC301C76FA86400000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000008
FF494441547801EC5A0D7055C515FEEE7B792F797979F9232085582712CA4F85
22753A240863C5B15645B002DA29385A8B0E633BA550EAD032955090412D459C
71A6B1C89F0AA20814A528638D90AAA5980894A6417E3A0DB12A2124909797BC
977B5FCFD99BBDB9B93FF294903C13366C76F7ECEEB9DFF9F6ECD9BD3728F178
1C7D3979FAB2F16CFB65022E7B401F67E0F216E8E30E703908A6583D607E6959
AFBE18FCFEC11B14B3CD3602B8930699C7F49A3A2DAECD1647027AB50B582870
26A00F31E04240DF61C099008B9BF4E6A633012607F8B0BA06EBB6974323D98F
EFBC1E63865D29F878BC666152F1F2AB2B970B3C122F37EE9BDA81D70DEC056F
826BC9F8338D619C3D17C673DBF6B9E9491A396364BC9C13C17B410FB05A96AC
9F0FDC70B9C9A55D360FE00F24E67CDF1DE3919B154476281DF74FB9DEE8930A
92A594981923E3CDC9EC8C57F65BF1DA3D8009308D1A4D7B7EE5827B0C89EC9B
3FF83143960C1589CB0DAFC0E8E00E360274A692C1A4AEC7C0B659933301D651
BDA49D380176A27A0505091140518E62400703878ED6E0F99DEF8AE0378B02E2
E86FE8F780A7FEF79BA422E5E75F5B26F048BCDC9839B9D8C02B3A1DB680CB29
00E641E48D7F7E17F5E21ED08C0D3BFE66C885C224FA25F13246C6CBD98C57EF
EF585809DD3906D8C7C9F18200A391441587C515E8CC72A72DE0EC01349539E0
FCA3DB8B9143E76A16DD03664E1E6FC885F624FA25F13246C69B4DF700335ED1
6F66A31DBBCD037889CD4C5D33341FCBE7CE304C957D0F0F586AC892A12271B9
E1151813218015315BBD314992CCB6D93C4010D04B19488C005A7F074F3193F6
95AD3BF9B6CD03F8C5DFEC00FFFCA8062FED7A4FC4857B6E2BC63543F57BC01F
EB162515110FE5E93149E2657077DF5A64E01560F9A38625399F02ED81905D66
3319CFDF021ACE3763D3EBFA85C8C9952C7ABBBDA96FDDB8C0C878399BF1CA7E
2B309B078881D651A6B69D4353670F56DD7099E54E0B67F780F618C07180F38C
EF17D1991A446646805CAA58C8589E6C49E2658C8C97EF2D66BCA2BFD3E6D62D
B079005B683670E4907C2CFEE974C35ED9F740CEEF0C593254242E37BC02A31C
64026C23E0425BC034B7DBABE1E879FCF5F84E1CA8DD87637547703AFC099AA2
E790E1CF44FFE04014E67D13D70D9E801B874C46D01FB2E163DB0A4A7284FCE4
A36745E94C800353366DDD2860C3D7573E85570EAF81271847203715A9F93E64
FBD390EB0D4053E368899EC1074D6FA1BC72175696FF1AD3463D807BC7FC0C19
A9590652A718E04C8031A5E72B65275EC7137B7F0935D48ABC5121787DB6B005
8F57812790021FE58CFE01A8310D3B4E3D87D7AA5EC082894FE286AB6F138624
44801EE53A0CAF3A7E0AAFBCF13E89E3987E4B1146504CE0B4AEF1B71D832E51
ADF248050E1E3D88BCC24CF88399093F8549CA2DC844341C43C93B7370F2EC5C
DC3F769E1ED52D5A6C74C6E39A88951CE839BFBCFB3D34D099DA48F7802D7FA1
0B51BBDCA2A7CB9B6CFCE1138770C5881CF8D37D3A187AB84FE9A81B6024284B
C9F3068CC8C6C67FADC2DA8A95B4889A0DA70301FA29C061C02914B8C96D9A2F
4270B2E624ADFC87C81B9A054F8A22BC8F3D90F39AEFBC8A5159633BC9649F53
C9F359CFFA437FC0674AA50D950B01FAC358E10F6E1E477F13D0EF01777D6F9C
F1609BA62E1244A351941FD8275CD8E321E3F96A6ECA57058760F5B73760FEF0
C5087A429DFACCE3CC75D6935B104275CA8B8C32DB0CD51604C942E15972D070
DAF30BE7E8FB9E65EC659C66864AF44A17FF2EDDBF1C292145043482E2983C8A
0753F2EFC684FE93B0B26A09CA3E7DD3719C59C80132B55F046DA7BD8FA444E3
C61F365D3C40777F06D09D39DC7A1E5B8F94227445BAEBCA9A8DCA4DCDC3D231
ABB1E2DA67D0DF3FD0758EF406D6AB78E273498711519D09A0114C7E77E7BDFF
D90D04342874AC39ED679639A5F1036EC48B137761DA55B3A0D08FDB5CD6EBCF
F0A5B5F9953BA51E6702E8416E4A2EA5FCC0A932A485FC00076BB72C915BCA80
371DBF18B908A5455B509831CC75BED00FDC2CA75F3006549FA8C58E3D7F1784
4CA58038ECEAC162EEE6F062A9A3CBCA0FEADE866F408A78D697553A327B34D6
4ED88E178EFF096BAA9F46546BEDA4CA974E262BF1B152E8E2011D7B7FFB9EF7
E90E10C6B9A6666C7B933F8CE87D52415796E148333C1E0FED657A864B4EE479
5EC58B7B0B1FC2A6EFEEC675FDE80DD6A4CBE325FD8011D52F4880F581979280
582C2AFEFFFAE76D332B9ECF6B0F4ACFC7D3C5EB3161E024634B5388E07F1972
9E3301D42B03E01D93C6D1BB7510A16000536E2A32E4524157967EBF1F5A1BDD
444DE7BEB5FE459E772AFC5F3C5C3E0BEFD4EE3174B27E4AE7A41E5B0C90ECCB
01430B0661DE4F8CA069ECCF69698FCA215D56BE11781B4DB14FE1F57B2F4AA7
1A57B1F1E8B378B66A35A26AE718C02F4A943E960FB011C09B9C57BF275261EE
28FCA3A916DE149B63260CE748FD412C3BB0101F35FEDB714EACB98DDC5BA990
9D3602740F90DDDD5B5E3B6822CA2B762235442F3C5F3035B735E399C34F60CB
B10DF4615BACB2A386D6A618CB8DABE397A7DA51FDC5098BBF7E0B949897DEE7
F9FEEF7C12383DA18CF6F8B45D376153F53AA82AC710E7B9AC37D6D2D64257E1
6D524F5211904E9FB1A60E9F8D48438B11B5654C92A504CEE59996D358503E07
F3F6CEC627E18F5DE7C8B9AC179AB28AA6BA0741565CB2EA792E7A24A94A3FA8
D93EB4A5ABAEC1905DFCD5639BB1AAF23184634D09E154A32AD4F3B4B5A2AD2B
280A18C9160336AF984DC764CF24F9C1320ECF5D5A9DB2855E5EE8C5AF339C63
0DD558BE7F112A3EDB9F30483E4AC375114D457C06696B304FB41160EEECC1FA
564D8B9734D5454A82B969F406D741C20F5FBB15314D04B284E009E3EB5BC0FA
68C256EBA4642580712ED16271ADE974A4249093E6911F43A36AE2C6F3991F39
DBA2B51BBFC46A3CB7939900C6B75455E355E1339152FAA0919B9AE1EBE40D3C
C029F1AAF371178BB4D5D3B5E64145B1AFBC9C9754A780046529B7A6B4A02016
511F276F6869AE6F155F7B39A869E2C88B8B92DBFC1598FB791C8FE779A4CBE6
F666FDC9EE01122B1F5B8F9041CB629A3A9D8C9D44ED6F51E677F32CCA8D946B
291FA4157FCB17C5CB6D691D471DC95D93C267645F4E5F852D7049D7E7FF0300
9DE8175D3157BEB60000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000080000000800806000000C33E61
CB000000097048597300001D8700001D87018FE5F16500000A4F694343505068
6F746F73686F70204943432070726F66696C65000078DA9D53675453E9163DF7
DEF4424B8880944B6F5215082052428B801491262A2109104A8821A1D91551C1
114545041BC8A088038E8E808C15512C0C8A0AD807E421A28E83A3888ACAFBE1
7BA36BD6BCF7E6CDFEB5D73EE7ACF39DB3CF07C0080C9648335135800CA9421E
11E083C7C4C6E1E42E40810A2470001008B3642173FD230100F87E3C3C2B22C0
07BE000178D30B0800C04D9BC0301C87FF0FEA42995C01808401C07491384B08
801400407A8E42A600404601809D98265300A0040060CB6362E300502D006027
7FE6D300809DF8997B01005B94211501A09100201365884400683B00ACCF568A
450058300014664BC43900D82D00304957664800B0B700C0CE100BB200080C00
305188852900047B0060C8232378008499001446F2573CF12BAE10E72A000078
99B23CB9243945815B082D710757572E1E28CE49172B14366102619A402EC279
99193281340FE0F3CC0000A0911511E083F3FD78CE0EAECECE368EB60E5F2DEA
BF06FF226262E3FEE5CFAB70400000E1747ED1FE2C2FB31A803B06806DFEA225
EE04685E0BA075F78B66B20F40B500A0E9DA57F370F87E3C3C45A190B9D9D9E5
E4E4D84AC4425B61CA577DFE67C25FC057FD6CF97E3CFCF7F5E0BEE22481325D
814704F8E0C2CCF44CA51CCF92098462DCE68F47FCB70BFFFC1DD322C44962B9
582A14E35112718E449A8CF332A52289429229C525D2FF64E2DF2CFB033EDF35
00B06A3E017B912DA85D6303F64B27105874C0E2F70000F2BB6FC1D428080380
6883E1CF77FFEF3FFD47A02500806649927100005E44242E54CAB33FC7080000
44A0812AB0411BF4C1182CC0061CC105DCC10BFC6036844224C4C24210420A64
801C726029AC82422886CDB01D2A602FD4401D34C051688693700E2EC255B80E
3D700FFA61089EC128BC81090441C808136121DA8801628A58238E08179985F8
21C14804128B2420C9881451224B91354831528A542055481DF23D720239875C
46BA913BC8003282FC86BC47319481B2513DD40CB543B9A8371A8446A20BD064
74319A8F16A09BD072B41A3D8C36A1E7D0AB680FDA8F3E43C730C0E8180733C4
6C302EC6C342B1382C099363CBB122AC0CABC61AB056AC03BB89F563CFB17704
128145C0093604774220611E4148584C584ED848A8201C243411DA0937090384
51C2272293A84BB426BA11F9C4186232318758482C23D6128F132F107B8843C4
37241289433227B9900249B1A454D212D246D26E5223E92CA99B34481A2393C9
DA646BB20739942C202BC885E49DE4C3E433E41BE421F25B0A9D624071A4F853
E22852CA6A4A19E510E534E5066598324155A39A52DDA8A15411358F5A42ADA1
B652AF5187A81334759A39CD8316494BA5ADA295D31A681768F769AFE874BA11
DD951E4E97D057D2CBE947E897E803F4770C0D861583C7886728199B18071867
197718AF984CA619D38B19C754303731EB98E7990F996F55582AB62A7C1591CA
0A954A9526951B2A2F54A9AAA6AADEAA0B55F355CB548FA95E537DAE46553353
E3A909D496AB55AA9D50EB531B5367A93BA887AA67A86F543FA47E59FD890659
C34CC34F43A451A0B15FE3BCC6200B6319B3782C216B0DAB86758135C426B1CD
D97C762ABB98FD1DBB8B3DAAA9A13943334A3357B352F394663F07E39871F89C
744E09E728A797F37E8ADE14EF29E2291BA6344CB931655C6BAA96979658AB48
AB51AB47EBBD36AEEDA79DA6BD45BB59FB810E41C74A275C2747678FCE059DE7
53D953DDA70AA7164D3D3AF5AE2EAA6BA51BA1BB4477BF6EA7EE989EBE5E809E
4C6FA7DE79BDE7FA1C7D2FFD54FD6DFAA7F5470C5806B30C2406DB0CCE183CC5
35716F3C1D2FC7DBF151435DC34043A561956197E18491B9D13CA3D5468D460F
8C69C65CE324E36DC66DC6A326062621264B4DEA4DEE9A524DB9A629A63B4C3B
4CC7CDCCCDA2CDD699359B3D31D732E79BE79BD79BDFB7605A785A2CB6A8B6B8
6549B2E45AA659EEB6BC6E855A3959A558555A5DB346AD9DAD25D6BBADBBA711
A7B94E934EAB9ED667C3B0F1B6C9B6A9B719B0E5D806DBAEB66DB67D61676217
67B7C5AEC3EE93BD937DBA7D8DFD3D070D87D90EAB1D5A1D7E73B472143A563A
DE9ACE9CEE3F7DC5F496E92F6758CF10CFD833E3B613CB29C4699D539BD34767
1767B97383F3888B894B82CB2E973E2E9B1BC6DDC8BDE44A74F5715DE17AD2F5
9D9BB39BC2EDA8DBAFEE36EE69EE87DC9FCC349F299E593373D0C3C843E051E5
D13F0B9F95306BDFAC7E4F434F8167B5E7232F632F9157ADD7B0B7A577AAF761
EF173EF63E729FE33EE33C37DE32DE595FCC37C0B7C8B7CB4FC36F9E5F85DF43
7F23FF64FF7AFFD100A78025016703898141815B02FBF87A7C21BF8E3F3ADB65
F6B2D9ED418CA0B94115418F82AD82E5C1AD2168C8EC90AD21F7E798CE91CE69
0E85507EE8D6D00761E6618BC37E0C2785878557863F8E7088581AD131973577
D1DC4373DF44FA449644DE9B67314F39AF2D4A352A3EAA2E6A3CDA37BA34BA3F
C62E6659CCD5589D58496C4B1C392E2AAE366E6CBEDFFCEDF387E29DE20BE37B
17982FC85D7079A1CEC2F485A716A92E122C3A96404C884E3894F041102AA816
8C25F21377258E0A79C21DC267222FD136D188D8435C2A1E4EF2482A4D7A92EC
91BC357924C533A52CE5B98427A990BC4C0D4CDD9B3A9E169A76206D323D3ABD
31839291907142AA214D93B667EA67E66676CBAC6585B2FEC56E8BB72F1E9507
C96BB390AC05592D0AB642A6E8545A28D72A07B267655766BFCD89CA3996AB9E
2BCDEDCCB3CADB90379CEF9FFFED12C212E192B6A5864B572D1D58E6BDAC6A39
B23C7179DB0AE315052B865606AC3CB88AB62A6DD54FABED5797AE7EBD267A4D
6B815EC1CA82C1B5016BEB0B550AE5857DEBDCD7ED5D4F582F59DFB561FA869D
1B3E15898AAE14DB1797157FD828DC78E51B876FCABF99DC94B4A9ABC4B964CF
66D266E9E6DE2D9E5B0E96AA97E6970E6E0DD9DAB40DDF56B4EDF5F645DB2F97
CD28DBBB83B643B9A3BF3CB8BC65A7C9CECD3B3F54A454F454FA5436EED2DDB5
61D7F86ED1EE1B7BBCF634ECD5DB5BBCF7FD3EC9BEDB5501554DD566D565FB49
FBB3F73FAE89AAE9F896FB6D5DAD4E6D71EDC703D203FD07230EB6D7B9D4D51D
D23D54528FD62BEB470EC71FBEFE9DEF772D0D360D558D9CC6E223704479E4E9
F709DFF71E0D3ADA768C7BACE107D31F761D671D2F6A429AF29A469B539AFB5B
625BBA4FCC3ED1D6EADE7AFC47DB1F0F9C343C59794AF354C969DAE982D39367
F2CF8C9D959D7D7E2EF9DC60DBA2B67BE763CEDF6A0F6FEFBA1074E1D245FF8B
E73BBC3BCE5CF2B874F2B2DBE51357B8579AAF3A5F6DEA74EA3CFE93D34FC7BB
9CBB9AAEB95C6BB9EE7ABDB57B66F7E91B9E37CEDDF4BD79F116FFD6D59E393D
DDBDF37A6FF7C5F7F5DF16DD7E7227FDCECBBBD97727EEADBC4FBC5FF440ED41
D943DD87D53F5BFEDCD8EFDC7F6AC077A0F3D1DC47F7068583CFFE91F58F0F43
058F998FCB860D86EB9E383E3939E23F72FDE9FCA743CF64CF269E17FEA2FECB
AE17162F7EF8D5EBD7CED198D1A197F29793BF6D7CA5FDEAC0EB19AFDBC6C2C6
1EBEC97833315EF456FBEDC177DC771DEFA3DF0F4FE47C207F28FF68F9B1F553
D0A7FB93199393FF040398F3FC63332DDB000000206348524D00007A25000080
830000F9FF000080E9000075300000EA6000003A980000176F925FC546000014
43494441547801EC5D0B7C94C5B53FDF6E1E9B077990100851086F89162B82A5
E2056A11B52DD4FA53DB5F2B5EEEAF28FEE4F625BDEA45AAB522526DEBA3B50F
ADD64795DA681545E5E16D15AD957783F2C8034840121292902C79EC6E92DD7B
CEECCE3EBED77CBB4960373BC3EFCBCC9C993973E67FCE7766BE6F663F149FCF
0732242F02B6E41DBA1C3921200D20C9ED401A803480244720C9872F3D803480
244720C9872F3D803480244720C9872F3D803480244720C9872F3D8034802447
20C9872F3D803480244720C9872F3D40921B408A68FC2B9E7C4F1E18108114C7
E5BFBC659E62269EF40066E8244199D003700CD0927852C60980007A6E4B524A
0F6009A6A15B491AC0D0D5ADA591599E02E4D9514B78265C25E901124E65032B
B0750F30B0FD4A6E71828065030090AF03E24467032A866503906B8001C53D6E
98C93540DCA8E2EC0862DD039C1DF964AF838C806503305B023434B7C3CB9B76
C0A735C7C1EBF5C1B4C9E7C037AF9C09C585B91AF17F7EEC7F353449082170E7
B90F8632815434F86A1A0B08960DC068097802957FEF6FD74397CB13EC6AE7BE
5AF8B4FA38DCFFDFD7C0281D23085694090D026A9C8DF0DD8737DBCF96F71FDF
7EAF01E8CE0F573E1F91CBD303EB366EE75919C7888011BEDDEE1EE67563641B
6C66DD03A84D33C082EE74A34065F2E9C1081D7DBA1A2F337CF7567DD66F7CFB
ED01F48721A989828065032007A0779D3FB1C470AC9F9B748EA68D616559C010
50631C2DBEBCBD5538C506403E89F925CE3A32FEE6553321D391A6E98F68375C
3903E991F5351525418540245E846174F806DA07F5A662AFCA0AD700C48E827A
6EF253018A86E7C03DB72E82F2CD3B60FFE106462E1B5F0CD72F9809230B720D
DBF1F6328E44408D3361180BBE5C6F91DCB539A10158D1203DEA7DEFDBF3B5DC
75282B4AD6E85025C90C8168F00DF2515B52B020322134006E493C8E6C2E73F1
8A80557D090DC08A07885710925AAE81F2004110AD9A54B0814C240202420FC0
BF2328F59F08EA0CC9C8F516A2E8A7C48F81FAED2475882020F4007C0D60714A
1922B00C8161585498D00042AE3F941A02F00CF92158D596D000FC6FF2F85F7D
DC68CBF26F5B76E28BA07A761EE0027C3D7CED153374B7821F6BB85B9F89A432
047E50FC800689707CA9B06CFC68437C438DAD9980D000829EC4805F634B3BAC
79F2CD882DE1DD07EA60DFA17AF6068BDE64C91005022A9C8DF03D8037DBAA65
8BD8DB563DEE41BDE91586D12C2C0249229FE68DBE9F0AF00ADEF97AE701DC78
1E805E0FF37A3C0EEB5B267510E038F1D8085F3A0F4065BC9E3AF6FB6CA29A07
A107603D98F0D88F77BA51302B336A23E99108986148A7820C8358F7ACA9D000
FCF7BEF91AC050082CB02887198BA42A8B162FA3FA5C6F22F0C45300F5607295
4D186DD807DBCB56B735AC2D0B18022ABCA2C657D55E84AAD80002DA57F3E5F9
6BAF303E0FF08DF93334B6231228D9CB39AE3C260C8DCE03E8E1CBDB85EE5A73
44850640AB49B315259D07B86BE942B868EA58C8C043208EF45496269A7C0230
07DF4A2961188E2F614C588BF015E98DF72D5C03F059DCD40850C865377C99F3
0CC67A6D9617699F73830D6442F7662B8A02DF1084E40BC441680021255A6328
EE52D638130884F466DE9BD000821EC09C8F2C8D3B04ACDDB06203B0C627EE86
9FF40259D49BD000F8F3A4559792F4C0C709005C6F2271840620DFE488208CD3
F201F700713A4E29963E0203EF012C5A94BE38927AC611B0A82FF114109803CC
F8D196E51B7FDF0595741E00170B532794C0A2CB2FD67D11F487E655671C8B44
EA7059E16A8DB8E1F852E1143C0F60846FA8B199C642B58406203A5CD8D4E284
5F3CB301BAC3BE0F5071B00E0EA231DCB974111415E4847A93A9A81130C2B7F2
483DDCF15D637C457AE382085F05F38AC450EF5AFF7F3B2294CFEBD37980D7DF
C5F300AA76BC5CC6FA08A8F132C2D785E701A84C5D9FE7F5B96BA9420FA0FB6E
328CCFC123FEDF03869182C98368A532F40F01337CE9549061B0F8DC2E34003E
93F0D8B043838258DB19B01BF2E468F132AA6F445703289E02C8924CAC69CAB8
6235CF60FE3C5CACC8D03F0462C657A0372E95D8000235393F75FCF52FCF60DB
C09C218F69DB72E1E5781E20603F3CE6E532D64780E3C463C290B05407237C79
3B757DA3BCD000448B8AC2FC1CB87DC95761DA943190919E06E969A92C4D343A
2B2043FF10200CC3F1258C096B11BE22BD71A9846B005ED12CA6FDEAEF5E77B9
599560D9D2E1F707D332610D8168F0B5C631544B68006449140251A8A54CC535
025C6F22218506206220CBC508787D5E38D4B21F761FFF086ADB6AA0F654251C
771E851E6F0FB475373306791985906A4B85929C31509A3F054AF326C2F4924B
61424119D814E14C6D2884725FE47F1AE6BB37F2F9406C00DC031876210BF410
20A5EFA9FF176CAC2E877FD6BE1B54B45E5DA2714338D9D900FF6ED816AC4686
31BB743E5C35E97AB868F417AD1B8345972D348090BD845241E964428380A7D7
0D1BAB5E81E7F73C0EF57897F390926E87F461B848CE4E8114075E98B7D915B0
A5F8EF6E6FAF17BC7D3EE875F741AFAB17DC1D789DF630C378EBC05F80AED1E8
1D6EBAE8FB70D5E4EB202D259DB3D68DAD6A4B68007CF2B76850BAC2240B7113
2AFE898F57434B57231B322939ABD001590519A874BB290C640836D406B5819C
34C82EF257EF75F54167733774B6B89841AD7DFFC7F0D48E8761F9AC5570251A
8261B0A830A10158B524434192A0E0B8B316D6BEBF82CDF134DCB4AC54C829CE
84CCE18E7E8F9E0C27F79C6C7675B5BAC0D9D0052D9D8DF0B3BF7F0F3654AE83
BBE6FE12D70DA59A7EACEA4DBCBA204BC28B18CA4B8BC1969AD7E0A6F2F94CF9
7417178CCF8551E70F1F10E5ABB54A0645BCA90FEA8B1695D437C9A0D64DF00D
9C9A892A2FF400C1FAD48341686A6D87B7DFDB0D55B50DD8AF0FA68C1B0D5F99
371D5F04E56A5A3CDB7E8F869688041AE78EBD3B60EF810A267E6681038697E6
B0797DB0C743D34A467E3AB4D63AA1ABA5137EFAEE6D50DDBC0F965DB2D2FA22
3120A4D000F8F3A491FE4FB63AE1F1E7DF8ED812FEA4EA281A433DFC70C94218
3104DF06FA7085BF75FB07507DA40A144581FCD261903D2263B0F51EC19F1690
851372A103D70BA76A4FC38BFF7E025ABB4EC21D731E86147B1ABB11231A1864
C4538041434E7EEBBD5D11CAE774B7A71736FC6327CF0E99986E88F7B7BDEF57
3E2A61C4E4BC33AEFC7030C9F04806056579A7EAAFF0E0D615782ACB1B5EC534
2DF4006C2E4116386EDD508D77BA51F04F0946A5894927B75F535B038ACDAFFC
F4EC54D3BBADC8310A9A5C270675B0E939A9CC084E56B6C1667C1229CC1C890A
2B637D4E481F61DAB7D00390DE0D746FCA7828161EAAAB61733EB9FDC289B990
8EAB7DCDEA8B0316889FFBC29B70DD398B011FF2847545BCCCCA49169289647B
09A783469BFFEB21223D080D804B4DCF017AFF26951AEFF9D36250DD462450BC
963B3B9CF0E1CE7F32F1F2C664B3973AE4154557564A367C7FCA4AF8DD8C7530
2E6B92B0BE889F5939BD68CA3B379BC958655F07DDCA49219C4203E01D1A71FA
EABC8BD936B0BA9CB62DAF9E3B5D4D4ED8FC07B8E8EBE9F1B0C7BBACC2E8177C
5373A7C133B35E8365936E87349BF95BBCFE8094856B027A42E8051754DA5F64
EB813E7716F04BCD5B6800DC64B921A8E3E179C360F9E2AFC00593C6E0B701FC
E701284D343A2BA0AEAF162011F234E73734D5B3676F7687A90765960F1BA05D
B1C38DA537C3F35F7C032ECE9F25761F667C4DCAF2C70C63B2B629D5D4FBE230
113449F12250D3444BA047BDC5DF98A72DD0A1DC38EC3E1D6AFC923C7D6EF8D6
DE2F3001734BB2D8E28FB0EF4F28C91C038FCEF813BC53FF3AFCFAE083E0EC69
EF0F3B4D5B5AA092ACA7EA4E834FF13D8415CAF172692A2241E801E8B1875D58
59B5BE498AFCE6EA57F0F9BA0952335220331F5FED460B821EEA01DAD5A3AF81
75976D8405C50BA3E72B9083644DC54D270CA3C0D1FE9FB5E0FFA716476800C1
06820EA3062601F879BD5E7CC1F21B0641F6C80C1C62F4FF82F8192472D3F2E1
9E690FC323339F8651192531F4602C53F6A8C05AC5A7DC81DDEBEA5A971829AB
5F5309A0AF01B7C14F1AB743C3E93AB0A7D9202317176EB1801009A6616E66C1
6CF8F3651BE03BE396821DFFC5D4974A3E929964C7307E9C23EF32BC34FD0B0D
80AF35342D9380B0B1EA6536CACCBC185C3F5746143839EC1970DB94FF81A72F
7D15CECBB960408C80C98E32F87CB6FFC24B238D96A2A9E21F091F4F32C51F1D
DDC2D070E4F9DFAD07D7437C5D6421D6C069813029672A3C756939FCB0EC6E48
B739FC6B300B7DE9C947B25340BD7D4DC1FFD85B1DC406904C1A0F1BEB613CC3
E774B5823DD5E63FA4A1466E90F3740EF0FAD29B60DDDC8D7069D1BC987BA303
2634063C1958884CA6A919090DC0788931B44B2A4E7CCCB04AC557AC7C1A8C25
56031E6D7E644631FC62E693B07AFA6390975610932C340616ECB6B9EAFEC5EF
0168D482D08C5BC29B3ED80387EA1AD8F701E8F5F095FF711114EA6C05FFA5F3
A7026EF151BCB5712B13240D1FFF18EA6759ACCB8BAF864B0A67C3E3FBD7C25B
C75E8D6AC72F2D33055C6D6ED24D2C1E20B016413BD0BB03E83CC0EF5E7C07F6
571F05FA49784F4F2F4B3FF1C25B4065EA36671947CBDD3B4F3B59DD145A4587
4D0D51A72DF728AE989D9A032B2F5C038FCF7A0EC6648DB32C570A4E0114701A
98ACEEC55FA2A686E7B906C36961E9CD78E7BBDC9E308A3FE94143D8B475B786
9E28848ECED34C545B9A3D6A9D87DBCB608CF7E2C259F0C2BC3761C9E4DB2005
7F4B10DE9F5E9AC61008A53CC163B101F09A06718DC979801A9C121235F479FB
98E878D7E8BB3E7E6388E24102803694969DF7237876CEEBF0F9E1334C656463
F0CB81CFB391416800A1470BFD3E22D9A972688E6A7C5435E236EB72BB986C74
D2463D8668F2833DC0093993E1B7B35F843B2FBC1F32EDD9BAB2D21802A18827
782C34005ED1289E38D6F83CC0C4B1C546CD12801E008D4E57E9F955ABB43334
524F9F0798D73292CB2F078D2622089F02C80350F0FF8D68CB3257E06AFFF0B1
139A75006D0D2F9833DDB09D96537C511CE9E978D6B19BFD2F687400335E4355
FB0158BB6715EC3B55612822FDE22810FC3F44E4398C85061056573759807BFE
B77CFB6AD8828BC1C347FD73FEF831C540864165891AEC36FFC2C9DBE7C52DE0
7E3BCA018781B6A9FF70E05178A9FA69E8F3F9D72B469DF870532B10FCF31ACF
612C3600EE01027158DB60B2000F857C6BE19C609E27B8F7E0798AAF73DC1B9E
8DDBF4B6617BE193AE6DD0E7F1823DF0FBBD7811765BD387F0E0EE5550DF79CC
9248BDEEA001D4AA1B080D20E83CD42D8778BE24773C7CD24806D0073E7A1914
07A1CD7D0A1ED9FB00BC5DF75A54D2D01828A02EABD40DC523E31E40DD7288E7
27167C0E47B80E7AF097BA8E5CFF86CAD91CF286BA57E1918A07C0E9698B5A0C
1A030545F1ED5637161B006F9164AEA06CC44C36F29E6EF4006771EC9F751C85
35BB56C2F6A68FB826A28E690C14943EF01F6B0EE32034003E8F9F450CC2C43D
73C9D2FCA990E728843657339EA8C57580FF60C519138016762F543E054FEE7B
0C68C1176BA0350C7D7B0043135E7BD57CE26F79AB96F02CE62F39773EEBDDDD
81AFBAC90DC472C520FFBED60AB871F3D7E037153F074F2F2EDC63E937D086C9
8E32A0F46F78F1B0A83A4803502312965F30F106967377F4B0F719E405A3BDC2
D809935DBD5DF0F09EFB60C9BBD74255DBC1A8FBD2938D64A760577CCFE1A591
413805685A2411A1ACE812281E36969D0BF42090F4E187C10AEF1DDF020FEDBA
171ABB066EFFC4D3D9C3DC3F9EDCA841B93FD4935D7A003D54C268D75FB09CE5
BA713F3DB42F8290A28BB57285B1D24DB6B84EC28A0F96C1ED5B6F86139DF596
785AE997EA90CC146C3EE5219F17F734F0520769006A4454799A060A328BA1AF
C70BE405A2F6CB2A7E3C4B3FE17EB5E625B8E6CD2FC13F8E6D8A9EAF9EBF0FA3
91AC2433923E1BEB69FD135E40973A589E02EE7BF4CFEAB64993CF4FFB12B464
BD045DA7DCEC0722F4CB9BFE849AB64A7860FB4AA868DED51F36866D7D78F893
64A58092FE1823FF8B004689FC63D900229B2557AEC0330D9AD23F0667CA61E8
C40F3565E1E7606209F438F7C74F7F0DCFEEFF3DFB48642C3CACB4A12F8A9111
E4F48E27995F366BA3D05C21831681716BF3D5C4529C4D2B90989391978EDFFB
B3B620DC73631DE3B3A3F15FB066DB4AA8751E56F31DD03CADFA0373BF13C07B
2132AF0DEFE0C85DA7C2B316368322AA2775A616DDE952BC5DFEDADDEEC65FDF
2AEC838F22444E7B9CF0ABDDAB61FDA1F2A80E728AF8EA95D3072649360A0159
6B59C6E48F9C024CC0D1292A4787B91AC15DD5D5E2C68F40E2F375E8BC9D4E75
80AFAF9F0BADAE16DDB28124D2860FC944AB3E26A3C27E112CEC421A8010224D
859FF814188928DFDCD9EC661F6330FB0A684BF7E02B9FBE26DA8D8B3EF678A8
C05368043FD1486D40900660004CADBBCDA084916F1DEB184EB7DACD5DA75CE0
C04FB30CE64B223341E8658F0BBF29CCEE7C547E9DABF556B3FAEA32F91E408D
88B53CEDAEDC822BE83504BCCBE9C1C72E5A7913190967E0A2BEA84FEA9BBA63
B2A04CD839096139480F60192ADD8A77FB40D989FBECCFA01BCEEBF0B8F0E351
A9EC5D816EED0122F674D397C4717F827EECA9401BFE5982DE687D2CECA50788
05B5C836AF29BDDECFE35DB88514E26AF7E0D7BD5DC0F6E007D819104FE24D7D
30E5639FAC6F8098944FC3900610A9CC587375D870013E1DDC8077E411DA7F77
E1E358C7C96E76A7B257B2680CF4CA25DA8BDAD2DD4EBC8827DBDBC73E585FD8
27F64B7DC71CA401C40C9D6EC3F25257EB6454F2522C3D4877A9A7AB07E833EF
F4CD7F97D30D3D98EFC5CFE8D269639AC7831B3B98261A95511DAA4B6DA82DF1
60773CF144DED407F22FD795204AA25C0344099885EAF4DEFD69BAF0D7B8B3F1
97F98BD12B2C420516D3E35A2FF459601151053FC18E8739C0F7824D513447BA
226AC690910610036851342185D1752B3A83329BE29B83B3C0F98A4F99824631
16E9B97865E2453F42388D573B2ABB0E3FED56892E7E9FD7A76CC57DA7FD481F
B420F702060DDAC4602CD70089A1A74193521AC0A0419B188CA50124869E064D
CAFF1F00174B7C35117949D60000000049454E44AE426082}
end>
end>
Left = 376
Top = 136
end
end
| 77.181767 | 79 | 0.806959 |
c3c402767a9c548928e5e78c590980caaced25c8 | 2,207 | pas | Pascal | Libraries/TBCEditor/Source/BCEditor.Editor.Search.Map.Colors.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| 62 | 2016-01-20T16:26:25.000Z | 2022-02-28T14:25:52.000Z | Libraries/TBCEditor/Source/BCEditor.Editor.Search.Map.Colors.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| null | null | null | Libraries/TBCEditor/Source/BCEditor.Editor.Search.Map.Colors.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| 20 | 2016-09-08T00:15:22.000Z | 2022-01-26T13:13:08.000Z | unit BCEditor.Editor.Search.Map.Colors;
interface
uses
System.Classes, Vcl.Graphics, BCEditor.Consts, BCEditor.Types;
type
TBCEditorSearchMapColors = class(TPersistent)
strict private
FActiveLine: TColor;
FBackground: TColor;
FForeground: TColor;
FOnChange: TBCEditorSearchChangeEvent;
procedure SetActiveLine(AValue: TColor);
procedure SetBackground(AValue: TColor);
procedure SetForeground(AValue: TColor);
public
constructor Create;
procedure Assign(ASource: TPersistent); override;
published
property ActiveLine: TColor read FActiveLine write SetActiveLine default clSearchMapActiveLine;
property Background: TColor read FBackground write SetBackground default clLeftMarginBackground;
property Foreground: TColor read FForeground write SetForeground default clSearchHighlighter;
property OnChange: TBCEditorSearchChangeEvent read FOnChange write FOnChange;
end;
implementation
constructor TBCEditorSearchMapColors.Create;
begin
inherited;
FActiveLine := clSearchMapActiveLine;
FBackground := clLeftMarginBackground;
FForeground := clSearchHighlighter;
end;
procedure TBCEditorSearchMapColors.Assign(ASource: TPersistent);
begin
if Assigned(ASource) and (ASource is TBCEditorSearchMapColors) then
with ASource as TBCEditorSearchMapColors do
begin
Self.FBackground := FBackground;
Self.FForeground := FForeground;
Self.FActiveLine := FActiveLine;
if Assigned(Self.FOnChange) then
Self.FOnChange(scRefresh);
end
else
inherited Assign(ASource);
end;
procedure TBCEditorSearchMapColors.SetActiveLine(AValue: TColor);
begin
if FActiveLine <> AValue then
begin
FActiveLine := AValue;
if Assigned(FOnChange) then
FOnChange(scRefresh);
end;
end;
procedure TBCEditorSearchMapColors.SetBackground(AValue: TColor);
begin
if FBackground <> AValue then
begin
FBackground := AValue;
if Assigned(FOnChange) then
FOnChange(scRefresh);
end;
end;
procedure TBCEditorSearchMapColors.SetForeground(AValue: TColor);
begin
if FForeground <> AValue then
begin
FForeground := AValue;
if Assigned(FOnChange) then
FOnChange(scRefresh);
end;
end;
end.
| 25.964706 | 100 | 0.76937 |
c3132e2f87d62c2c4c3804c33a06756f2192b8d7 | 6,120 | pas | Pascal | Libraries/Spring4D/Tests/Source/Spring.TestUtils.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| 62 | 2016-01-20T16:26:25.000Z | 2022-02-28T14:25:52.000Z | Libraries/Spring4D/Tests/Source/Spring.TestUtils.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| null | null | null | Libraries/Spring4D/Tests/Source/Spring.TestUtils.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| 20 | 2016-09-08T00:15:22.000Z | 2022-01-26T13:13:08.000Z | {***************************************************************************}
{ }
{ Spring Framework for Delphi }
{ }
{ Copyright (c) 2009-2018 Spring4D Team }
{ }
{ http://www.spring4d.org }
{ }
{***************************************************************************}
{ }
{ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 }
{ }
{ Unless required by applicable law or agreed to in writing, software }
{ distributed under the License is distributed on an "AS IS" BASIS, }
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{ See the License for the specific language governing permissions and }
{ limitations under the License. }
{ }
{***************************************************************************}
unit Spring.TestUtils;
{$I Spring.Tests.inc}
interface
uses
SysUtils,
TestFramework;
type
TAbstractTestHelper = class helper for TAbstractTest
private
function GetExpectedException: ExceptionClass; inline;
protected
{$IFNDEF DELPHIXE2_UP}
procedure CheckEquals(expected, actual: UInt64; msg: string = ''); overload;
{$ENDIF}
public
procedure CheckEqualsString(const expected, actual: string; msg: string = '');
procedure CheckException(expected: ExceptionClass; const method: TProc; const msg: string = '');
procedure Pass; inline;
function RegisterExpectedMemoryLeak(p: Pointer): Boolean; inline;
procedure StartExpectingException(e: ExceptionClass);
property ExpectedException: ExceptionClass
read GetExpectedException write StartExpectingException;
end;
TTestCase<T: class, constructor> = class(TTestCase)
private type
TInterfacedObjectAccess = class(TInterfacedObject);
private
fSUT: T;
strict protected
property SUT: T read fSUT;
protected
procedure SetUp; override;
procedure TearDown; override;
end;
implementation
uses
Math,
StrUtils;
{$IFNDEF DELPHIXE2_UP}
function ReturnAddress: Pointer; inline;
begin
Result := CallerAddr;
end;
{$ENDIF}
{$REGION 'TAbstractTestHelper'}
{$IFNDEF DELPHIXE2_UP}
procedure TAbstractTestHelper.CheckEquals(expected, actual: UInt64; msg: string);
begin
FCheckCalled := True;
if expected <> actual then
FailNotEquals(UIntToStr(expected), UIntToStr(actual), msg, ReturnAddress);
end;
{$ENDIF}
procedure TAbstractTestHelper.CheckEqualsString(const expected, actual: string; msg: string); //FI:O801
procedure EqualsFail(index: Integer); overload;
const
ContextCharCount = 20;
begin
if (msg <> '') and not EndsText(sLineBreak, msg) then
msg := msg + sLineBreak;
msg := msg +
'Strings differ at position ' + IntToStr(index) + sLineBreak +
'Expected: ' + ReplaceStr(Copy(expected, Max(1, index - ContextCharCount), ContextCharCount * 2), sLineBreak, ' ') + sLineBreak +
'But was: ' + ReplaceStr(Copy(actual, Max(1, index - ContextCharCount), ContextCharCount * 2), sLineBreak, ' ') + sLineBreak +
'----------' + DupeString('-', Min(ContextCharCount, index - 1)) + '^';
Fail(msg);
end;
var
i: Integer;
begin
FCheckCalled := True;
for i := 1 to Min(Length(expected), Length(actual)) do
if expected[i] <> actual[i] then
EqualsFail(i);
if Length(expected) <> Length(actual) then
EqualsFail(Min(Length(expected), Length(actual)) + 1);
end;
procedure TAbstractTestHelper.CheckException(expected: ExceptionClass;
const method: TProc; const msg: string);
begin
FCheckCalled := True;
try
method;
except
on E: Exception do
begin
if not Assigned(expected) then
raise
else if not E.InheritsFrom(expected) then
FailNotEquals(expected.ClassName, E.ClassName, msg, ReturnAddress)
else
expected := nil;
end;
end;
if Assigned(expected) then
FailNotEquals(expected.ClassName, 'nothing', msg, ReturnAddress);
end;
function TAbstractTestHelper.GetExpectedException: ExceptionClass;
begin
Result := FExpectedException;
end;
procedure TAbstractTestHelper.Pass;
begin
FCheckCalled := True;
end;
function TAbstractTestHelper.RegisterExpectedMemoryLeak(p: Pointer): Boolean;
{$IFNDEF MSWINDOWS}
var
memMgrEx: TMemoryManagerEx;
{$ENDIF}
begin
{$IFDEF MSWINDOWS}
Result := System.RegisterExpectedMemoryLeak(p);
{$ELSE}
GetMemoryManager(memMgrEx);
if Assigned(memMgrEx.RegisterExpectedMemoryLeak) then
Result := memMgrEx.RegisterExpectedMemoryLeak(p)
else
Result := False;
{$ENDIF}
end;
procedure TAbstractTestHelper.StartExpectingException(e: ExceptionClass);
begin
StopExpectingException;
FExpectedException := e;
FCheckCalled := True;
end;
{$ENDREGION}
{$REGION 'TTestCase<T>'}
procedure TTestCase<T>.SetUp;
begin
inherited SetUp;
fSUT := T.Create;
{$IFNDEF AUTOREFCOUNT}
if fSUT.InheritsFrom(TInterfacedObject) then
TInterfacedObjectAccess(fSUT)._AddRef;
{$ENDIF}
end;
procedure TTestCase<T>.TearDown;
begin
{$IFNDEF AUTOREFCOUNT}
if fSUT.InheritsFrom(TInterfacedObject) then
TInterfacedObjectAccess(fSUT)._Release
else
{$ENDIF}
fSUT.Free;
inherited TearDown;
end;
{$ENDREGION}
end.
| 30.29703 | 136 | 0.590033 |
f1ec101a2092ece9bf568df69546226a45d080eb | 2,602 | pas | Pascal | easyexample.pas | Zawullon/fpnativeapi | 98c3ba53eb5974fa3cb09a5568d6d7218fd21dc0 | [
"MIT"
]
| 14 | 2017-07-10T17:47:32.000Z | 2021-10-04T20:43:39.000Z | easyexample.pas | Zawullon/fpnativeapi | 98c3ba53eb5974fa3cb09a5568d6d7218fd21dc0 | [
"MIT"
]
| 6 | 2016-12-30T21:40:18.000Z | 2021-03-23T19:52:20.000Z | easyexample.pas | Zawullon/fpnativeapi | 98c3ba53eb5974fa3cb09a5568d6d7218fd21dc0 | [
"MIT"
]
| 3 | 2017-08-15T12:19:59.000Z | 2020-11-17T00:26:19.000Z | unit EasyExample;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, V8AddIn, fpTimer, FileUtil, LazUTF8;
type
{ TTimerThread }
TTimerThread = class (TThread)
public
Interval: Integer;
OnTimer: TNotifyEvent;
procedure Execute; override;
end;
{ TAddInEasyExample }
TAddInEasyExample = class (TAddIn)
private
FIsEnabled: Boolean;
FTimer: TTimerThread;
procedure MyTimerProc(Sender: TObject);
public
function GetIsEnabled: Variant;
procedure SetIsEnabled(AValue: Variant);
function GetIsTimerPresent: Variant;
procedure Enable;
procedure Disable;
procedure ShowInStatusLine(Text: Variant);
procedure StartTimer;
procedure StopTimer;
destructor Destroy; override;
function LoadPicture(FileName: Variant): Variant;
procedure ShowMessageBox;
end;
implementation
{ TTimerThread }
procedure TTimerThread.Execute;
begin
repeat
Sleep(Interval);
if Terminated then
Break
else
OnTimer(Self);
until False;
end;
{ TAddInEasyExample }
procedure TAddInEasyExample.MyTimerProc(Sender: TObject);
begin
ExternalEvent('EasyComponentNative', 'Timer', DateTimeToStr(Now));
end;
function TAddInEasyExample.GetIsEnabled: Variant;
begin
Result := FIsEnabled;
end;
procedure TAddInEasyExample.SetIsEnabled(AValue: Variant);
begin
FIsEnabled := AValue;
end;
function TAddInEasyExample.GetIsTimerPresent: Variant;
begin
Result := True;
end;
procedure TAddInEasyExample.Enable;
begin
FIsEnabled := True;
end;
procedure TAddInEasyExample.Disable;
begin
FIsEnabled := False;
end;
procedure TAddInEasyExample.ShowInStatusLine(Text: Variant);
begin
SetStatusLine(Text);
end;
procedure TAddInEasyExample.StartTimer;
begin
if FTimer = nil then
begin
FTimer := TTimerThread.Create(True);
FTimer.Interval := 1000;
FTimer.OnTimer := @MyTimerProc;
FTimer.Start;
end;
end;
procedure TAddInEasyExample.StopTimer;
begin
if FTimer <> nil then
FreeAndNil(FTimer);
end;
destructor TAddInEasyExample.Destroy;
begin
if FTimer <> nil then
FreeAndNil(FTimer);
inherited Destroy;
end;
function TAddInEasyExample.LoadPicture(FileName: Variant): Variant;
var
SFileName: String;
FileStream: TFileStream;
begin
SFileName := UTF8ToSys(String(FileName));
FileStream := TFileStream.Create(SFileName, fmOpenRead);
try
Result := StreamTo1CBinaryData(FileStream);
finally
FileStream.Free;
end;
end;
procedure TAddInEasyExample.ShowMessageBox;
begin
if Confirm(AppVersion) then
Alert('OK')
else
Alert('Cancel');
end;
end.
| 18.323944 | 68 | 0.734435 |
47c83923d7a6d1abac1b20ee16c6a8cf144667d5 | 2,152 | pas | Pascal | src/Http/Request/UploadedFiles/Contracts/UploadedFileCollectionIntf.pas | atkins126/fano | 472679437cb42637b0527dda8255ec52a3e1e953 | [
"MIT"
]
| null | null | null | src/Http/Request/UploadedFiles/Contracts/UploadedFileCollectionIntf.pas | atkins126/fano | 472679437cb42637b0527dda8255ec52a3e1e953 | [
"MIT"
]
| null | null | null | src/Http/Request/UploadedFiles/Contracts/UploadedFileCollectionIntf.pas | atkins126/fano | 472679437cb42637b0527dda8255ec52a3e1e953 | [
"MIT"
]
| null | null | null | {*!
* Fano Web Framework (https://fanoframework.github.io)
*
* @link https://github.com/fanoframework/fano
* @copyright Copyright (c) 2018 - 2020 Zamrony P. Juhara
* @license https://github.com/fanoframework/fano/blob/master/LICENSE (MIT)
*}
unit UploadedFileCollectionIntf;
interface
{$MODE OBJFPC}
{$H+}
uses
UploadedFileIntf;
type
IUploadedFileArray = array of IUploadedFile;
(*!------------------------------------------------
* interface for any class having capability as
* contain array of IUploadedFile instance
*
* @author Zamrony P. Juhara <zamronypj@yahoo.com>
*-----------------------------------------------*)
IUploadedFileCollection = interface
['{116083C1-4484-489D-AE15-5565B29CE802}']
(*!------------------------------------------------
* get total uploaded file in collection
*-------------------------------------------------
* @return number of item in collection
*------------------------------------------------*)
function count() : integer;
(*!------------------------------------------------
* test if there is uploaded file specified by name
*-------------------------------------------------
* @return true if specified
*------------------------------------------------*)
function has(const key : shortstring) : boolean;
(*!------------------------------------------------
* get IUploadedFile instance by name
*-------------------------------------------------
* @return IUploadedFile instance
*------------------------------------------------*)
function getUploadedFile(const key : shortstring) : IUploadedFileArray;
(*!------------------------------------------------
* get IUploadedFile instance by index
*-------------------------------------------------
* @return IUploadedFile instance
*------------------------------------------------*)
function getUploadedFile(const indx : integer) : IUploadedFileArray;
end;
implementation
end.
| 33.107692 | 79 | 0.415428 |
fc7179a74e8afeddddf331565101a20a3eef8be0 | 29,678 | pas | Pascal | gl_2d.pas | PAmcconnell/MRIcroGL | 3dc8fe7c1318981c7e11aa286cc08d96a3908ceb | [
"BSD-2-Clause"
]
| 51 | 2016-02-21T20:09:59.000Z | 2021-02-28T16:53:56.000Z | gl_2d.pas | PAmcconnell/MRIcroGL | 3dc8fe7c1318981c7e11aa286cc08d96a3908ceb | [
"BSD-2-Clause"
]
| 37 | 2015-11-08T22:00:40.000Z | 2021-01-01T18:50:07.000Z | gl_2d.pas | PAmcconnell/MRIcroGL | 3dc8fe7c1318981c7e11aa286cc08d96a3908ceb | [
"BSD-2-Clause"
]
| 21 | 2016-02-21T20:10:08.000Z | 2021-02-23T20:32:10.000Z | unit gl_2d;
{$mode objfpc}{$H+}
interface
{$Include opts.inc}
uses
{$IFDEF DGL} dglOpenGL, {$ELSE DGL} {$IFDEF COREGL}gl_core_matrix, glcorearb, {$ELSE} gl, {$ENDIF} {$ENDIF DGL}
//colorTable,
//matmath,
raycast_common,
define_types, prefs,
Classes, SysUtils, math;
{$IFDEF COREGL}
const kVert2D ='#version 330'
+#10'layout(location = 0) in vec3 Vert;'
+#10'layout(location = 3) in vec4 Clr;'
+#10'out vec4 vClr;'
+#10'uniform mat4 ModelViewProjectionMatrix;'
+#10'void main() {'
+#10' gl_Position = ModelViewProjectionMatrix * vec4(Vert, 1.0);'
+#10' vClr = Clr;'
+#10'}';
const kFrag2D = '#version 330'
+#10'in vec4 vClr;'
+#10'out vec4 color;'
+#10'void main() {'
+#10' color = vClr;'
+#10'}';
{$ELSE}
const kVert2D ='varying vec4 vClr;'
+#10'void main() {'
+#10' gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;'
+#10' vClr = gl_Color;'
+#10'}';
const kFrag2D = 'varying vec4 vClr;'
+#10'void main() {'
+#10' gl_FragColor = vClr;'
+#10'}';
{$ENDIF}
procedure ReDraw2D; //use pre-calculated drawing
procedure StartDraw2D;
procedure EndDraw2D;
procedure nglBegin(mode: integer);
procedure nglEnd;
procedure nglColor4f(r,g,b,a: single);
procedure nglColor4ub (r,g,b,a: byte);
procedure nglVertex3f(x,y,z: single);
procedure nglVertex2f(x,y: single);
//procedure Set2DDraw (w,h: integer; r,g,b: byte);
//procedure DrawCLUTtrk ( lU: TUnitRect; lBorder, lMin, lMax: single; var lPrefs: TPrefs; LUT: TLUT;window_width, window_height: integer );
procedure TextArrow (X,Y,Sz: single; NumStr: string; orient: integer; FontColor,ArrowColor: TGLRGBQuad);
procedure DrawCube (lScrnWid, lScrnHt, lAzimuth, lElevation: integer);
//procedure DrawCLUT ( lU: TUnitRect; lBorder: single; var lPrefs: TPrefs; lMesh: TMesh; window_width, window_height: integer );
//procedure DrawText (var lPrefs: TPrefs; lScrnWid, lScrnHt: integer);
implementation
uses //{$IFDEF COREGL} raycast_core, {$ENDIF}
shaderu, mainunit;
const
kVert : array [1..50] of tpoint = (
(X:0;Y:0),(X:0;Y:4),(X:0;Y:8),(X:0;Y:12),(X:0;Y:13),
(X:0;Y:14),(X:0;Y:15),(X:0;Y:16),(X:0;Y:17),(X:0;Y:18),
(X:0;Y:22),(X:0;Y:24),(X:0;Y:28),(X:2;Y:14),(X:4;Y:0),
(X:4;Y:4),(X:4;Y:8),(X:4;Y:11),(X:4;Y:12),(X:4;Y:13),
(X:4;Y:15),(X:4;Y:16),(X:4;Y:17),(X:4;Y:22),(X:4;Y:24),
(X:4;Y:28),(X:8;Y:0),(X:8;Y:14),(X:8;Y:18),(X:8;Y:24),
(X:14;Y:0),(X:14;Y:4),(X:14;Y:12),(X:14;Y:13),(X:14;Y:16),
(X:14;Y:17),(X:14;Y:22),(X:14;Y:24),(X:14;Y:28),(X:16;Y:14),
(X:18;Y:0),(X:18;Y:4),(X:18;Y:11),(X:18;Y:12),(X:18;Y:13),
(X:18;Y:15),(X:18;Y:16),(X:18;Y:22),(X:18;Y:24),(X:18;Y:28)
);
kStripRaw : array [0..11,1..28] of byte = (
(16, 12, 2, 25, 15, 16, 31, 32, 42, 38, 49, 39, 25, 26, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(15, 25, 27, 30, 26, 25, 13, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(42, 41, 16, 1, 22, 4, 22, 47, 4, 33, 47, 39, 49, 26, 25, 12, 24, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(16, 3, 2, 17, 15, 16, 31, 32, 42, 33, 44, 40, 19, 22, 35, 33, 47, 39, 49, 26, 25, 12, 24, 11, 0, 0, 0, 0 ),
(13, 26, 7, 21, 18, 46, 43, 50, 41, 39, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(49, 50, 25, 13, 20, 9, 20, 45, 9, 36, 45, 31, 42, 15, 16, 2, 17, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(38, 48, 49, 37, 39, 38, 26, 25, 12, 23, 9, 5, 36, 34, 20, 23, 5, 15, 2, 31, 32, 42, 33, 44, 35, 0, 0, 0 ),
(11, 13, 24, 25, 13, 50, 25, 49, 38, 27, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(16, 4, 2, 19, 15, 16, 31, 32, 42, 33, 44, 40, 19, 22, 35, 33, 47, 39, 49, 26, 25, 12, 22, 8, 14, 22, 19, 4 ),
(16, 3, 2, 17, 15, 16, 31, 32, 42, 33, 44, 47, 19, 22, 35, 33, 47, 39, 49, 26, 25, 12, 22, 8, 19, 0, 0, 0 ),
(1, 15, 2, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(6, 10, 28, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
);
kStripLocal : array [0..11,1..28] of byte = (
(1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 10, 11, 4, 12, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(1, 2, 3, 4, 5, 2, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(1, 2, 3, 4, 5, 6, 5, 7, 6, 8, 7, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 9, 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, 0, 0 ),
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(1, 2, 3, 4, 5, 6, 5, 7, 6, 8, 7, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 9, 11, 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, 0 ),
(1, 2, 3, 4, 2, 5, 4, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 10, 11, 4, 12, 13, 9, 14, 15, 16, 17, 18, 19, 12, 20, 21, 12, 4, 2 ),
(1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 9, 11, 15, 16, 17, 18, 19, 13, 20, 12, 0, 0, 0 ),
(1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
(1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
);
kStripCount : array [0..11] of byte = (15, 8, 18, 24, 11, 18, 25, 11, 28, 25, 4, 4 );
kStripWid : array [0..11] of byte = (9, 5, 9, 9, 9, 9, 9, 9, 9, 9, 2, 4 );
(*procedure Enter2D(lPrefs: TPrefs);
begin
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
glOrtho(0, lPrefs.window_width, 0, lPrefs.window_height,-1,1);//<- same effect as previous line
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
glDisable(GL_DEPTH_TEST);
end;*)
{$IFDEF COREGL}
type
TVtxClr = Packed Record
vtx : TPoint3f; //vertex coordinates
clr : TRGBA;
end;
var
g2Dvnc: array of TVtxClr;
g2Drgba : TRGBA;
g2DNew: boolean;
procedure nglPushMatrix;
begin
//
end;
procedure nglPopMatrix;
begin
//
end;
procedure nglColor4f(r,g,b,a: single);
begin
g2Drgba.R := round(r * 255);
g2Drgba.G := round(g * 255);
g2Drgba.B := round(b * 255);
g2Drgba.A := round(a * 255);
end;
procedure nglColor4ub (r,g,b,a: byte);
begin
g2Drgba.R := round(r );
g2Drgba.G := round(g );
g2Drgba.B := round(b );
g2Drgba.A := round(a );
end;
procedure nglVertex3f(x,y,z: single);
begin
setlength(g2Dvnc, length(g2Dvnc)+1);
g2Dvnc[high(g2Dvnc)].vtx.X := x;
g2Dvnc[high(g2Dvnc)].vtx.Y := y;
g2Dvnc[high(g2Dvnc)].vtx.Z := z;
g2Dvnc[high(g2Dvnc)].clr := g2Drgba;
if not g2DNew then exit;
g2DNew := false;
setlength(g2Dvnc, length(g2Dvnc)+1);
g2Dvnc[high(g2Dvnc)] := g2Dvnc[high(g2Dvnc)-1];
end;
procedure nglVertex2f(x,y: single);
begin
nglVertex3f(x,y,0);
end;
procedure nglBegin(mode: integer);
begin
g2DNew := true;
end;
procedure nglEnd;
begin
//add tail
if length(g2Dvnc) < 1 then exit;
setlength(g2Dvnc, length(g2Dvnc)+1);
g2Dvnc[high(g2Dvnc)] := g2Dvnc[high(g2Dvnc)-1];
end;
procedure DrawTextCore (lScrnWid, lScrnHt: integer);
begin
nglMatrixMode(nGL_MODELVIEW);
nglLoadIdentity;
nglMatrixMode (nGL_PROJECTION);
nglLoadIdentity ();
nglOrtho (0, lScrnWid,0, lScrnHt,-10,10);
end;
procedure ReDraw2D; //use pre-calculated drawing
var
mv : TnMat44;
mvpMat: GLint;
begin
if gShader.nface < 1 then exit;
glUseProgram(gShader.program2d);
mv := ngl_ModelViewProjectionMatrix;
mvpMat := glGetUniformLocation(gShader.program2d, pAnsiChar('ModelViewProjectionMatrix'));
glUniformMatrix4fv(mvpMat, 1, GL_FALSE, @mv[0,0]);
glBindVertexArray(gShader.vao_point2d);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,gShader.vbo_face2d);
glDrawElements(GL_TRIANGLE_STRIP, gShader.nface, GL_UNSIGNED_INT, nil);
glBindVertexArray(0);
end;
procedure DrawStrips (lScrnWid, lScrnHt: integer);
const
kATTRIB_VERT = 0; //vertex XYZ are positions 0,1,2
kATTRIB_CLR = 3; //color RGBA are positions 3,4,5,6
var
i,nface: integer;
faces: TInts;
vbo_point : GLuint;
mv : TnMat44;
mvpMat: GLint;
begin
//setup 2D
if Length(g2Dvnc) < 1 then exit;
glUseProgram(gShader.program2d);
if gShader.vao_point2d <> 0 then
glDeleteVertexArrays(1,@gShader.vao_point2d);
glGenVertexArrays(1, @gShader.vao_point2d);
if (gShader.vbo_face2d <> 0) then
glDeleteBuffers(1, @gShader.vbo_face2d);
glGenBuffers(1, @gShader.vbo_face2d);
vbo_point := 0;
glGenBuffers(1, @vbo_point);
glBindBuffer(GL_ARRAY_BUFFER, vbo_point);
glBufferData(GL_ARRAY_BUFFER, Length(g2Dvnc)*SizeOf(TVtxClr), @g2Dvnc[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Prepare vertrex array object (VAO)
glBindVertexArray(gShader.vao_point2d);
glBindBuffer(GL_ARRAY_BUFFER, vbo_point);
//Vertices
glVertexAttribPointer(kATTRIB_VERT, 3, GL_FLOAT, GL_FALSE, sizeof(TVtxClr), PChar(0));
glEnableVertexAttribArray(kATTRIB_VERT);
//Color
glVertexAttribPointer(kATTRIB_CLR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(TVtxClr), PChar( sizeof(TPoint3f)));
glEnableVertexAttribArray(kATTRIB_CLR);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
glDeleteBuffers(1, @vbo_point);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gShader.vbo_face2d);
nface := Length(g2Dvnc); //each face has 3 vertices
setlength(faces,nface);
if nface > 0 then begin
for i := 0 to (nface-1) do begin
faces[i] := i;
glBufferData(GL_ELEMENT_ARRAY_BUFFER, nface*sizeof(uint32), @faces[0], GL_STATIC_DRAW);
end;
end;
mv := ngl_ModelViewProjectionMatrix;
mvpMat := glGetUniformLocation(gShader.program2d, pAnsiChar('ModelViewProjectionMatrix'));
glUniformMatrix4fv(mvpMat, 1, GL_FALSE, @mv[0,0]);
glBindVertexArray(gShader.vao_point2d);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gShader.vbo_face2d);
glDrawElements(GL_TRIANGLE_STRIP, nface, GL_UNSIGNED_INT, nil); //slow!!! we need to copy VBO with each call
gShader.nface := nface;
//GLForm1.ShaderMemo.Lines.Add(inttostr(nface));
end;
procedure Enter2D(w, h: integer);
begin
glUseProgram(gShader.program2d);
glDisable(GL_DEPTH_TEST);
end;
procedure Set2DDraw (w,h: integer; r,g,b: byte);
begin
glDepthMask(GL_TRUE); // enable writes to Z-buffer
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE); // glEnable(GL_CULL_FACE); //check on pyramid
glEnable(GL_BLEND);
{$IFNDEF COREGL}glEnable(GL_NORMALIZE);{$ENDIF}
glClearColor(r/255, g/255, b/255, 0.0); //Set background
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT);
glViewport( 0, 0, w, h); //required when bitmap zoom <> 1
end;
{$ELSE}
procedure Set2DDraw (w,h: integer; r,g,b: byte);
begin
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho (0, 1, 0, 1, -6, 12);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
{$IFDEF DGL}
glDepthMask(BYTEBOOL(1)); // enable writes to Z-buffer
{$ELSE}
glDepthMask(GL_TRUE); // enable writes to Z-buffer
{$ENDIF}
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE); // glEnable(GL_CULL_FACE); //check on pyramid
glEnable(GL_BLEND);
glEnable(GL_NORMALIZE);
glClearColor(r/255, g/255, b/255, 0.0); //Set background
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT);
glViewport( 0, 0, w, h); //required when bitmap zoom <> 1
end;
procedure Enter2D(w, h: integer);
begin
glUseProgram(gShader.program2d);
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
glOrtho(0, w, 0, h,-1,1);//<- same effect as previous line
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
glDisable(GL_DEPTH_TEST);
end;
procedure nglColor4f(r,g,b,a: single);
begin
glColor4f(r,g,b,a);
end;
procedure nglColor4ub (r,g,b,a: byte);
begin
glColor4ub (r,g,b,a);
end;
procedure nglVertex3f(x,y,z: single);
begin
glVertex3f(x,y,z);
end;
procedure nglVertex2f(x,y: single);
begin
glVertex2f(x,y);
end;
procedure nglBegin(mode: integer);
begin
glBegin(mode);
end;
procedure nglEnd;
begin
glEnd();
end;
{$ENDIF}
function PrintHt (Sz: single): single;
begin
result := Sz * 14;//14-pixel tall font
end;
function Char2Int (c: char): integer;
begin
result := ord(c)-48;//ascii '0'..'9' = 48..58
if result = -3 then result := 11; // '-' minus;
if (result < 0) or (result > 11) then result := 10; //'.'or''
end;
function PrintWid (Sz: single; NumStr: string): single;
var
i: integer;
begin
result := 0;
if length(NumStr) < 1 then
exit;
for i := 1 to length(NUmStr) do begin
result := result + kStripWid[Char2Int(NumStr[i]) ] + 1; ;
end;
if result < 1 then
exit;
result := result -1;//fence post: no gap after last gap between character
result := result * sz;
end;
procedure MakeCube(sz: single);
//draw a cube of size sz
var
sz2: single;
begin
sz2 := sz;
nglColor4f(0.1,0.1,0.1,1);
nglBegin(GL_TRIANGLE_STRIP); //* Bottom side
nglVertex3f(-sz, -sz, -sz2);
nglVertex3f(-sz, sz, -sz2);
nglVertex3f(sz, -sz, -sz2);
nglVertex3f(sz, sz, -sz2);
nglEnd;
nglColor4f(0.8,0.8,0.8,1);
nglBegin(GL_TRIANGLE_STRIP); //* Top side
nglVertex3f(-sz, -sz, sz2);
nglVertex3f(sz, -sz, sz2);
nglVertex3f(-sz, sz, sz2);
nglVertex3f(sz, sz, sz2);
nglEnd;
nglColor4f(0,0,0.5,1);
nglBegin(GL_TRIANGLE_STRIP); //* Front side
nglVertex3f(-sz, sz2, -sz);
nglVertex3f(-sz, sz2, sz);
nglVertex3f(sz, sz2, -sz);
nglVertex3f(sz, sz2, sz);
nglEnd;
nglColor4f(0.3,0,0.3,1);
nglBegin(GL_TRIANGLE_STRIP);//* Back side
nglVertex3f(-sz, -sz2, -sz);
nglVertex3f(sz, -sz2, -sz);
nglVertex3f(-sz, -sz2, sz);
nglVertex3f(sz, -sz2, sz);
nglEnd;
nglColor4f(0.6,0,0,1);
nglBegin(GL_TRIANGLE_STRIP); //* Left side
nglVertex3f(-sz2, -sz, -sz);
nglVertex3f(-sz2, -sz, sz);
nglVertex3f(-sz2, sz, -sz);
nglVertex3f(-sz2, sz, sz);
nglEnd;
nglColor4f(0,0.6,0,1);
nglBegin(GL_TRIANGLE_STRIP); //* Right side
//glNormal3f(1.0, -sz, -sz);
nglVertex3f(sz2, -sz, -sz);
nglVertex3f(sz2, sz, -sz);
nglVertex3f(sz2, -sz, sz);
nglVertex3f(sz2, sz, sz);
nglEnd();
end; //MakeCube()
procedure DrawCubeCore (lScrnWid, lScrnHt, lAzimuth, lElevation: integer);
var
{$IFDEF COREGL}
mvp: TnMat44;
{$ENDIF}
sz: single;
begin
sz := lScrnWid;
if sz > lScrnHt then sz := lScrnHt;
if sz < 10 then exit;
sz := sz * 0.03;
{$IFDEF COREGL}
glUseProgram(gShader.program2d); //666
nglMatrixMode(nGL_MODELVIEW);
nglLoadIdentity;
//glDisable(GL_DEPTH_TEST);
nglMatrixMode (nGL_PROJECTION);
nglLoadIdentity ();
nglOrtho (0, lScrnWid,0, lScrnHt,-10*sz,10*sz);
glEnable(GL_DEPTH_TEST);
//glDisable (GL_LIGHTING);
//glDisable (GL_BLEND);
nglTranslatef(0,0,sz*8);
nglTranslatef(1.8*sz,1.8*sz,0);
//nglRotatef(90-lElevation,-1,0,0);
//nglRotatef(-lAzimuth,0,0,1);
nglRotatef(90-lElevation,-1,0,0);
//nglRotatef(-lAzimuth,0,0,1);
nglRotatef(lAzimuth,0,0,1);
//nglTranslatef(0,0,-30);
//mvp := ngl_ModelViewProjectionMatrix;
//glUniformMatrix4fv(glGetUniformLocation(gShader.program2d, pAnsiChar('ModelViewProjectionMatrix')), 1, GL_FALSE, @mvp[0,0]);
{$ELSE}
//Enter2D(lScrnWid, lScrnHt);
glUseProgram(gShader.program2d);
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
glOrtho(0, lScrnWid, 0, lScrnHt,-sz*4,0.01);//<- same effect as previous line
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
(*glUseProgram(gShader.program2d);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
//glDisable(GL_DEPTH_TEST);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, lScrnWid,0, lScrnHt,-10*sz,10*sz); *)
glEnable(GL_DEPTH_TEST);
//glDisable (GL_LIGHTING);
//glDisable (GL_BLEND);
glTranslatef(0,0,sz*2);
//glTranslatef(0,0,0.5);
glTranslatef(1.8*sz,1.8*sz,0);
glRotatef(90-lElevation,-1,0,0);
glRotatef(-lAzimuth,0,0,1);
{$ENDIF}
MakeCube(sz);
end;
procedure PrintXY (Xin,Y,Sz: single; NumStr: string;FontColor: TGLRGBQuad);
//draws numerical strong with 18-pixel tall characters. If Sz=2.0 then characters are 36-pixel tall
//Unless you use multisampling, fractional sizes will not look good...
var
i, j, k: integer;
X, Sc: single;
begin
if length(NumStr) < 1 then
exit;
Sc := Sz * 0.5;
X := Xin;
nglColor4ub (FontColor.rgbRed, FontColor.rgbGreen, FontColor.rgbBlue,FontColor.rgbReserved);
for i := 1 to length(NUmStr) do begin
j := Char2Int(NumStr[i]);
nglBegin(GL_TRIANGLE_STRIP);
for k := 1 to kStripCount[j] do
nglVertex2f(Sc*kVert[kStripRaw[j,k]].X + X, Sc*kVert[kStripRaw[j,k]].Y +Y);
nglEnd;
X := X + ((kStripWid[j] + 1)* Sz);
end;
end;
procedure TextArrow (X,Y,Sz: single; NumStr: string; orient: integer; FontColor,ArrowColor: TGLRGBQuad);
//orient code 1=left,2=top,3=right,4=bottom
const
kZ = -0.1; //put border BEHIND text
var
lW,lH,lW2,lH2,T: single;
begin
//glForm1.Caption := format('%g %g %g', [X, Y, Sz]);
if NumStr = '' then exit;
//glLoadIdentity();
lH := PrintHt(Sz);
lH2 := (lH/2);
lW := PrintWid(Sz,NumStr);
lW2 := (lW/2);
nglColor4ub (ArrowColor.rgbRed, ArrowColor.rgbGreen, ArrowColor.rgbBlue,ArrowColor.rgbReserved);
case Orient of
1: begin
nglBegin(GL_TRIANGLE_STRIP);
nglVertex3f(X-lH2-lW-3*Sz,Y+LH2+Sz, kZ);
nglVertex3f(X-lH2-lW-3*Sz,Y-lH2-Sz, kZ);
nglVertex3f(X-lH2,Y+lH2+Sz, kZ);
nglVertex3f(X-lH2,Y-lH2-Sz, kZ);
nglVertex3f(X,Y, kZ);
nglEnd;
PrintXY (X-lW-lH2-1.5*Sz,Y-lH2,Sz, NumStr,FontColor);
end;
3: begin
nglBegin(GL_TRIANGLE_STRIP);
nglVertex3f(X+lH2+lW+2*Sz,Y+LH2+Sz, kZ);
nglVertex3f(X+lH2+lW+2*Sz,Y-lH2-Sz, kZ);
nglVertex3f(X+lH2-Sz,Y+lH2+Sz, kZ);
nglVertex3f(X+lH2-Sz,Y-lH2-Sz, kZ);
nglVertex3f(X,Y, kZ);
nglEnd;
PrintXY (X+lH2,Y-lH2,Sz, NumStr,FontColor);
end;
4: begin //bottom
nglBegin(GL_TRIANGLE_STRIP);
nglVertex3f(X-lW2-2*Sz,Y-LH-lH2-2*Sz, kZ);//-
nglVertex3f(X-lW2-2*Sz,Y-lH2, kZ);
nglVertex3f(X+lW2+Sz,Y-LH-lH2-2*Sz, kZ);//-
nglVertex3f(X+lW2+Sz,Y-lH2, kZ);
nglVertex3f(X-lW2-Sz,Y-lH2, kZ);
nglVertex3f(X,Y, kZ);
nglEnd;
PrintXY (X-lW2-Sz,Y-lH-LH2,Sz, NumStr,FontColor);
end;
else begin
if Orient = 5 then
T := Y-LH-Sz-lH2
else
T := Y;
nglBegin(GL_TRIANGLE_STRIP);
nglVertex3f(X-lW2-2*Sz,T+LH+2*Sz+lH2, kZ);
nglVertex3f(X-lW2-2*Sz,T+lH2, kZ);
nglVertex3f(X+lW2+Sz,T+LH+2*Sz+lH2, kZ);
nglVertex3f(X+lW2+Sz,T+lH2, kZ);
nglVertex3f(X-lW2-Sz,T+lH2, kZ);
nglVertex3f(X,T, kZ);
nglEnd;
PrintXY (X-lW2-Sz,T+lH2+Sz,Sz, NumStr,FontColor);
end;
end;//case
end;
procedure SetOrder (l1,l2: single; var lSmall,lLarge: single);
//set lSmall to be the lesser of l1/l2 and lLarge the greater value of L1/L2
begin
if l1 < l2 then begin
lSmall := l1;
lLarge := l2;
end else begin
lSmall := l2;
lLarge := l1;
end;
end;
procedure DrawCLUTx (var lCLUT: TLUT; lU: TUnitRect; lPrefs: TPrefs);
var
lL,lT,lR,lB,lN: single;
lI: integer;
begin
SetOrder(lU.L,lU.R,lL,lR);
SetOrder(lU.T,lU.B,lT,lB);
lL := lL*gRayCast.WINDOW_WIDTH;
lR := lR*gRayCast.WINDOW_WIDTH;
lT := lT*gRayCast.WINDOW_HEIGHT;
lB := lB*gRayCast.WINDOW_HEIGHT;
if (lR-lL) > (lB-lT) then begin
lN := lL;
nglBegin(GL_TRIANGLE_STRIP);
nglColor4ub (lCLUT[0].rgbRed, lCLUT[0].rgbGreen,lCLUT[0].rgbBlue,255);
nglVertex2f(lN,lT);
nglVertex2f(lN,lB);
for lI := 1 to (255) do begin
lN := (lI/255 * (lR-lL))+lL;
nglColor4ub (lCLUT[lI].rgbRed, lCLUT[lI].rgbGreen,lCLUT[lI].rgbBlue,255);
nglVertex2f(lN,lT);
nglVertex2f(lN,lB);
end;
nglEnd;//GL_TRIANGLE_STRIP
end else begin //If WIDE, else TALL
lN := lT;
nglColor4ub (lCLUT[0].rgbRed, lCLUT[0].rgbGreen,lCLUT[0].rgbBlue,255);
nglBegin(GL_TRIANGLE_STRIP);
nglVertex2f(lR, lN);
nglVertex2f(lL, lN);
for lI := 1 to (255) do begin
lN := (lI/255 * (lB-lT))+lT;
nglColor4ub (lCLUT[lI].rgbRed, lCLUT[lI].rgbGreen,lCLUT[lI].rgbBlue,255);
nglVertex2f(lR, lN);
nglVertex2f(lL, lN);
end;
nglEnd;//GL_TRIANGLE_STRIP
end;
end;
procedure DrawBorder (var lU: TUnitRect;lBorder: single; lPrefs: TPrefs);
const
kZ = -0.1; //put border behind colorbar
var
lL,lT,lR,lB: single;
begin
if lBorder <= 0 then
exit;
SetOrder(lU.L,lU.R,lL,lR);
SetOrder(lU.T,lU.B,lT,lB);
nglColor4ub(lPrefs.GridAndBorder.rgbRed,lPrefs.GridAndBorder.rgbGreen,lPrefs.GridAndBorder.rgbBlue,lPrefs.GridAndBorder.rgbReserved);
nglBegin(GL_TRIANGLE_STRIP);
nglVertex3f((lL-lBorder)*gRayCast.WINDOW_WIDTH,(lB+lBorder)*gRayCast.WINDOW_HEIGHT, kZ);
nglVertex3f((lL-lBorder)*gRayCast.WINDOW_WIDTH,(lT-lBorder)*gRayCast.WINDOW_HEIGHT, kZ);
nglVertex3f((lR+lBorder)*gRayCast.WINDOW_WIDTH,(lB+lBorder)*gRayCast.WINDOW_HEIGHT, kZ);
nglVertex3f((lR+lBorder)*gRayCast.WINDOW_WIDTH,(lT-lBorder)*gRayCast.WINDOW_HEIGHT, kZ);
nglEnd;//GL_TRIANGLE_STRIP
end;
procedure UOffset (var lU: TUnitRect; lX,lY: single);
begin
lU.L := lU.L+lX;
lU.T := lU.T+lY;
lU.R := lU.R+lX;
lU.B := lU.B+lY;
end;
procedure SetLutFromZero(var lMin,lMax: single);
//if both min and max are positive, returns 0..max
//if both min and max are negative, returns min..0
begin
SortSingle(lMin,lMax);
if (lMin > 0) and (lMax > 0) then
lMin := 0
else if (lMin < 0) and (lMax < 0) then
lMax := 0;
end;
const
kVertTextLeft = 1;
kHorzTextBottom = 2;
kVertTextRight = 3;
kHorzTextTop = 4;
function ColorBarPos(var lU: TUnitRect): integer;
begin
SensibleUnitRect(lU);
if abs(lU.R-lU.L) > abs(lU.B-lU.T) then begin //wide bars
if (lU.B+lU.T) >1 then
result := kHorzTextTop
else
result := kHorzTextBottom;
end else begin //high bars
if (lU.L+lU.R) >1 then
result := kVertTextLeft
else
result := kVertTextRight;
end;
end;
procedure DrawColorBarText(lMinIn,lMaxIn: single; var lUin: TUnitRect;lBorder: single; var lPrefs: TPrefs);
var
lS: string;
lOrient,lDesiredSteps,lPower, lSteps,lStep,lDecimals,lStepPosScrn, lTextZoom: integer;
lBarLength,lScrnL,lScrnT,lStepPos,l1stStep,lMin,lMax,lRange,lStepSize: single;
lU: TUnitRect;
begin
lU := lUin;
lOrient := ColorBarPos(lU);
lMin := lMinIn;
lMax := lMaxIn;
if (lMinIn < 0) and (lMaxIn <= 0) then begin
lMin := abs(lMinIn);
lMax := abs(lMaxIn);
end;
sortsingle(lMin,lMax);
//next: compute increment
lDesiredSteps := 4;
lRange := abs(lMax - lMin);
if lRange < 0.000001 then exit;
lStepSize := lRange / lDesiredSteps;
lPower := 0;
while lStepSize >= 10 do begin
lStepSize := lStepSize/10;
inc(lPower);
end;
while lStepSize < 1 do begin
lStepSize := lStepSize * 10;
dec(lPower);
end;
lStepSize := round(lStepSize) *Power(10,lPower);
if lPower < 0 then
lDecimals := abs(lPower)
else
lDecimals := 0;
l1stStep := trunc((lMin) / lStepSize)*lStepSize;
lScrnL := lU.L * gRayCast.WINDOW_WIDTH;
if lOrient = kVertTextRight then
lScrnL := lU.R * gRayCast.WINDOW_WIDTH;
lScrnT := (lU.B) * gRayCast.WINDOW_HEIGHT;
if lOrient = kHorzTextTop then
lScrnT := ((lU.B) * gRayCast.WINDOW_HEIGHT);
if lOrient = kHorzTextBottom then
lScrnT := ((lU.T) * gRayCast.WINDOW_HEIGHT);
if l1stStep < (lMin) then l1stStep := l1stStep+lStepSize;
lSteps := trunc( abs((lMax+0.0001)-l1stStep) / lStepSize)+1;
if (lOrient = kVertTextLeft) or (lOrient = kVertTextRight) then //vertical bars
lBarLength := gRayCast.WINDOW_HEIGHT * abs(lU.B-lU.T)
else
lBarLength := gRayCast.WINDOW_WIDTH * abs(lU.L-lU.R);
lTextZoom := trunc(lBarLength / 1000) + 1;
for lStep := 1 to lSteps do begin
lStepPos := l1stStep+((lStep-1)*lStepSize);
lStepPosScrn := round( abs(lStepPos-lMin)/lRange*lBarLength);
lS := realtostr(lStepPos,lDecimals);
if (lMinIn < 0) and (lMaxIn <= 0) then
lS := '-'+lS;
if (lOrient = kVertTextLeft) or (lOrient = kVertTextRight) then
TextArrow (lScrnL,lScrnT+ lStepPosScrn,lTextZoom,lS,lOrient,lPrefs.TextColor, lPrefs.TextBorder)
else
TextArrow (lScrnL+ lStepPosScrn,lScrnT,lTextZoom,lS,lOrient,lPrefs.TextColor, lPrefs.TextBorder);
end;
{$IFNDEF COREGL}glLoadIdentity();{$ENDIF}
end; //DrawColorBarText
type
TColorBar = packed record
mn, mx: single;
LUT: TLUT;
end;
TColorBars = array of TColorBar;
procedure DrawColorBars ( lU: TUnitRect; lBorder: single; var lPrefs: TPrefs; lColorBars: TColorBars; window_width, window_height: integer );
var
lU2:TUnitRect;
nLUT, lI: integer;
lIsHorzTop: boolean;
lX,lY,lMin,lMax: single;
begin
nLUT := length(lColorBars);
if (nLUT < 1) then exit;
gRayCast.WINDOW_HEIGHT:= window_height;
gRayCast.WINDOW_WIDTH := window_width;
lIsHorzTop := false;
//Enter2D(lPrefs);
Enter2D(window_width, window_height);
glEnable (GL_BLEND);//allow border to be translucent
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if abs(lU.R-lU.L) > abs(lU.B-lU.T) then begin //wide bars
lX := 0;
lY := abs(lU.B-lU.T)+lBorder;
if (lU.B+lU.T) >1 then
lY := -lY
else
lIsHorzTop := true;
end else begin //high bars
lX := abs(lU.R-lU.L)+lBorder;
lY := 0;
if (lU.L+lU.R) >1 then
lX := -lX;
end;
//next - draw a border - do this once for all overlays, so
//semi-transparent regions do not display regions of overlay
SensibleUnitRect(lU);
lU2 := lU;
if nLUT > 1 then begin
for lI := 2 to nLUT do begin
if lX < 0 then
lU2.L := lU2.L + lX
else
lU2.R := lU2.R + lX;
if lY < 0 then
lU2.B := lU2.B + lY
else
lU2.T := lU2.T + lY;
end;
end;
DrawBorder(lU2,lBorder,lPrefs);
lU2 := lU;
for lI := 0 to (nLUT-1) do begin
DrawCLUTx(lColorBars[lI].LUT,lU2,lPrefs);
UOffset(lU2,lX,lY);
end;
lU2 := lU;
for lI := 0 to (nLUT-1) do begin
lMin := lColorBars[lI].mn;
lMax := lColorBars[lI].mx;
SortSingle(lMin,lMax);
DrawColorBarText(lMin,lMax, lU2,lBorder,lPrefs);
UOffset(lU2,lX,lY);
end;
glDisable (GL_BLEND);
end;
{$IFDEF COREGL}
procedure StartDraw2D;
begin
//Set2DDraw (gRayCast.WINDOW_WIDTH,gRayCast.WINDOW_Height, 48,48,48);
glDepthMask(GL_TRUE); // enable writes to Z-buffer
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE); // glEnable(GL_CULL_FACE); //check on pyramid
glEnable(GL_BLEND);
{$IFNDEF COREGL}glEnable(GL_NORMALIZE); {$ENDIF}
glViewport( 0, 0, gRayCast.WINDOW_WIDTH,gRayCast.WINDOW_Height); //required when bitmap zoom <> 1
nglMatrixMode(nGL_MODELVIEW);
nglLoadIdentity;
//glDisable(GL_DEPTH_TEST);
nglMatrixMode (nGL_PROJECTION);
nglLoadIdentity ();
nglOrtho (0, gRayCast.WINDOW_WIDTH,0, gRayCast.WINDOW_Height,-10,10);
setlength(g2Dvnc, 0);
end;
procedure EndDraw2D;
begin
DrawStrips (gRayCast.WINDOW_WIDTH, gRayCast.WINDOW_Height);
end;
(*procedure DrawCubeX (lScrnWid, lScrnHt, lAzimuth, lElevation: integer);
begin
Set2DDraw (lScrnWid,lScrnHt, 48,48,48);
nglMatrixMode(nGL_MODELVIEW);
nglLoadIdentity;
//glDisable(GL_DEPTH_TEST);
nglMatrixMode (nGL_PROJECTION);
nglLoadIdentity ();
nglOrtho (0, lScrnWid,0, lScrnHt,-10,10);
setlength(g2Dvnc, 0);
TextArrow (50,50,1, '6666',1, gPrefs.TextColor, gPrefs.TextBorder);
DrawStrips (lScrnWid, lScrnHt);
end; *)
procedure DrawCube (lScrnWid, lScrnHt, lAzimuth, lElevation: integer);
begin
setlength(g2Dvnc, 0);
DrawStrips (lScrnWid, lScrnHt);
DrawCubeCore (lScrnWid, lScrnHt, lAzimuth, lElevation);
DrawStrips (lScrnWid, lScrnHt);
end;
{$ELSE}
procedure DrawCube (lScrnWid, lScrnHt, lAzimuth, lElevation: integer);
begin
DrawCubeCore (lScrnWid, lScrnHt, lAzimuth, lElevation);
end;
{$ENDIF}
(*procedure TestColorBar (var lPrefs: TPrefs; window_width, window_height: integer);
var
c: TColorBars;
lU: TUnitRect;
i : integer = 1;
begin
lU := CreateUnitRect (0.1,0.1,0.9,0.2);
setlength(c,2);
i := 2;
c[0].LUT := UpdateTransferFunction(i);
c[0].mn := 2;
c[0].mx := 10;
i := 1;
c[1].LUT := UpdateTransferFunction(i);
c[1].mn := -2;
c[1].mx := -10;
DrawColorBars ( lU, 0.005, lPrefs, c, window_width, window_height );
end;
procedure DrawCube (lScrnWid, lScrnHt, lAzimuth, lElevation: integer);
begin
setlength(g2Dvnc, 0);
DrawCubeCore (lScrnWid, lScrnHt, lAzimuth, lElevation);
DrawStrips (lScrnWid, lScrnHt);
end;
procedure DrawTextCore (lScrnWid, lScrnHt: integer);
begin
nglMatrixMode(nGL_MODELVIEW);
nglLoadIdentity;
nglMatrixMode (nGL_PROJECTION);
nglLoadIdentity ();
nglOrtho (0, lScrnWid,0, lScrnHt,-10,10);
//clr.r := 22; clr.g := 22; clr.b := 222; clr.a := 255;
//PrintXY(10,320, 2,'-123.9', clr);
//clr2.r := 65; clr2.g := 10; clr2.b := 220; clr2.a := 128;
//TextArrow (60,220, 2, '123.9', 2, clr,clr2);
end;
procedure DrawText (var lPrefs: TPrefs; lScrnWid, lScrnHt: integer);
begin
setlength(g2Dvnc, 0);
DrawTextCore(lScrnWid, lScrnHt);
TestColorBar(lPrefs, lScrnWid, lScrnHt);
DrawStrips (lScrnWid, lScrnHt);
end; *)
(*procedure TestColorBar (var lPrefs: TPrefs; window_width, window_height: integer);
var
c: TColorBars;
lU: TUnitRect;
i : integer = 1;
begin
lU := CreateUnitRect (0.1,0.1,0.9,0.2);
setlength(c,2);
i := 2;
c[0].LUT := UpdateTransferFunction(i);
c[0].mn := 2;
c[0].mx := 10;
i := 1;
c[1].LUT := UpdateTransferFunction(i);
c[1].mn := -2;
c[1].mx := -10;
DrawColorBars ( lU, 0.005, lPrefs, c, window_width, window_height );
end; *)
{$IFDEF COREGL}
procedure DrawText (var lPrefs: TPrefs; lScrnWid, lScrnHt: integer);
begin
setlength(g2Dvnc, 0);
DrawTextCore(lScrnWid, lScrnHt);
//TestColorBar(lPrefs, lScrnWid, lScrnHt);
DrawStrips (lScrnWid, lScrnHt);
end;
{$ELSE}
procedure DrawText (var lPrefs: TPrefs; lScrnWid, lScrnHt: integer);
begin
TestColorBar(lPrefs, lScrnWid, lScrnHt);
end;
{$ENDIF}
end.
| 30.191251 | 141 | 0.643911 |
c3dfe03f0e92c9b6bbb4ec1abd4b95ac681f51e9 | 3,334 | dfm | Pascal | src/Graph.dfm | miselkrstovic/graph-layout | 9e241d73296a1543016ca63ec3ae8ab16080dc84 | [
"BSD-3-Clause-No-Nuclear-License",
"MIT"
]
| 8 | 2019-02-24T09:28:04.000Z | 2022-03-05T16:10:31.000Z | src/Graph.dfm | miselkrstovic/graph-layout | 9e241d73296a1543016ca63ec3ae8ab16080dc84 | [
"BSD-3-Clause-No-Nuclear-License",
"MIT"
]
| null | null | null | src/Graph.dfm | miselkrstovic/graph-layout | 9e241d73296a1543016ca63ec3ae8ab16080dc84 | [
"BSD-3-Clause-No-Nuclear-License",
"MIT"
]
| 4 | 2017-06-27T14:21:39.000Z | 2020-05-04T21:47:02.000Z | object frmGraph: TfrmGraph
Left = 0
Top = 0
Caption = 'Graph Layout'
ClientHeight = 478
ClientWidth = 650
Color = clWhite
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
OnDestroy = FormDestroy
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object controlPanel: TPanel
Left = 0
Top = 436
Width = 650
Height = 42
Align = alBottom
BevelOuter = bvNone
TabOrder = 1
object btnScramble: TButton
Left = 8
Top = 8
Width = 75
Height = 25
Caption = 'Scramble'
TabOrder = 0
OnClick = btnScrambleClick
end
object btnShake: TButton
Left = 89
Top = 8
Width = 75
Height = 25
Caption = 'Shake'
TabOrder = 1
OnClick = btnScrambleClick
end
object chkStress: TCheckBox
Left = 184
Top = 12
Width = 59
Height = 17
Caption = 'Stress'
TabOrder = 2
OnClick = chkStressClick
end
object chkRandom: TCheckBox
Left = 249
Top = 13
Width = 72
Height = 17
Caption = 'Random'
TabOrder = 3
OnClick = chkStressClick
end
end
object edgesPanel: TPanel
Left = 0
Top = 379
Width = 650
Height = 57
Align = alBottom
BevelOuter = bvNone
TabOrder = 0
DesignSize = (
650
57)
object lblEdges: TLabel
Left = 8
Top = 8
Width = 29
Height = 13
Caption = 'Edges'
end
object lblCenter: TLabel
Left = 529
Top = 8
Width = 33
Height = 13
Anchors = [akTop, akRight]
Caption = 'Center'
end
object edtCenter: TEdit
Left = 529
Top = 27
Width = 113
Height = 21
Anchors = [akTop, akRight]
TabOrder = 1
OnChange = edtEdgesChange
end
object edtEdges: TComboBox
Left = 8
Top = 27
Width = 511
Height = 21
Anchors = [akLeft, akTop, akRight]
TabOrder = 0
OnChange = edtEdgesChange
OnCloseUp = edtEdgesChange
Items.Strings = (
'joe-food,joe-dog,joe-tea,joe-cat,joe-table,table-plate/50,plate-' +
'food/30,food-mouse/100,food-dog/100,mouse-cat/150,table-cup/30,c' +
'up-tea/30,dog-cat/80,cup-spoon/50,plate-fork,dog-flea1,dog-flea2' +
',flea1-flea2/20,plate-knife'
'zero-one,one-two,two-three,three-four,four-five,five-six,six-sev' +
'en,seven-zero'
'zero-one,zero-two,zero-three,zero-four,zero-five,zero-six,zero-s' +
'even,zero-eight,zero-nine,one-ten,two-twenty,three-thirty,four-f' +
'ourty,five-fifty,six-sixty,seven-seventy,eight-eighty,nine-ninet' +
'y,ten-twenty/80,twenty-thirty/80,thirty-fourty/80,fourty-fifty/8' +
'0,fifty-sixty/80,sixty-seventy/80,seventy-eighty/80,eighty-ninet' +
'y/80,ninety-ten/80,one-two/30,two-three/30,three-four/30,four-fi' +
've/30,five-six/30,six-seven/30,seven-eight/30,eight-nine/30,nine' +
'-one/30'
'a1-a2,a2-a3,a3-a4,a4-a5,a5-a6,b1-b2,b2-b3,b3-b4,b4-b5,b5-b6,c1-c' +
'2,c2-c3,c3-c4,c4-c5,c5-c6,x-a1,x-b1,x-c1,x-a6,x-b6,x-c6')
end
end
end
| 25.257576 | 78 | 0.574985 |
c3feb92c460407b0c4158ccff21a680571d3d745 | 591 | dpr | Pascal | Capitulo3/Exemplo2/ConversorWeb/ConversorWeb/ConversorWeb.dpr | diondcm/exemplos-delphi | 16b4d195981e5f3161d0a2c62f778bec5ba9f3d4 | [
"MIT"
]
| 10 | 2017-08-02T00:44:41.000Z | 2021-10-13T21:11:28.000Z | Capitulo3/Exemplo2/ConversorWeb/ConversorWeb/ConversorWeb.dpr | diondcm/exemplos-delphi | 16b4d195981e5f3161d0a2c62f778bec5ba9f3d4 | [
"MIT"
]
| 10 | 2019-12-30T04:09:37.000Z | 2022-03-02T06:06:19.000Z | Capitulo3/Exemplo2/ConversorWeb/ConversorWeb/ConversorWeb.dpr | diondcm/exemplos-delphi | 16b4d195981e5f3161d0a2c62f778bec5ba9f3d4 | [
"MIT"
]
| 9 | 2017-04-29T16:12:21.000Z | 2020-11-11T22:16:32.000Z | program ConversorWeb;
uses
Forms,
IWStart,
UTF8ContentParser,
Unit4 in 'Unit4.pas' {IWForm4: TIWAppForm},
ServerController in 'ServerController.pas' {IWServerController: TIWServerControllerBase},
UserSessionUnit in 'UserSessionUnit.pas' {IWUserSession: TIWUserSessionBase},
Classe.Converte.Unidades in '..\..\Classe.Converte.Unidades.pas',
ClientClassesUnit1 in '..\..\ClientClassesUnit1.pas',
ClientModuleUnit1 in '..\..\ClientModuleUnit1.pas' {ClientModule1: TDataModule};
{$R *.res}
begin
ClientModule1 := TClientModule1.Create(nil);
TIWStart.Execute(True);
end.
| 29.55 | 91 | 0.758037 |
c36283ef78604193e1d50c9a3fa671e19acc62c2 | 104,259 | pas | Pascal | dependencies/Indy10/Protocols/IdIMAP4Server.pas | grahamegrieve/fhirserver | 28f69977bde75490adac663e31a3dd77bc016f7c | [
"BSD-3-Clause"
]
| 132 | 2015-02-02T00:22:40.000Z | 2021-08-11T12:08:08.000Z | dependencies/Indy10/Protocols/IdIMAP4Server.pas | grahamegrieve/fhirserver | 28f69977bde75490adac663e31a3dd77bc016f7c | [
"BSD-3-Clause"
]
| 113 | 2015-03-20T01:55:20.000Z | 2021-10-08T16:15:28.000Z | dependencies/Indy10/Protocols/IdIMAP4Server.pas | grahamegrieve/fhirserver | 28f69977bde75490adac663e31a3dd77bc016f7c | [
"BSD-3-Clause"
]
| 49 | 2015-04-11T14:59:43.000Z | 2021-03-30T10:29:18.000Z | {
$Project$
$Workfile$
$Revision$
$DateUTC$
$Id$
This file is part of the Indy (Internet Direct) project, and is offered
under the dual-licensing agreement described on the Indy website.
(http://www.indyproject.org/)
Copyright:
(c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
}
{
$Log$
}
{
Prior revision history
Rev 1.31 2/9/2005 11:44:20 AM JPMugaas
Fixed compiler problem and removed some warnings about virtual
methods hiding stuff in the base class.
Rev 1.30 2/8/05 6:20:16 PM RLebeau
Added additional overriden methods.
Rev 1.29 10/26/2004 11:08:06 PM JPMugaas
Updated refs.
Rev 1.28 10/21/2004 1:49:12 PM BGooijen
Raid 214213
Rev 1.27 09/06/2004 09:54:56 CCostelloe
Kylix 3 patch
Rev 1.26 2004.05.20 11:37:34 AM czhower
IdStreamVCL
Rev 1.25 4/8/2004 11:49:56 AM BGooijen
Fix for D5
Rev 1.24 03/03/2004 01:16:20 CCostelloe
Yet another check-in as part of continuing development
Rev 1.23 01/03/2004 23:32:24 CCostelloe
Another check-in as part of continuing development
Rev 1.22 3/1/2004 12:55:28 PM JPMugaas
Updated for problem with new code.
Rev 1.21 26/02/2004 02:01:14 CCostelloe
Another intermediate check-in, approx half of functions are debugged
Rev 1.20 24/02/2004 10:34:50 CCostelloe
Storage-specific code moved to IdIMAP4ServerDemo
Rev 1.19 2/22/2004 12:09:54 AM JPMugaas
Fixes for IMAP4Server compile failure in DotNET. This also fixes
a potential problem where file handles can be leaked in the server
needlessly.
Rev 1.18 12/02/2004 02:40:56 CCostelloe
Minor bugfix
Rev 1.17 12/02/2004 02:24:30 CCostelloe
Completed revision, apart from parts support and BODYSTRUCTURE, not
yet debugged.
Rev 1.16 05/02/2004 00:25:32 CCostelloe
This version actually works!
Rev 1.15 2/4/2004 2:37:38 AM JPMugaas
Moved more units down to the implementation clause in the units to
make them easier to compile.
Rev 1.14 2/3/2004 4:12:42 PM JPMugaas
Fixed up units so they should compile.
Rev 1.13 1/29/2004 9:07:54 PM JPMugaas
Now uses TIdExplicitTLSServer so it can take advantage of that framework.
Rev 1.12 1/21/2004 3:11:02 PM JPMugaas
InitComponent
Rev 1.11 27/12/2003 22:28:48 ANeillans
Design fix, Login event only passed the username (first param)
Rev 1.10 2003.10.21 9:13:08 PM czhower
Now compiles.
Rev 1.9 10/19/2003 6:00:24 PM DSiders
Added localization coimments.
Rev 1.8 9/19/2003 03:29:58 PM JPMugaas
Now should compile again.
Rev 1.7 07/09/2003 12:29:08 CCostelloe
Warning that variable LIO is declared but never used in
TIdIMAP4Server.DoCommandSTARTTLS fixed.
Rev 1.6 7/20/2003 6:20:06 PM SPerry
Switched to IdCmdTCPServer, also some modifications
Rev 1.5 3/14/2003 10:44:36 PM BGooijen
Removed warnings, changed StartSSL to PassThrough:=false;
Rev 1.4 3/14/2003 10:04:10 PM BGooijen
Removed TIdServerIOHandlerSSLBase.PeerPassthrough, the ssl is now
enabled in the server-protocol-files
Rev 1.3 3/13/2003 09:49:20 AM JPMugaas
Now uses an abstract SSL base class instead of OpenSSL so
3rd-party vendors can plug-in their products.
Rev 1.2 2/24/2003 09:03:14 PM JPMugaas
Rev 1.1 2/6/2003 03:18:14 AM JPMugaas
Updated components that compile with Indy 10.
Rev 1.0 11/13/2002 07:55:02 AM JPMugaas
2002-Apr-21 - J. Berg
use fetch()
2000-May-18 - J. Peter Mugaas
Ported to Indy
2000-Jan-13 - MTL
Moved to new Palette Scheme (Winshoes Servers)
1999-Aug-26 - Ray Malone
Started unit
}
unit IdIMAP4Server;
{
TODO (ex RFC 3501):
Dont allow & to be used as a mailbox separator.
Certain server data (unsolicited responses) MUST be recorded,
see Server Responses section.
UIDs must be unique to a mailbox AND any subsequent mailbox with
the same name - record in a text file.
\Recent cannot be changed by STORE or APPEND.
COPY should preserve the date of the original message.
TODO (ccostelloe):
Add a file recording the UIDVALIDITY in each mailbox.
Emails should be ordered in date order.
Optional date/time param to be implemented in APPEND.
Consider integrating IdUserAccounts into login mechanism
(or per-user passwords).
Implement utf mailbox encoding.
Implement * in message numbers.
Implement multiple-option FETCH commands (will need breaking out some
options which are abbreviations into their subsets).
Need some method of preserving flags permanently.
}
{
IMPLEMENTATION NOTES:
Major rewrite started 2nd February 2004, Ciaran Costelloe, ccostelloe@flogas.ie.
Prior to this, it was a simple wrapper class with a few problems.
Note that IMAP servers should return BAD for an unknown command or
invalid arguments (synthax errors and unsupported commands) and BAD
if the command is valid but there was some problem in executing
(e.g. trying a change an email's flag if it is a read-only mailbox).
FUseDefaultMechanismsForUnassignedCommands defaults to True: if you
set it to False, you need to implement command handlers for all the
commands you need to implement. If True, this class implements a
default mechanism and provides default behaviour for all commands.
It does not include any filesystem-specific functions, which you
need to implement.
The default behaviour uses a default password of 'admin' - change this
if you have any consideration for security!
FSaferMode defaults to False: you should probably leave it False for
testing, because this generates diagnostically-useful error messages.
However, setting it True generates minimal responses for the greeting
and for login failures, making life more difficult for a hacker.
WARNING: you should also implement one of the Indy-provided more-secure
logins than the default plaintext password login!
You may want to assign handlers to the OnBeforeCmd and OnBeforeSend
events to easily log data in & out of the server.
WARNING: TIdIMAP4PeerContext has a TIdMailBox which holds various
status info, including UIDs in its message collection. Do NOT use the
message collection for loading messages into, or you may thrash message
UIDs or flags!
}
interface
{$i IdCompilerDefines.inc}
{$IFDEF DOTNET}
{$I IdUnitPlatformOff.inc}
{$I IdSymbolPlatformOff.inc}
{$ENDIF}
uses
Classes,
IdAssignedNumbers,
IdCustomTCPServer, //for TIdServerContext
IdCmdTCPServer,
IdContext,
IdCommandHandlers,
IdException,
IdExplicitTLSClientServerBase,
IdIMAP4, //For some defines like TIdIMAP4ConnectionState
IdMailBox,
IdMessage,
IdReply,
IdReplyIMAP4,
IdTCPConnection,
IdYarn;
const
DEF_IMAP4_IMPLICIT_TLS = False;
type
TIMAP4CommandEvent = procedure(AContext: TIdContext; const ATag, ACmd: String) of object;
TIdIMAP4CommandBeforeEvent = procedure(ASender: TIdCommandHandlers; var AData: string; AContext: TIdContext) of object;
TIdIMAP4CommandBeforeSendEvent = procedure(AContext: TIdContext; AData: string) of object;
//For default mechanisms..
TIdIMAP4DefMech1 = function(ALoginName, AMailbox: string): Boolean of object;
TIdIMAP4DefMech2 = function(ALoginName, AMailBoxName: string; AMailBox: TIdMailBox): Boolean of object;
TIdIMAP4DefMech3 = function(ALoginName, AMailbox: string): string of object;
TIdIMAP4DefMech4 = function(ALoginName, AOldMailboxName, ANewMailboxName: string): Boolean of object;
TIdIMAP4DefMech5 = function(ALoginName, AMailBoxName: string; AMailBoxNames: TStrings; AMailBoxFlags: TStrings): Boolean of object;
TIdIMAP4DefMech6 = function(ALoginName, AMailbox: string; AMessage: TIdMessage): Boolean of object;
TIdIMAP4DefMech7 = function(ALoginName, ASourceMailBox, AMessageUID, ADestinationMailbox: string): Boolean of object;
TIdIMAP4DefMech8 = function(ALoginName, AMailbox: string; AMessage: TIdMessage): Int64 of object;
TIdIMAP4DefMech9 = function(ALoginName, AMailbox: string; AMessage, ATargetMessage: TIdMessage): Boolean of object;
TIdIMAP4DefMech10 = function(ALoginName, AMailbox: string; AMessage: TIdMessage; ALines: TStrings): Boolean of object;
TIdIMAP4DefMech11 = function(ASender: TIdCommand; AReadOnly: Boolean): Boolean of object;
TIdIMAP4DefMech12 = function(AParams: TStrings; AMailBoxParam: Integer): Boolean of object;
TIdIMAP4DefMech13 = function(ALoginName, AMailBoxName, ANewUIDNext: string): Boolean of object;
TIdIMAP4DefMech14 = function(ALoginName, AMailBoxName, AUID: string): string of object;
EIdIMAP4ServerException = class(EIdException);
EIdIMAP4ImplicitTLSRequiresSSL = class(EIdIMAP4ServerException);
{ custom IMAP4 context }
TIdIMAP4PeerContext = class(TIdServerContext)
protected
FConnectionState : TIdIMAP4ConnectionState;
FLoginName: string;
FMailBox: TIdMailBox;
FIMAP4Tag: String;
FLastCommand: TIdReplyIMAP4; //Used to record the client command we are currently processing
function GetUsingTLS: Boolean;
public
constructor Create(
AConnection: TIdTCPConnection;
AYarn: TIdYarn;
AList: TIdContextThreadList = nil
); override;
destructor Destroy; override;
property ConnectionState: TIdIMAP4ConnectionState read FConnectionState;
property UsingTLS : Boolean read GetUsingTLS;
property IMAP4Tag: String read FIMAP4Tag;
property MailBox: TIdMailBox read FMailBox;
property LoginName: string read FLoginName write FLoginName;
end;
{ TIdIMAP4Server }
TIdIMAP4Server = class(TIdExplicitTLSServer)
protected
//
FSaferMode: Boolean; //See IMPLEMENTATION NOTES above
FUseDefaultMechanismsForUnassignedCommands: Boolean; //See IMPLEMENTATION NOTES above
FRootPath: string; //See IMPLEMENTATION NOTES above
FDefaultPassword: string; //See IMPLEMENTATION NOTES above
FMailBoxSeparator: Char;
//
fOnDefMechDoesImapMailBoxExist: TIdIMAP4DefMech1;
fOnDefMechCreateMailBox: TIdIMAP4DefMech1;
fOnDefMechDeleteMailBox: TIdIMAP4DefMech1;
fOnDefMechIsMailBoxOpen: TIdIMAP4DefMech1;
fOnDefMechSetupMailbox: TIdIMAP4DefMech2;
fOnDefMechNameAndMailBoxToPath: TIdIMAP4DefMech3;
fOnDefMechGetNextFreeUID: TIdIMAP4DefMech3;
fOnDefMechRenameMailBox: TIdIMAP4DefMech4;
fOnDefMechListMailBox: TIdIMAP4DefMech5;
fOnDefMechDeleteMessage: TIdIMAP4DefMech6;
fOnDefMechCopyMessage: TIdIMAP4DefMech7;
fOnDefMechGetMessageSize: TIdIMAP4DefMech8;
fOnDefMechGetMessageHeader: TIdIMAP4DefMech9;
fOnDefMechGetMessageRaw: TIdIMAP4DefMech10;
fOnDefMechOpenMailBox: TIdIMAP4DefMech11;
fOnDefMechReinterpretParamAsMailBox: TIdIMAP4DefMech12;
fOnDefMechUpdateNextFreeUID: TIdIMAP4DefMech13;
fOnDefMechGetFileNameToWriteAppendMessage: TIdIMAP4DefMech14;
//
fOnBeforeCmd: TIdIMAP4CommandBeforeEvent;
fOnBeforeSend: TIdIMAP4CommandBeforeSendEvent;
fOnCommandCAPABILITY: TIMAP4CommandEvent;
fONCommandNOOP: TIMAP4CommandEvent;
fONCommandLOGOUT: TIMAP4CommandEvent;
fONCommandAUTHENTICATE: TIMAP4CommandEvent;
fONCommandLOGIN: TIMAP4CommandEvent;
fONCommandSELECT: TIMAP4CommandEvent;
fONCommandEXAMINE: TIMAP4CommandEvent;
fONCommandCREATE: TIMAP4CommandEvent;
fONCommandDELETE: TIMAP4CommandEvent;
fONCommandRENAME: TIMAP4CommandEvent;
fONCommandSUBSCRIBE: TIMAP4CommandEvent;
fONCommandUNSUBSCRIBE: TIMAP4CommandEvent;
fONCommandLIST: TIMAP4CommandEvent;
fONCommandLSUB: TIMAP4CommandEvent;
fONCommandSTATUS: TIMAP4CommandEvent;
fONCommandAPPEND: TIMAP4CommandEvent;
fONCommandCHECK: TIMAP4CommandEvent;
fONCommandCLOSE: TIMAP4CommandEvent;
fONCommandEXPUNGE: TIMAP4CommandEvent;
fONCommandSEARCH: TIMAP4CommandEvent;
fONCommandFETCH: TIMAP4CommandEvent;
fONCommandSTORE: TIMAP4CommandEvent;
fONCommandCOPY: TIMAP4CommandEvent;
fONCommandUID: TIMAP4CommandEvent;
fONCommandX: TIMAP4CommandEvent;
fOnCommandError: TIMAP4CommandEvent;
//
function CreateExceptionReply: TIdReply; override;
function CreateGreeting: TIdReply; override;
function CreateHelpReply: TIdReply; override;
function CreateMaxConnectionReply: TIdReply; override;
function CreateReplyUnknownCommand: TIdReply; override;
//
//The following are internal commands that help support the IMAP protocol...
procedure InitializeCommandHandlers; override;
function GetReplyClass:TIdReplyClass; override;
function GetRepliesClass:TIdRepliesClass; override;
procedure SendGreeting(AContext: TIdContext; AGreeting: TIdReply); override;
procedure SendWrongConnectionState(ASender: TIdCommand);
procedure SendUnsupportedCommand(ASender: TIdCommand);
procedure SendIncorrectNumberOfParameters(ASender: TIdCommand);
procedure SendUnassignedDefaultMechanism(ASender: TIdCommand);
procedure DoReplyUnknownCommand(AContext: TIdContext; AText: string); override;
procedure SendErrorOpenedReadOnly(ASender: TIdCommand);
procedure SendOkReply(ASender: TIdCommand; const AText: string);
procedure SendBadReply(ASender: TIdCommand; const AText: string); overload;
procedure SendBadReply(ASender: TIdCommand; const AFormat: string; const Args: array of const); overload;
procedure SendNoReply(ASender: TIdCommand; const AText: string = ''); overload;
procedure SendNoReply(ASender: TIdCommand; const AFormat: string; const Args: array of const); overload;
//
//The following are used internally by the default mechanism...
function ExpungeRecords(ASender: TIdCommand): Boolean;
function MessageSetToMessageNumbers(AUseUID: Boolean; ASender: TIdCommand; AMessageNumbers: TStrings; AMessageSet: string): Boolean;
function GetRecordForUID(const AUID: String; AMailBox: TIdMailBox): Int64;
procedure ProcessFetch(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings);
procedure ProcessCopy(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings);
function ProcessStore(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings): Boolean;
procedure ProcessSearch(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings);
function FlagStringToFlagList(AFlagList: TStrings; AFlagString: string): Boolean;
function StripQuotesIfNecessary(AName: string): string;
function ReassembleParams(ASeparator: char; AParams: TStrings; AParamToReassemble: integer): Boolean;
function ReinterpretParamAsMailBox(AParams: TStrings; AMailBoxParam: integer): Boolean;
function ReinterpretParamAsFlags(AParams: TStrings; AFlagsParam: integer): Boolean;
function ReinterpretParamAsQuotedStr(AParams: TStrings; AFlagsParam: integer): Boolean;
function ReinterpretParamAsDataItems(AParams: TStrings; AFlagsParam: integer): Boolean;
//
//The following are used internally by our default mechanism and are copies of
//the same function in TIdIMAP4 (move to a base class?)...
function MessageFlagSetToStr(const AFlags: TIdMessageFlagsSet): String;
//
//DoBeforeCmd & DoSendReply are useful for a server to log all commands and
//responses for debugging...
procedure DoBeforeCmd(ASender: TIdCommandHandlers; var AData: string; AContext: TIdContext);
procedure DoSendReply(AContext: TIdContext; const AData: string); overload;
procedure DoSendReply(AContext: TIdContext; const AFormat: string; const Args: array of const); overload;
//
//Command handlers...
procedure DoCmdHandlersException(ACommand: String; AContext: TIdContext);
procedure DoCommandCAPABILITY(ASender: TIdCommand);
procedure DoCommandNOOP(ASender: TIdCommand);
procedure DoCommandLOGOUT(ASender: TIdCommand);
procedure DoCommandAUTHENTICATE(ASender: TIdCommand);
procedure DoCommandLOGIN(ASender: TIdCommand);
procedure DoCommandSELECT(ASender: TIdCommand);
procedure DoCommandEXAMINE(ASender: TIdCommand);
procedure DoCommandCREATE(ASender: TIdCommand);
procedure DoCommandDELETE(ASender: TIdCommand);
procedure DoCommandRENAME(ASender: TIdCommand);
procedure DoCommandSUBSCRIBE(ASender: TIdCommand);
procedure DoCommandUNSUBSCRIBE(ASender: TIdCommand);
procedure DoCommandLIST(ASender: TIdCommand);
procedure DoCommandLSUB(ASender: TIdCommand);
procedure DoCommandSTATUS(ASender: TIdCommand);
procedure DoCommandAPPEND(ASender: TIdCommand);
procedure DoCommandCHECK(ASender: TIdCommand);
procedure DoCommandCLOSE(ASender: TIdCommand);
procedure DoCommandEXPUNGE(ASender: TIdCommand);
procedure DoCommandSEARCH(ASender: TIdCommand);
procedure DoCommandFETCH(ASender: TIdCommand);
procedure DoCommandSTORE(ASender: TIdCommand);
procedure DoCommandCOPY(ASender: TIdCommand);
procedure DoCommandUID(ASender: TIdCommand);
procedure DoCommandX(ASender: TIdCommand);
procedure DoCommandSTARTTLS(ASender: TIdCommand);
// common code for command handlers
procedure MustUseTLS(ASender: TIdCommand);
//
procedure InitComponent; override;
public
{$IFDEF WORKAROUND_INLINE_CONSTRUCTORS}
constructor Create(AOwner: TComponent); reintroduce; overload;
{$ENDIF}
destructor Destroy; override;
published
property DefaultPort default IdPORT_IMAP4;
property SaferMode: Boolean read FSaferMode write FSaferMode default False;
property UseDefaultMechanismsForUnassignedCommands: Boolean read FUseDefaultMechanismsForUnassignedCommands write FUseDefaultMechanismsForUnassignedCommands default True;
property RootPath: string read FRootPath write FRootPath;
property DefaultPassword: string read FDefaultPassword write FDefaultPassword;
property MailBoxSeparator: Char read FMailBoxSeparator;
{Default mechansisms}
property OnDefMechDoesImapMailBoxExist: TIdIMAP4DefMech1 read fOnDefMechDoesImapMailBoxExist write fOnDefMechDoesImapMailBoxExist;
property OnDefMechCreateMailBox: TIdIMAP4DefMech1 read fOnDefMechCreateMailBox write fOnDefMechCreateMailBox;
property OnDefMechDeleteMailBox: TIdIMAP4DefMech1 read fOnDefMechDeleteMailBox write fOnDefMechDeleteMailBox;
property OnDefMechIsMailBoxOpen: TIdIMAP4DefMech1 read fOnDefMechIsMailBoxOpen write fOnDefMechIsMailBoxOpen;
property OnDefMechSetupMailbox: TIdIMAP4DefMech2 read fOnDefMechSetupMailbox write fOnDefMechSetupMailbox;
property OnDefMechNameAndMailBoxToPath: TIdIMAP4DefMech3 read fOnDefMechNameAndMailBoxToPath write fOnDefMechNameAndMailBoxToPath;
property OnDefMechGetNextFreeUID: TIdIMAP4DefMech3 read fOnDefMechGetNextFreeUID write fOnDefMechGetNextFreeUID;
property OnDefMechRenameMailBox: TIdIMAP4DefMech4 read fOnDefMechRenameMailBox write fOnDefMechRenameMailBox;
property OnDefMechListMailBox: TIdIMAP4DefMech5 read fOnDefMechListMailBox write fOnDefMechListMailBox;
property OnDefMechDeleteMessage: TIdIMAP4DefMech6 read fOnDefMechDeleteMessage write fOnDefMechDeleteMessage;
property OnDefMechCopyMessage: TIdIMAP4DefMech7 read fOnDefMechCopyMessage write fOnDefMechCopyMessage;
property OnDefMechGetMessageSize: TIdIMAP4DefMech8 read fOnDefMechGetMessageSize write fOnDefMechGetMessageSize;
property OnDefMechGetMessageHeader: TIdIMAP4DefMech9 read fOnDefMechGetMessageHeader write fOnDefMechGetMessageHeader;
property OnDefMechGetMessageRaw: TIdIMAP4DefMech10 read fOnDefMechGetMessageRaw write fOnDefMechGetMessageRaw;
property OnDefMechOpenMailBox: TIdIMAP4DefMech11 read fOnDefMechOpenMailBox write fOnDefMechOpenMailBox;
property OnDefMechReinterpretParamAsMailBox: TIdIMAP4DefMech12 read fOnDefMechReinterpretParamAsMailBox write fOnDefMechReinterpretParamAsMailBox;
property OnDefMechUpdateNextFreeUID: TIdIMAP4DefMech13 read fOnDefMechUpdateNextFreeUID write fOnDefMechUpdateNextFreeUID;
property OnDefMechGetFileNameToWriteAppendMessage: TIdIMAP4DefMech14 read fOnDefMechGetFileNameToWriteAppendMessage write fOnDefMechGetFileNameToWriteAppendMessage;
{ Events }
property OnBeforeCmd: TIdIMAP4CommandBeforeEvent read fOnBeforeCmd write fOnBeforeCmd;
property OnBeforeSend: TIdIMAP4CommandBeforeSendEvent read fOnBeforeSend write fOnBeforeSend;
property OnCommandCAPABILITY: TIMAP4CommandEvent read fOnCommandCAPABILITY write fOnCommandCAPABILITY;
property OnCommandNOOP: TIMAP4CommandEvent read fONCommandNOOP write fONCommandNOOP;
property OnCommandLOGOUT: TIMAP4CommandEvent read fONCommandLOGOUT write fONCommandLOGOUT;
property OnCommandAUTHENTICATE: TIMAP4CommandEvent read fONCommandAUTHENTICATE write fONCommandAUTHENTICATE;
property OnCommandLOGIN: TIMAP4CommandEvent read fONCommandLOGIN write fONCommandLOGIN;
property OnCommandSELECT: TIMAP4CommandEvent read fONCommandSELECT write fONCommandSELECT;
property OnCommandEXAMINE:TIMAP4CommandEvent read fOnCommandEXAMINE write fOnCommandEXAMINE;
property OnCommandCREATE: TIMAP4CommandEvent read fONCommandCREATE write fONCommandCREATE;
property OnCommandDELETE: TIMAP4CommandEvent read fONCommandDELETE write fONCommandDELETE;
property OnCommandRENAME: TIMAP4CommandEvent read fOnCommandRENAME write fOnCommandRENAME;
property OnCommandSUBSCRIBE: TIMAP4CommandEvent read fONCommandSUBSCRIBE write fONCommandSUBSCRIBE;
property OnCommandUNSUBSCRIBE: TIMAP4CommandEvent read fONCommandUNSUBSCRIBE write fONCommandUNSUBSCRIBE;
property OnCommandLIST: TIMAP4CommandEvent read fONCommandLIST write fONCommandLIST;
property OnCommandLSUB: TIMAP4CommandEvent read fOnCommandLSUB write fOnCommandLSUB;
property OnCommandSTATUS: TIMAP4CommandEvent read fONCommandSTATUS write fONCommandSTATUS;
property OnCommandAPPEND: TIMAP4CommandEvent read fOnCommandAPPEND write fOnCommandAPPEND;
property OnCommandCHECK: TIMAP4CommandEvent read fONCommandCHECK write fONCommandCHECK;
property OnCommandCLOSE: TIMAP4CommandEvent read fOnCommandCLOSE write fOnCommandCLOSE;
property OnCommandEXPUNGE: TIMAP4CommandEvent read fONCommandEXPUNGE write fONCommandEXPUNGE;
property OnCommandSEARCH: TIMAP4CommandEvent read fOnCommandSEARCH write fOnCommandSEARCH;
property OnCommandFETCH: TIMAP4CommandEvent read fONCommandFETCH write fONCommandFETCH;
property OnCommandSTORE: TIMAP4CommandEvent read fOnCommandSTORE write fOnCommandSTORE;
property OnCommandCOPY: TIMAP4CommandEvent read fOnCommandCOPY write fOnCommandCOPY;
property OnCommandUID: TIMAP4CommandEvent read fONCommandUID write fONCommandUID;
property OnCommandX: TIMAP4CommandEvent read fOnCommandX write fOnCommandX;
property OnCommandError: TIMAP4CommandEvent read fOnCommandError write fOnCommandError;
end;
implementation
uses
IdGlobal,
IdGlobalProtocols,
IdMessageCollection,
IdResourceStrings,
IdResourceStringsProtocols,
IdSSL,
IdStream,
SysUtils;
function TIdIMAP4Server.GetReplyClass: TIdReplyClass;
begin
Result := TIdReplyIMAP4;
end;
function TIdIMAP4Server.GetRepliesClass: TIdRepliesClass;
begin
Result := TIdRepliesIMAP4;
end;
procedure TIdIMAP4Server.SendGreeting(AContext: TIdContext; AGreeting: TIdReply);
begin
if FSaferMode then begin
DoSendReply(AContext, '* OK'); {Do not Localize}
end else begin
DoSendReply(AContext, '* OK Indy IMAP server version ' + GetIndyVersion); {Do not Localize}
end;
end;
procedure TIdIMAP4Server.SendWrongConnectionState(ASender: TIdCommand);
begin
SendNoReply(ASender, 'Wrong connection state'); {Do not Localize}
end;
procedure TIdIMAP4Server.SendErrorOpenedReadOnly(ASender: TIdCommand);
begin
SendNoReply(ASender, 'Mailbox was opened read-only'); {Do not Localize}
end;
procedure TIdIMAP4Server.SendUnsupportedCommand(ASender: TIdCommand);
begin
SendBadReply(ASender, 'Unsupported command'); {Do not Localize}
end;
procedure TIdIMAP4Server.SendIncorrectNumberOfParameters(ASender: TIdCommand);
begin
SendBadReply(ASender, 'Incorrect number of parameters'); {Do not Localize}
end;
procedure TIdIMAP4Server.SendUnassignedDefaultMechanism(ASender: TIdCommand);
begin
SendBadReply(ASender, 'Server internal error: unassigned procedure'); {Do not Localize}
end;
procedure TIdIMAP4Server.SendOkReply(ASender: TIdCommand; const AText: string);
begin
DoSendReply(ASender.Context, TIdIMAP4PeerContext(ASender.Context).FLastCommand.SequenceNumber + ' OK ' + AText); {Do not Localize}
end;
procedure TIdIMAP4Server.SendBadReply(ASender: TIdCommand; const AText: string);
begin
DoSendReply(ASender.Context, TIdIMAP4PeerContext(ASender.Context).FLastCommand.SequenceNumber + ' BAD ' + AText); {Do not Localize}
end;
procedure TIdIMAP4Server.SendBadReply(ASender: TIdCommand; const AFormat: string; const Args: array of const);
begin
SendBadReply(ASender, IndyFormat(AFormat, Args));
end;
procedure TIdIMAP4Server.SendNoReply(ASender: TIdCommand; const AText: string = '');
begin
if AText <> '' then begin
DoSendReply(ASender.Context, TIdIMAP4PeerContext(ASender.Context).FLastCommand.SequenceNumber + ' NO ' + AText); {Do not Localize}
end else begin
DoSendReply(ASender.Context, TIdIMAP4PeerContext(ASender.Context).FLastCommand.SequenceNumber + ' NO'); {Do not Localize}
end;
end;
procedure TIdIMAP4Server.SendNoReply(ASender: TIdCommand; const AFormat: string; const Args: array of const);
begin
SendNoReply(ASender, IndyFormat(AFormat, Args));
end;
{$IFDEF WORKAROUND_INLINE_CONSTRUCTORS}
constructor TIdIMAP4Server.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
{$ENDIF}
procedure TIdIMAP4Server.InitComponent;
begin
inherited InitComponent;
//Todo: Not sure which number is appropriate. Should be tested
FRegularProtPort := IdPORT_IMAP4;
FImplicitTLSProtPort := IdPORT_IMAP4S; //Id_PORT_imap4_ssl_dp;
FExplicitTLSProtPort := IdPORT_IMAP4;
DefaultPort := IdPORT_IMAP4;
ContextClass := TIdIMAP4PeerContext;
FSaferMode := False;
FUseDefaultMechanismsForUnassignedCommands := True;
{$IFDEF UNIX}
FRootPath := GPathDelim + 'var' + GPathDelim + 'imapmail'; {Do not Localize}
{$ELSE}
FRootPath := GPathDelim + 'imapmail'; {Do not Localize}
{$ENDIF}
FDefaultPassword := 'admin'; {Do not Localize}
FMailBoxSeparator := '.'; {Do not Localize}
end;
destructor TIdIMAP4Server.Destroy;
begin
inherited Destroy;
end;
function TIdIMAP4Server.CreateExceptionReply: TIdReply;
begin
Result := TIdReplyIMAP4.CreateWithReplyTexts(nil, ReplyTexts);
Result.SetReply(IMAP_BAD, 'Unknown Internal Error'); {do not localize}
end;
function TIdIMAP4Server.CreateGreeting: TIdReply;
begin
Result := TIdReplyIMAP4.CreateWithReplyTexts(nil, ReplyTexts);
Result.SetReply(IMAP_OK, 'Welcome'); {do not localize}
end;
function TIdIMAP4Server.CreateHelpReply: TIdReply;
begin
Result := TIdReplyIMAP4.CreateWithReplyTexts(nil, ReplyTexts);
Result.SetReply(IMAP_OK, 'Help follows'); {do not localize}
end;
function TIdIMAP4Server.CreateMaxConnectionReply: TIdReply;
begin
Result := TIdReplyIMAP4.CreateWithReplyTexts(nil, ReplyTexts);
Result.SetReply(IMAP_BAD, 'Too many connections. Try again later.'); {do not localize}
end;
function TIdIMAP4Server.CreateReplyUnknownCommand: TIdReply;
begin
Result := TIdReplyIMAP4.CreateWithReplyTexts(nil, ReplyTexts);
Result.SetReply(IMAP_BAD, 'Unknown command'); {do not localize}
end;
constructor TIdIMAP4PeerContext.Create(AConnection: TIdTCPConnection; AYarn: TIdYarn; AList: TIdContextThreadList = nil);
begin
inherited Create(AConnection, AYarn, AList);
FMailBox := TIdMailBox.Create;
FLastCommand := TIdReplyIMAP4.Create(nil);
FConnectionState := csAny;
end;
destructor TIdIMAP4PeerContext.Destroy;
begin
FreeAndNil(FLastCommand);
FreeAndNil(FMailBox);
inherited Destroy;
end;
function TIdIMAP4PeerContext.GetUsingTLS: Boolean;
begin
if Connection.IOHandler is TIdSSLIOHandlerSocketBase then begin
Result := not TIdSSLIOHandlerSocketBase(Connection.IOHandler).PassThrough;
end else begin
Result := False;
end;
end;
procedure TIdIMAP4Server.DoReplyUnknownCommand(AContext: TIdContext; AText: string);
//AText is ignored by TIdIMAP4Server
var
LText: string;
begin
LText := TIdIMAP4PeerContext(AContext).FLastCommand.SequenceNumber;
if LText = '' then begin
//This should not happen!
LText := '*'; {Do not Localize}
end;
DoSendReply(AContext, LText + ' NO Unknown command'); {Do not Localize}
end;
function TIdIMAP4Server.ExpungeRecords(ASender: TIdCommand): Boolean;
var
LN: integer;
LMessage: TIdMessage;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
//Delete all records that have the deleted flag set...
LN := 0;
Result := True;
while LN < LContext.MailBox.MessageList.Count do begin
LMessage := LContext.MailBox.MessageList.Messages[LN];
if mfDeleted in LMessage.Flags then begin
if not OnDefMechDeleteMessage(LContext.LoginName, LContext.MailBox.Name, LMessage) then
begin
Result := False;
end;
LContext.MailBox.MessageList.Delete(LN);
LContext.MailBox.TotalMsgs := LContext.MailBox.TotalMsgs - 1;
end else begin
Inc(LN);
end;
end;
end;
function TIdIMAP4Server.MessageSetToMessageNumbers(AUseUID: Boolean; ASender: TIdCommand;
AMessageNumbers: TStrings; AMessageSet: string): Boolean;
{AMessageNumbers may be '7' or maybe '2:4' (2, 3 & 4) or maybe '2,4,6' (2, 4 & 6)
or maybe '1:*'}
var
LPos: integer;
LStart: Int64;
LN: Int64;
LEnd: Int64;
LTemp: string;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
AMessageNumbers.BeginUpdate;
try
AMessageNumbers.Clear;
//See is it a sequence like 2:4 ...
LPos := IndyPos(':', AMessageSet); {Do not Localize}
if LPos > 0 then begin
LTemp := Copy(AMessageSet, 1, LPos-1);
LStart := IndyStrToInt64(LTemp);
LTemp := Copy(AMessageSet, LPos+1, MAXINT);
if LTemp = '*' then begin {Do not Localize}
if AUseUID then begin
LEnd := IndyStrToInt64(LContext.MailBox.UIDNext)-1;
end else begin
LEnd := LContext.MailBox.MessageList.Count;
end;
end else begin
LEnd := IndyStrToInt64(LTemp);
end;
// RLebeau 2/4/2020: using a 'while' loop instead of a 'for' loop, because the
// LN variable is an Int64 and Delphi prior to XE8 will fail to compile on it
// with a "For loop control variable must have ordinal type" error...
{
for LN := LStart to LEnd do begin
AMessageNumbers.Add(IntToStr(LN));
end;
}
LN := LStart;
while LN <= LEnd do begin
AMessageNumbers.Add(IntToStr(LN));
Inc(LN);
end;
end else begin
//See is it a comma-separated list...
LPos := IndyPos(',', AMessageSet); {Do not Localize}
if LPos = 0 then begin
AMessageNumbers.Add(AMessageSet);
end else begin
BreakApart(AMessageSet, ',', AMessageNumbers); {Do not Localize}
end;
end;
finally
AMessageNumbers.EndUpdate;
end;
Result := True;
end;
//Return -1 if not found
function TIdIMAP4Server.GetRecordForUID(const AUID: String; AMailBox: TIdMailBox): Int64;
var
LN: Integer;
LUID: Int64;
begin
// TODO: do string comparisons instead so that conversions are not needed?
LUID := IndyStrToInt64(AUID);
for LN := 0 to AMailBox.MessageList.Count-1 do begin
if IndyStrToInt64(AMailBox.MessageList.Messages[LN].UID) = LUID then begin
Result := LN;
Exit;
end;
end;
Result := -1;
end;
function TIdIMAP4Server.StripQuotesIfNecessary(AName: string): string;
begin
if Length(AName) > 0 then begin
if (AName[1] = '"') and (AName[Length(Result)] = '"') then begin {Do not Localize}
Result := Copy(AName, 2, Length(AName)-2);
Exit;
end;
end;
Result := AName;
end;
function TIdIMAP4Server.ReassembleParams(ASeparator: Char; AParams: TStrings;
AParamToReassemble: Integer): Boolean;
var
LEndSeparator: char;
LTemp: string;
LN: integer;
LReassembledParam: string;
begin
Result := False;
case ASeparator of
'(': LEndSeparator := ')'; {Do not Localize}
'[': LEndSeparator := ']'; {Do not Localize}
else LEndSeparator := ASeparator;
end;
LTemp := AParams[AParamToReassemble];
if (LTemp = '') or (LTemp[1] <> ASeparator) then begin
Exit;
end;
if LTemp[Length(LTemp)] = LEndSeparator then begin
AParams[AParamToReassemble] := Copy(LTemp, 2, Length(LTemp)-2);
Result := True;
Exit;
end;
LReassembledParam := Copy(LTemp, 2, MAXINT);
LN := AParamToReassemble + 1;
repeat
if LN >= AParams.Count - 1 then begin
Result := False;
Exit; //Error
end;
LTemp := AParams[LN];
AParams.Delete(LN);
if LTemp[Length(LTemp)] = LEndSeparator then begin
AParams[AParamToReassemble] := LReassembledParam + ' ' + Copy(LTemp, 1, Length(LTemp)-1); {Do not Localize}
Result := True;
Exit; //This is example 1
end;
LReassembledParam := LReassembledParam + ' ' + LTemp; {Do not Localize}
until False;
end;
//This reorganizes the parameter list on the basis that AMailBoxParam is a
//mailbox name, which may (if enclosed in quotes) be in more than one param.
//Example 1: '43' '"My' 'Documents"' '5' -> '43' 'My Documents' '5'
//Example 2: '43' '"MyDocs"' '5' -> '43' 'MyDocs' '5'
//Example 3: '43' 'MyDocs' '5' -> '43' 'MyDocs' '5'
function TIdIMAP4Server.ReinterpretParamAsMailBox(AParams: TStrings; AMailBoxParam: Integer): Boolean;
var
LTemp: string;
begin
if (AMailBoxParam < 0) or (AMailBoxParam >= AParams.Count) then begin
Result := False;
Exit;
end;
LTemp := AParams[AMailBoxParam];
if LTemp = '' then begin
Result := False;
Exit;
end;
if LTemp[1] <> '"' then begin {Do not Localize}
Result := True;
Exit; //This is example 3, no change.
end;
Result := ReassembleParams('"', AParams, AMailBoxParam); {Do not Localize}
end;
function TIdIMAP4Server.ReinterpretParamAsFlags(AParams: TStrings; AFlagsParam: Integer): Boolean;
begin
Result := ReassembleParams('(', AParams, AFlagsParam); {Do not Localize}
end;
function TIdIMAP4Server.ReinterpretParamAsQuotedStr(AParams: TStrings; AFlagsParam: integer): Boolean;
begin
Result := ReassembleParams('"', AParams, AFlagsParam); {Do not Localize}
end;
function TIdIMAP4Server.ReinterpretParamAsDataItems(AParams: TStrings; AFlagsParam: Integer): Boolean;
begin
Result := ReassembleParams('(', AParams, AFlagsParam); {Do not Localize}
end;
function TIdIMAP4Server.FlagStringToFlagList(AFlagList: TStrings; AFlagString: string): Boolean;
var
LTemp: string;
begin
AFlagList.BeginUpdate;
try
AFlagList.Clear;
if (AFlagString <> '') and (AFlagString[1] = '(') and (AFlagString[Length(AFlagString)] = ')') then begin {Do not Localize}
LTemp := Copy(AFlagString, 2, Length(AFlagString)-2);
BreakApart(LTemp, ' ', AFlagList); {Do not Localize}
Result := True;
end else begin
Result := False;
end;
finally
AFlagList.EndUpdate;
end;
end;
procedure TIdIMAP4Server.ProcessFetch(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings);
//There are a pile of options for this.
var
LMessageNumbers: TStringList;
LDataItems: TStringList;
LM: integer;
LN: integer;
LLO: integer;
LRecord: Int64;
LSize: Int64;
LMessageToCheck, LMessageTemp: TIdMessage;
LMessageRaw: TStringList;
LTemp: string;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
//First param is a message set, e.g. 41 or 2:5 (which is 2, 3, 4 & 5)
LMessageNumbers := TStringList.Create;
try
if not MessageSetToMessageNumbers(AUseUID, ASender, LMessageNumbers, AParams[0]) then begin
SendBadReply(ASender, 'Error in syntax of message set parameter'); {Do not Localize}
Exit;
end;
if not ReinterpretParamAsDataItems(AParams, 1) then begin
SendBadReply(ASender, 'Fetch data items parameter is invalid.'); {Do not Localize}
Exit;
end;
LDataItems := TStringList.Create;
try
BreakApart(AParams[1], ' ', LDataItems);
for LN := 0 to LMessageNumbers.Count-1 do begin
if AUseUID then begin
LRecord := GetRecordForUID(LMessageNumbers[LN], LContext.MailBox);
if LRecord = -1 then begin //It is OK to skip non-existent UID records
Continue;
end;
end else begin
LRecord := IndyStrToInt64(LMessageNumbers[LN])-1;
end;
if (LRecord < 0) or (LRecord > LContext.MailBox.MessageList.Count) then begin
SendBadReply(ASender, 'Message number %d does not exist', [LRecord+1]); {Do not Localize}
Exit;
end;
LMessageToCheck := LContext.MailBox.MessageList.Messages[LRecord];
for LLO := 0 to LDataItems.Count-1 do begin
if TextIsSame(LDataItems[LLO], 'UID') then begin {Do not Localize}
//Format:
//C9 FETCH 490 (UID)
//* 490 FETCH (UID 6545)
//C9 OK Completed
DoSendReply(ASender.Context, '* FETCH (UID %s)', [LMessageToCheck.UID]); {Do not Localize}
end
else if TextIsSame(LDataItems[LLO], 'FLAGS') then begin {Do not Localize}
//Format:
//C10 UID FETCH 6545 (FLAGS)
//* 490 FETCH (FLAGS (\Recent) UID 6545)
//C10 OK Completed
if AUseUID then begin
DoSendReply(ASender.Context, '* %d FETCH (FLAGS (%s) UID %s)', {Do not Localize}
[LRecord+1, MessageFlagSetToStr(LMessageToCheck.Flags), LMessageNumbers[LN]]);
end else begin
DoSendReply(ASender.Context, '* %d FETCH (FLAGS (%s))', {Do not Localize}
[LRecord+1, MessageFlagSetToStr(LMessageToCheck.Flags)]);
end;
end
else if TextIsSame(LDataItems[LLO], 'RFC822.HEADER') then begin {Do not Localize}
//Format:
//C11 UID FETCH 6545 (RFC822.HEADER)
//* 490 FETCH (UID 6545 RFC822.HEADER {1654}
//Return-Path: <Christina_Powell@secondhandcars.com>
//...
//Content-Type: multipart/alternative;
// boundary="----=_NextPart_000_70BE_C8606D03.F4EA24EE"
//C10 OK Completed
//We don't want to thrash UIDs and flags in MailBox message, so load into LMessage
LMessageTemp := TIdMessage.Create;
try
if not OnDefMechGetMessageHeader(LContext.LoginName, LContext.MailBox.Name, LMessageToCheck, LMessageTemp) then begin
SendNoReply(ASender, 'Failed to get message header'); {Do not Localize}
Exit;
end;
//Need to calculate the size of the headers...
LSize := 0;
for LM := 0 to LMessageTemp.Headers.Count-1 do begin
Inc(LSize, Length(LMessageTemp.Headers.Strings[LM]) + 2); //Allow for CR+LF
end;
if AUseUID then begin
DoSendReply(ASender.Context, '* %d FETCH (UID %s RFC822.HEADER {%d}', {Do not Localize}
[LRecord+1, LMessageNumbers[LN], LSize]);
end else begin
DoSendReply(ASender.Context, '* %d FETCH (RFC822.HEADER {%d}', {Do not Localize}
[LRecord+1, LSize]);
end;
for LM := 0 to LMessageTemp.Headers.Count-1 do begin
DoSendReply(ASender.Context, LMessageTemp.Headers.Strings[LM]);
end;
DoSendReply(ASender.Context, ')'); {Do not Localize}
//Finished with the headers, free the memory...
finally
FreeAndNil(LMessageTemp);
end;
end
else if TextIsSame(LDataItems[LLO], 'RFC822.SIZE') then begin {Do not Localize}
//Format:
//C12 UID FETCH 6545 (RFC822.SIZE)
//* 490 FETCH (UID 6545 RFC822.SIZE 3447)
//C12 OK Completed
LSize := OnDefMechGetMessageSize(LContext.LoginName, LContext.MailBox.Name, LMessageToCheck);
if LSize = -1 then begin
SendNoReply(ASender, 'Failed to get message size'); {Do not Localize}
Exit;
end;
if AUseUID then begin
DoSendReply(ASender.Context, '* %d FETCH (UID %s RFC822.SIZE %d)', {Do not Localize}
[LRecord+1, LMessageNumbers[LN], LSize]);
end else begin
DoSendReply(ASender.Context, '* %d FETCH (RFC822.SIZE %d)', {Do not Localize}
[LRecord+1, LSize]);
end;
end
else if PosInStrArray(LDataItems[LLO], ['BODY.PEEK[]', 'BODY[]', 'RFC822', 'RFC822.PEEK'], False) <> -1 then {Do not Localize}
begin
//All are the same, except the return string is different...
LMessageRaw := TStringList.Create;
try
if not OnDefMechGetMessageRaw(LContext.LoginName, LContext.MailBox.Name, LMessageToCheck, LMessageRaw) then
begin
SendNoReply(ASender, 'Failed to get raw message'); {Do not Localize}
Exit;
end;
LSize := 0;
for LM := 0 to LMessageToCheck.Headers.Count-1 do begin
Inc(LSize, Length(LMessageRaw.Strings[LM]) + 2); //Allow for CR+LF
end;
Inc(LSize, 3); //The message terminator '.CRLF'
LTemp := Copy(AParams[1], 2, Length(AParams[1])-2);
if AUseUID then begin
DoSendReply(ASender.Context, '* %d FETCH (FLAGS (%s) UID %s %s {%d}', {Do not Localize}
[LRecord+1, MessageFlagSetToStr(LMessageToCheck.Flags), LMessageNumbers[LN], LTemp, LSize]);
end else begin
DoSendReply(ASender.Context, '* %d FETCH (FLAGS (%s) %s {%d}', {Do not Localize}
[LRecord+1, MessageFlagSetToStr(LMessageToCheck.Flags), LTemp, LSize]);
end;
for LM := 0 to LMessageToCheck.Headers.Count-1 do begin
DoSendReply(ASender.Context, LMessageRaw.Strings[LM]);
end;
DoSendReply(ASender.Context, '.'); {Do not Localize}
DoSendReply(ASender.Context, ')'); {Do not Localize}
//Free the memory...
finally
FreeAndNil(LMessageRaw);
end;
end
else if TextIsSame(LDataItems[LLO], 'BODYSTRUCTURE') then begin {Do not Localize}
//Format:
//C49 UID FETCH 6545 (BODYSTRUCTURE)
//* 490 FETCH (UID 6545 BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "iso-8859-1") NIL NIL "7BIT" 290 8 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "iso-8859-1") NIL NIL "7BIT" 1125 41 NIL NIL NIL) "ALTERNATIVE" ("BOUNDARY"
//C12 OK Completed
SendBadReply(ASender, 'Parameter not supported: ' + AParams[1]); {Do not Localize}
end
else if TextStartsWith(LDataItems[LLO], 'BODY[') or TextStartsWith(LDataItems[LLO], 'BODY.PEEK[') then begin {Do not Localize}
//Format:
//C50 UID FETCH 6545 (BODY[1])
//* 490 FETCH (FLAGS (\Recent \Seen) UID 6545 BODY[1] {290}
//...
//)
//C50 OK Completed
SendBadReply(ASender, 'Parameter not supported: ' + AParams[1]); {Do not Localize}
end
else begin
SendBadReply(ASender, 'Parameter not supported: ' + AParams[1]); {Do not Localize}
Exit;
end;
end;
end;
finally
FreeAndNil(LDataItems);
end;
finally
FreeAndNil(LMessageNumbers);
end;
SendOkReply(ASender, 'Completed'); {Do not Localize}
end;
procedure TIdIMAP4Server.ProcessSearch(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings);
//if AUseUID is True, return UIDs rather than relative message numbers.
var
LSearchString: string;
LN: Integer;
LM: Integer;
LItem: Integer;
LMessageToCheck, LMessageTemp: TIdMessage;
LHits: string;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
//Watch out: you could become an old man trying to implement all the IMAP
//search options, just do a subset.
//Format:
//C1065 UID SEARCH FROM "visible"
//* SEARCH 5769 5878
//C1065 OK Completed (2 msgs in 0.010 secs)
if AParams.Count < 2 then begin //The only search options we support are 2-param ones
SendIncorrectNumberOfParameters(ASender);
//LParams.Free;
Exit;
end;
LItem := PosInStrArray(AParams[0], ['FROM', 'TO', 'CC', 'BCC', 'SUBJECT'], False);
if LItem = -1 then begin {Do not Localize}
SendBadReply(ASender, 'Unsupported search method'); {Do not Localize}
Exit;
end;
//Reassemble the other params into a line, because "Ciaran Costelloe" will be params 1 & 2...
LSearchString := AParams[1];
for LN := 2 to AParams.Count-1 do begin
LSearchString := LSearchString + ' ' + AParams[LN]; {Do not Localize}
end;
if (LSearchString[1] = '"') and (LSearchString[Length(LSearchString)] = '"') then begin {Do not Localize}
LSearchString := Copy(LSearchString, 2, Length(LSearchString)-2);
end;
LHits := '';
LMessageTemp := TIdMessage.Create;
try
for LN := 0 to LContext.MailBox.MessageList.Count-1 do begin
LMessageToCheck := LContext.MailBox.MessageList.Messages[LN];
if not OnDefMechGetMessageHeader(LContext.LoginName, LContext.MailBox.Name, LMessageToCheck, LMessageTemp) then
begin
SendNoReply(ASender, 'Failed to get message header'); {Do not Localize}
Exit;
end;
case LItem of
0: // FROM {Do not Localize}
begin
if Pos(UpperCase(LSearchString), UpperCase(LMessageTemp.From.Address)) > 0 then begin
if AUseUID then begin
LHits := LHits + LMessageToCheck.UID + ' '; {Do not Localize}
end else begin
LHits := LHits + IntToStr(LN+1) + ' '; {Do not Localize}
end;
end;
end;
1: // TO {Do not Localize}
begin
for LM := 0 to LMessageTemp.Recipients.Count-1 do begin
if Pos(UpperCase(LSearchString), UpperCase(LMessageTemp.Recipients.Items[LM].Address)) > 0 then begin
if AUseUID then begin
LHits := LHits + LMessageToCheck.UID + ' '; {Do not Localize}
end else begin
LHits := LHits + IntToStr(LN+1) + ' '; {Do not Localize}
end;
Break; //Don't want more than 1 hit on this record
end;
end;
end;
2: // CC {Do not Localize}
begin
for LM := 0 to LMessageTemp.Recipients.Count-1 do begin
if Pos(UpperCase(LSearchString), UpperCase(LMessageTemp.CCList.Items[LM].Address)) > 0 then begin
if AUseUID then begin
LHits := LHits + LMessageToCheck.UID + ' '; {Do not Localize}
end else begin
LHits := LHits + IntToStr(LN+1) + ' '; {Do not Localize}
end;
Break; //Don't want more than 1 hit on this record
end;
end;
end;
3: // BCC {Do not Localize}
begin
for LM := 0 to LMessageTemp.Recipients.Count-1 do begin
if Pos(UpperCase(LSearchString), UpperCase(LMessageTemp.BCCList.Items[LM].Address)) > 0 then begin
if AUseUID then begin
LHits := LHits + LMessageToCheck.UID + ' '; {Do not Localize}
end else begin
LHits := LHits + IntToStr(LN+1) + ' '; {Do not Localize}
end;
Break; //Don't want more than 1 hit on this record
end;
end;
end;
else // SUBJECT {Do not Localize}
begin
if Pos(UpperCase(LSearchString), UpperCase(LMessageTemp.Subject)) > 0 then begin
if AUseUID then begin
LHits := LHits + LMessageToCheck.UID + ' '; {Do not Localize}
end else begin
LHits := LHits + IntToStr(LN+1) + ' '; {Do not Localize}
end;
end;
end;
end;
end;
finally
FreeAndNil(LMessageTemp);
end;
DoSendReply(ASender.Context, '* SEARCH ' + TrimRight(LHits)); {Do not Localize}
SendOkReply(ASender, 'Completed'); {Do not Localize}
end;
procedure TIdIMAP4Server.ProcessCopy(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings);
var
LMessageNumbers: TStringList;
LN: Integer;
LRecord: Int64;
LResult: Boolean;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
//Format is "C1 COPY 2:4 MEETINGFOLDER"
if AParams.Count < 2 then begin
SendIncorrectNumberOfParameters(ASender);
Exit;
end;
if not OnDefMechReinterpretParamAsMailBox(AParams, 1) then begin
SendBadReply(ASender, 'Mailbox parameter is invalid.'); {Do not Localize}
Exit;
end;
//First param is a message set, e.g. 41 or 2:5 (which is 2, 3, 4 & 5)
LMessageNumbers := TStringList.Create;
try
if not MessageSetToMessageNumbers(AUseUID, ASender, LMessageNumbers, AParams[0]) then begin
SendBadReply(ASender, 'Error in syntax of message set parameter'); {Do not Localize}
Exit;
end;
if not Assigned(OnDefMechDoesImapMailBoxExist) then begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
if not OnDefMechDoesImapMailBoxExist(LContext.LoginName, AParams[1]) then begin
SendNoReply(ASender, 'Mailbox does not exist.'); {Do not Localize}
Exit;
end;
LResult := True;
for LN := 0 to LMessageNumbers.Count-1 do begin
if AUseUID then begin
LRecord := GetRecordForUID(LMessageNumbers[LN], LContext.MailBox);
if LRecord = -1 then begin //It is OK to skip non-existent UID records
Continue;
end;
end else begin
LRecord := IndyStrToInt64(LMessageNumbers[LN])-1;
end;
if (LRecord < 0) or (LRecord >= LContext.MailBox.MessageList.Count) then begin
LResult := False;
end
else if not OnDefMechCopyMessage(LContext.LoginName, LContext.MailBox.Name,
LContext.MailBox.MessageList.Messages[LRecord].UID, AParams[1]) then
begin
LResult := False;
end;
end;
if LResult then begin
SendOkReply(ASender, 'Completed'); {Do not Localize}
end else begin
SendNoReply(ASender, 'Copy failed for one or more messages'); {Do not Localize}
end;
finally
FreeAndNil(LMessageNumbers);
end;
end;
function TIdIMAP4Server.ProcessStore(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings): Boolean;
const
LCMsgFlags: array[0..4] of TIdMessageFlags = ( mfAnswered, mfFlagged, mfDeleted, mfDraft, mfSeen );
var
LMessageNumbers: TStringList;
LFlagList: TStringList;
LN: integer;
LM: integer;
LRecord: Int64;
LFlag: integer;
LTemp: string;
LStoreMethod: TIdIMAP4StoreDataItem;
LSilent: Boolean;
LMessage: TIdMessage;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
//Format is:
//C53 UID STORE 6545,6544 +FLAGS.SILENT (\Deleted)
//C53 OK Completed
Result := False;
if AParams.Count < 3 then begin
SendIncorrectNumberOfParameters(ASender);
Exit;
end;
//First param is a message set, e.g. 41 or 2:5 (which is 2, 3, 4 & 5)
LMessageNumbers := TStringList.Create;
try
if not MessageSetToMessageNumbers(AUseUID, ASender, LMessageNumbers, AParams[0]) then begin
SendBadReply(ASender, 'Error in syntax of message set parameter'); {Do not Localize}
Exit;
end;
LTemp := AParams[1];
if LTemp[1] = '+' then begin {Do not Localize}
LStoreMethod := sdAdd;
LTemp := Copy(LTemp, 2, MaxInt);
end else if LTemp[1] = '-' then begin {Do not Localize}
LStoreMethod := sdRemove;
LTemp := Copy(LTemp, 2, MaxInt);
end else begin
LStoreMethod := sdReplace;
end;
if TextIsSame(LTemp, 'FLAGS') then begin {Do not Localize}
LSilent := False;
end else if TextIsSame(LTemp, 'FLAGS.SILENT') then begin {Do not Localize}
LSilent := True;
end else begin
SendBadReply(ASender, 'Error in syntax of FLAGS parameter'); {Do not Localize}
Exit;
end;
LFlagList := TStringList.Create;
try
//Assemble remaining flags back into a string...
LTemp := AParams[2];
for LN := 3 to AParams.Count-1 do begin
LTemp := LTemp + ' ' + AParams[LN]; {Do not Localize}
end;
if not FlagStringToFlagList(LFlagList, LTemp) then begin
SendBadReply(ASender, 'Error in syntax of flag set parameter'); {Do not Localize}
Exit;
end;
for LN := 0 to LMessageNumbers.Count-1 do begin
if AUseUID then begin
LRecord := GetRecordForUID(LMessageNumbers[LN], LContext.MailBox);
if LRecord = -1 then begin //It is OK to skip non-existent UID records
Continue;
end;
end else begin
LRecord := IndyStrToInt64(LMessageNumbers[LN])-1;
end;
if (LRecord < 0) or (LRecord > LContext.MailBox.MessageList.Count) then begin
SendBadReply(ASender, 'Message number %d does not exist', [LRecord+1]); {Do not Localize}
Exit;
end;
LMessage := LContext.MailBox.MessageList.Messages[LRecord];
if LStoreMethod = sdReplace then begin
LMessage.Flags := [];
end;
for LM := 0 to LFlagList.Count-1 do begin
//Support \Answered \Flagged \Deleted \Draft \Seen
LFlag := PosInStrArray(LFlagList[LM], ['\Answered', '\Flagged', '\Deleted', '\Draft', '\Seen'], False); {Do not Localize}
if LFlag = -1 then begin
Continue;
end;
case LStoreMethod of
sdAdd, sdReplace:
begin
LMessage.Flags := LMessage.Flags + [LCMsgFlags[LFlag]];
end;
sdRemove:
begin
LMessage.Flags := LMessage.Flags - [LCMsgFlags[LFlag]];
end;
end;
end;
if not LSilent then begin
//In this case, send to the client the current flags.
//The response is '* 43 FETCH (FLAGS (\Seen))' with the UID version
//being '* 43 FETCH (FLAGS (\Seen) UID 1234)'. Note the first number is the
//relative message number in BOTH cases.
if AUseUID then begin
DoSendReply(ASender.Context, '* %d FETCH (FLAGS (%s) UID %s)', {Do not Localize}
[LRecord+1, MessageFlagSetToStr(LMessage.Flags), LMessageNumbers[LN]]);
end else begin
DoSendReply(ASender.Context, '* %d FETCH (FLAGS (%s))', {Do not Localize}
[LRecord+1, MessageFlagSetToStr(LMessage.Flags)]);
end;
end;
end;
SendOkReply(ASender, 'STORE Completed'); {Do not Localize}
finally
FreeAndNil(LFlagList);
end;
finally
FreeAndNil(LMessageNumbers);
end;
Result := True;
end;
procedure TIdIMAP4Server.InitializeCommandHandlers;
var
LCommandHandler: TIdCommandHandler;
begin
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'CAPABILITY'; {do not localize}
LCommandHandler.OnCommand := DoCommandCAPABILITY;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'NOOP'; {do not localize}
LCommandHandler.OnCommand := DoCommandNOOP;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'LOGOUT'; {do not localize}
LCommandHandler.OnCommand := DoCommandLOGOUT;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'AUTHENTICATE'; {do not localize}
LCommandHandler.OnCommand := DoCommandAUTHENTICATE;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'LOGIN'; {do not localize}
LCommandHandler.OnCommand := DoCommandLOGIN;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'SELECT'; {do not localize}
LCommandHandler.OnCommand := DoCommandSELECT;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'EXAMINE'; {do not localize}
LCommandHandler.OnCommand := DoCommandEXAMINE;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'CREATE'; {do not localize}
LCommandHandler.OnCommand := DoCommandCREATE;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'DELETE'; {do not localize}
LCommandHandler.OnCommand := DoCommandDELETE;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'RENAME'; {do not localize}
LCommandHandler.OnCommand := DoCommandRENAME;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'SUBSCRIBE'; {do not localize}
LCommandHandler.OnCommand := DoCommandSUBSCRIBE;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'UNSUBSCRIBE'; {do not localize}
LCommandHandler.OnCommand := DoCommandUNSUBSCRIBE;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'LIST'; {do not localize}
LCommandHandler.OnCommand := DoCommandLIST;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'LSUB'; {do not localize}
LCommandHandler.OnCommand := DoCommandLSUB;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'STATUS'; {do not localize}
LCommandHandler.OnCommand := DoCommandSTATUS;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'APPEND'; {do not localize}
LCommandHandler.OnCommand := DoCommandAPPEND;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'CHECK'; {do not localize}
LCommandHandler.OnCommand := DoCommandCHECK;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'CLOSE'; {do not localize}
LCommandHandler.OnCommand := DoCommandCLOSE;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'EXPUNGE'; {do not localize}
LCommandHandler.OnCommand := DoCommandEXPUNGE;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'SEARCH'; {do not localize}
LCommandHandler.OnCommand := DoCommandSEARCH;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'FETCH'; {do not localize}
LCommandHandler.OnCommand := DoCommandFETCH;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'STORE'; {do not localize}
LCommandHandler.OnCommand := DoCommandSTORE;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'COPY'; {do not localize}
LCommandHandler.OnCommand := DoCommandCOPY;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'UID'; {do not localize}
LCommandHandler.OnCommand := DoCommandUID;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'X'; {do not localize}
LCommandHandler.OnCommand := DoCommandX;
LCommandHandler.NormalReply.Code := IMAP_OK;
LCommandHandler := CommandHandlers.Add;
LCommandHandler.Command := 'STARTTLS'; {do not localize}
LCommandHandler.OnCommand := DoCommandSTARTTLS;
LCommandHandler.NormalReply.Code := IMAP_OK;
FCommandHandlers.OnBeforeCommandHandler := DoBeforeCmd;
FCommandHandlers.OnCommandHandlersException := DoCmdHandlersException;
end;
//Command handlers
procedure TIdIMAP4Server.DoBeforeCmd(ASender: TIdCommandHandlers; var AData: string;
AContext: TIdContext);
begin
TIdIMAP4PeerContext(AContext).FLastCommand.ParseRequest(AData); //Main purpose is to get sequence number, like C11 from 'C11 CAPABILITY'
TIdIMAP4PeerContext(AContext).FIMAP4Tag := Fetch(AData, ' ');
AData := Trim(AData);
if Assigned(FOnBeforeCmd) then begin
FOnBeforeCmd(ASender, AData, AContext);
end;
end;
procedure TIdIMAP4Server.DoSendReply(AContext: TIdContext; const AData: string);
begin
if Assigned(FOnBeforeSend) then begin
FOnBeforeSend(AContext, AData);
end;
AContext.Connection.IOHandler.WriteLn(AData);
end;
procedure TIdIMAP4Server.DoSendReply(AContext: TIdContext; const AFormat: string; const Args: array of const);
begin
DoSendReply(AContext, IndyFormat(AFormat, Args));
end;
procedure TIdIMAP4Server.DoCmdHandlersException(ACommand: String; AContext: TIdContext);
var
LTag, LCmd: String;
begin
if Assigned(FOnCommandError) then begin
LTag := Fetch(ACommand, ' ');
LCmd := Fetch(ACommand, ' ');
OnCommandError(AContext, LTag, LCmd);
end;
end;
procedure TIdIMAP4Server.DoCommandCAPABILITY(ASender: TIdCommand);
begin
if Assigned(FOnCommandCAPABILITY) then begin
OnCommandCAPABILITY(ASender.Context, TIdIMAP4PeerContext(ASender.Context).IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
{Tell the client our capabilities...}
DoSendReply(ASender.Context, '* CAPABILITY IMAP4rev1 AUTH=PLAIN'); {Do not Localize}
SendOkReply(ASender, 'Completed'); {Do not Localize}
end;
procedure TIdIMAP4Server.DoCommandNOOP(ASender: TIdCommand);
begin
if Assigned(FOnCommandNOOP) then begin
OnCommandNOOP(ASender.Context, TIdIMAP4PeerContext(ASender.Context).IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
{On most servers, this does nothing (they use a timeout to disconnect users,
irrespective of NOOP commands, so they always return OK. If you really
want to implement it, use a countdown timer to force disconnects but reset
the counter if ANY command received, including NOOP.}
SendOkReply(ASender, 'Completed'); {Do not Localize}
end;
procedure TIdIMAP4Server.DoCommandLOGOUT(ASender: TIdCommand);
var
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if Assigned(FOnCommandLOGOUT) then begin
OnCommandLOGOUT(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
{Be nice and say ByeBye first...}
DoSendReply(ASender.Context, '* BYE May your God go with you.'); {Do not Localize}
SendOkReply(ASender, 'Completed'); {Do not Localize}
LContext.Connection.Disconnect(False);
LContext.MailBox.Clear;
LContext.RemoveFromList;
end;
procedure TIdIMAP4Server.DoCommandAUTHENTICATE(ASender: TIdCommand);
begin
if Assigned(FOnCommandAUTHENTICATE) then begin
{
Important, when usng TLS and FUseTLS=utUseRequireTLS, do not accept any authentication
information until TLS negotiation is completed. This insistance is a security feature.
Some networks should choose security over interoperability while other places may
sacrafice interoperability over security. It comes down to sensible administrative
judgement.
}
if (FUseTLS = utUseRequireTLS) and (not TIdIMAP4PeerContext(ASender.Context).UsingTLS) then begin
MustUseTLS(ASender);
end else begin
OnCommandAUTHENTICATE(ASender.Context, TIdIMAP4PeerContext(ASender.Context).IMAP4Tag, ASender.UnparsedParams);
end;
end;
end;
procedure TIdIMAP4Server.MustUseTLS(ASender: TIdCommand);
begin
DoSendReply(ASender.Context, 'NO ' + RSSMTPSvrReqSTARTTLS); {Do not Localize}
ASender.Disconnect := True;
end;
procedure TIdIMAP4Server.DoCommandLOGIN(ASender: TIdCommand);
var
LParams: TStringList;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if Assigned(fOnCommandLOGIN) then begin
{
Important, when using TLS and FUseTLS=utUseRequireTLS, do not accept any authentication
information until TLS negotiation is completed. This insistance is a security feature.
Some networks should choose security over interoperability while other places may
sacrafice interoperability over security. It comes down to sensible administrative
judgement.
}
if (FUseTLS = utUseRequireTLS) and (not TIdIMAP4PeerContext(ASender.Context).UsingTLS) then begin
MustUseTLS(ASender);
end else begin
OnCommandLOGIN(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
end;
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if not Assigned(OnDefMechDoesImapMailBoxExist) then begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
if LParams.Count < 2 then begin
//Incorrect number of params...
if FSaferMode then begin
SendNoReply(ASender);
end else begin
SendIncorrectNumberOfParameters(ASender);
end;
Exit;
end;
//See if we have a directory under FRootPath of that user's name...
//if DoesImapMailBoxExist(LParams[0], '') = False then begin
if not OnDefMechDoesImapMailBoxExist(LParams[0], '') then begin
if FSaferMode then begin
SendNoReply(ASender);
end else begin
SendNoReply(ASender, 'Unknown username'); {Do not Localize}
end;
Exit;
end;
//See is it the correct password...
if not TextIsSame(FDefaultPassword, LParams[1]) then begin
if FSaferMode then begin
SendNoReply(ASender);
end else begin
SendNoReply(ASender, 'Incorrect password'); {Do not Localize}
end;
Exit;
end;
//Successful login, change context's state to logged in...
LContext.LoginName := LParams[0];
LContext.FConnectionState := csAuthenticated;
SendOkReply(ASender, 'Completed'); {Do not Localize}
finally
FreeAndNil(LParams);
end;
end;
//SELECT and EXAMINE are the same except EXAMINE opens the mailbox read-only
procedure TIdIMAP4Server.DoCommandSELECT(ASender: TIdCommand);
var
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if LContext.ConnectionState = csSelected then begin
LContext.MailBox.Clear;
LContext.FConnectionState := csAuthenticated;
end;
if LContext.ConnectionState <> csAuthenticated then begin
SendWrongConnectionState(ASender);
Exit;
end;
if Assigned(FOnCommandSELECT) then begin
OnCommandSELECT(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if not Assigned(OnDefMechOpenMailBox) then begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
if OnDefMechOpenMailBox(ASender, False) then begin //SELECT opens the mailbox read-write
LContext.FConnectionState := csSelected;
SendOkReply(ASender, '[READ-WRITE] Completed'); {Do not Localize}
end;
end;
//SELECT and EXAMINE are the same except EXAMINE opens the mailbox read-only
procedure TIdIMAP4Server.DoCommandEXAMINE(ASender: TIdCommand);
var
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if not (LContext.ConnectionState in [csAuthenticated, csSelected]) then begin
SendWrongConnectionState(ASender);
Exit;
end;
if Assigned(FOnCommandEXAMINE) then begin
OnCommandEXAMINE(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if not Assigned(OnDefMechOpenMailBox) then begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
if OnDefMechOpenMailBox(ASender, True) then begin //EXAMINE opens the mailbox read-only
LContext.FConnectionState := csSelected;
SendOkReply(ASender, '[READ-ONLY] Completed'); {Do not Localize}
end;
end;
procedure TIdIMAP4Server.DoCommandCREATE(ASender: TIdCommand);
var
LParams: TStringList;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if not (LContext.ConnectionState in [csAuthenticated, csSelected]) then begin
SendWrongConnectionState(ASender);
Exit;
end;
{
if LContext.MailBox.State = msReadOnly then begin
SendErrorOpenedReadOnly(ASender);
Exit;
end;
}
if Assigned(FOnCommandCREATE) then begin
OnCommandCREATE(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if (not Assigned(OnDefMechReinterpretParamAsMailBox))
or (not Assigned(OnDefMechDoesImapMailBoxExist))
or (not Assigned(OnDefMechCreateMailBox)) then
begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
if LParams.Count < 1 then begin
//Incorrect number of params...
SendIncorrectNumberOfParameters(ASender);
Exit;
end;
if not OnDefMechReinterpretParamAsMailBox(LParams, 0) then begin
SendBadReply(ASender, 'Mailbox parameter is invalid.'); {Do not Localize}
Exit;
end;
if OnDefMechDoesImapMailBoxExist(LContext.LoginName, LParams[0]) then begin
SendBadReply(ASender, 'Mailbox already exists.'); {Do not Localize}
Exit;
end;
if OnDefMechCreateMailBox(LContext.LoginName, LParams[0]) then begin
SendOkReply(ASender, 'Completed'); {Do not Localize}
end else begin
SendNoReply(ASender, 'Create failed'); {Do not Localize}
end;
finally
FreeAndNil(LParams);
end;
end;
procedure TIdIMAP4Server.DoCommandDELETE(ASender: TIdCommand);
var
LParams: TStringList;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if not (LContext.ConnectionState in [csAuthenticated, csSelected]) then begin
SendWrongConnectionState(ASender);
Exit;
end;
{
if LContext.MailBox.State = msReadOnly then begin
SendErrorOpenedReadOnly(ASender);
Exit;
end;
}
if Assigned(FOnCommandDELETE) then begin
OnCommandDELETE(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if (not Assigned(OnDefMechDoesImapMailBoxExist))
or (not Assigned(OnDefMechReinterpretParamAsMailBox))
or (not Assigned(OnDefMechDeleteMailBox))
or (not Assigned(OnDefMechIsMailBoxOpen)) then
begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
//Make sure we don't have the mailbox open by anyone
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
if LParams.Count < 1 then begin
//Incorrect number of params...
SendIncorrectNumberOfParameters(ASender);
Exit;
end;
if not OnDefMechReinterpretParamAsMailBox(LParams, 0) then begin
SendBadReply(ASender, 'Mailbox parameter is invalid.'); {Do not Localize}
Exit;
end;
if OnDefMechIsMailBoxOpen(LContext.LoginName, LParams[0]) then begin
SendNoReply(ASender, 'Mailbox is in use.'); {Do not Localize}
Exit;
end;
if not OnDefMechDoesImapMailBoxExist(LContext.LoginName, LParams[0]) then begin
SendNoReply(ASender, 'Mailbox does not exist.'); {Do not Localize}
Exit;
end;
if OnDefMechDeleteMailBox(LContext.LoginName, LParams[0]) then begin
SendOkReply(ASender, 'Completed'); {Do not Localize}
end else begin
SendNoReply(ASender, 'Delete failed'); {Do not Localize}
end;
finally
FreeAndNil(LParams);
end;
end;
procedure TIdIMAP4Server.DoCommandRENAME(ASender: TIdCommand);
var
LParams: TStringList;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if not (LContext.ConnectionState in [csAuthenticated, csSelected]) then begin
SendWrongConnectionState(ASender);
Exit;
end;
{
if LContext.MailBox.State = msReadOnly then begin
SendErrorOpenedReadOnly(ASender);
Exit;
end;
}
if Assigned(FOnCommandRENAME) then begin
OnCommandRENAME(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if (not Assigned(OnDefMechDoesImapMailBoxExist))
or (not Assigned(OnDefMechReinterpretParamAsMailBox))
or (not Assigned(OnDefMechRenameMailBox))
or (not Assigned(OnDefMechIsMailBoxOpen)) then
begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
//Make sure we don't have the mailbox open by anyone
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
if LParams.Count < 2 then begin
//Incorrect number of params...
SendIncorrectNumberOfParameters(ASender);
Exit;
end;
if not OnDefMechReinterpretParamAsMailBox(LParams, 0) then begin
SendBadReply(ASender, 'First mailbox parameter is invalid.'); {Do not Localize}
Exit;
end;
if OnDefMechIsMailBoxOpen(LContext.LoginName, LParams[0]) then begin
SendNoReply(ASender, 'Mailbox is in use.'); {Do not Localize}
Exit;
end;
if not OnDefMechReinterpretParamAsMailBox(LParams, 1) then begin
SendBadReply(ASender, 'Second mailbox parameter is invalid.'); {Do not Localize}
Exit;
end;
if not OnDefMechDoesImapMailBoxExist(LContext.LoginName, LParams[0]) then begin
SendNoReply(ASender, 'Mailbox to be renamed does not exist.'); {Do not Localize}
Exit;
end;
if OnDefMechDoesImapMailBoxExist(LContext.LoginName, LParams[1]) then begin
SendNoReply(ASender, 'Destination mailbox already exists.'); {Do not Localize}
Exit;
end;
if OnDefMechRenameMailBox(LContext.LoginName, LParams[0], LParams[1]) then begin
SendOkReply(ASender, 'Completed'); {Do not Localize}
end else begin
SendNoReply(ASender, 'Delete failed'); {Do not Localize}
end;
finally
FreeAndNil(LParams);
end;
end;
procedure TIdIMAP4Server.DoCommandSUBSCRIBE(ASender: TIdCommand);
var
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if LContext.MailBox.State = msReadOnly then begin
SendErrorOpenedReadOnly(ASender);
Exit;
end;
if Assigned(FOnCommandSUBSCRIBE) then begin
OnCommandSUBSCRIBE(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
{Not clear exactly what this would do in this sample mechanism...}
SendUnsupportedCommand(ASender);
end;
procedure TIdIMAP4Server.DoCommandUNSUBSCRIBE(ASender: TIdCommand);
var
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if LContext.MailBox.State = msReadOnly then begin
SendErrorOpenedReadOnly(ASender);
Exit;
end;
if Assigned(FOnCommandUNSUBSCRIBE) then begin
OnCommandUNSUBSCRIBE(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
{Not clear exactly what this would do in this sample mechanism...}
SendUnsupportedCommand(ASender);
end;
procedure TIdIMAP4Server.DoCommandLIST(ASender: TIdCommand);
var
LParams: TStringList;
LMailBoxNames: TStringList;
LMailBoxFlags: TStringList;
LN: integer;
LEntry: string;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if not (LContext.ConnectionState in [csAuthenticated, csSelected]) then begin
SendWrongConnectionState(ASender);
Exit;
end;
if Assigned(FOnCommandLIST) then begin
OnCommandLIST(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if not Assigned(OnDefMechListMailBox) then begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
//The default mechanism only supports the following format:
// LIST "" *
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
if LParams.Count < 2 then begin
//Incorrect number of params...
SendIncorrectNumberOfParameters(ASender);
Exit;
end;
if LParams[1] <> '*' then begin {Do not Localize}
SendBadReply(ASender, 'Parameter not supported, 2nd (last) parameter must be *'); {Do not Localize}
Exit;
end;
LMailBoxNames := TStringList.Create;
try
LMailBoxFlags := TStringList.Create;
try
if OnDefMechListMailBox(LContext.LoginName, LParams[0], LMailBoxNames, LMailBoxFlags) then begin
for LN := 0 to LMailBoxNames.Count-1 do begin
//Replies are of the form:
//* LIST (\HasNoChildren) "." "INBOX.CreatedFolder"
LEntry := '* LIST ('; {Do not Localize}
if LMailBoxFlags[LN] <> '' then begin
LEntry := LEntry + LMailBoxFlags[LN];
end;
LEntry := LEntry + ') "' + MailBoxSeparator + '" "' + LMailBoxNames[LN] + '"'; {Do not Localize}
DoSendReply(ASender.Context, LEntry); {Do not Localize}
end;
SendOkReply(ASender, 'Completed'); {Do not Localize}
end else begin
SendNoReply(ASender, 'List failed'); {Do not Localize}
end;
finally
FreeAndNil(LMailBoxFlags);
end;
finally
FreeAndNil(LMailBoxNames);
end;
finally
FreeAndNil(LParams);
end;
end;
procedure TIdIMAP4Server.DoCommandLSUB(ASender: TIdCommand);
var
LParams: TStringList;
LMailBoxNames: TStringList;
LMailBoxFlags: TStringList;
LN: integer;
LEntry: string;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if not (LContext.ConnectionState in [csAuthenticated, csSelected]) then begin
SendWrongConnectionState(ASender);
Exit;
end;
if Assigned(FOnCommandLSUB) then begin
OnCommandLSUB(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if not Assigned(OnDefMechListMailBox) then begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
//Treat this the same as LIST...
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
if LParams.Count < 2 then begin
//Incorrect number of params...
SendIncorrectNumberOfParameters(ASender);
Exit;
end;
if LParams[1] <> '*' then begin {Do not Localize}
SendBadReply(ASender, 'Parameter not supported, 2nd (last) parameter must be *'); {Do not Localize}
Exit;
end;
LMailBoxNames := TStringList.Create;
try
LMailBoxFlags := TStringList.Create;
try
if OnDefMechListMailBox(LContext.LoginName, LParams[0], LMailBoxNames, LMailBoxFlags) then begin
for LN := 0 to LMailBoxNames.Count-1 do begin
//Replies are of the form:
//* LIST (\HasNoChildren) "." "INBOX.CreatedFolder"
LEntry := '* LIST ('; {Do not Localize}
if LMailBoxFlags[LN] <> '' then begin
LEntry := LEntry + LMailBoxFlags[LN];
end;
LEntry := LEntry + ') "' + MailBoxSeparator + '" "' + LMailBoxNames[LN] + '"'; {Do not Localize}
DoSendReply(ASender.Context, LEntry); {Do not Localize}
end;
SendOkReply(ASender, 'Completed'); {Do not Localize}
end else begin
SendNoReply(ASender, 'List failed'); {Do not Localize}
end;
finally
FreeAndNil(LMailBoxFlags);
end;
finally
FreeAndNil(LMailBoxNames);
end;
finally
FreeAndNil(LParams);
end;
end;
procedure TIdIMAP4Server.DoCommandSTATUS(ASender: TIdCommand);
var
LMailBox: TIdMailBox;
LN: integer;
LParams: TStringList;
LTemp: string;
LAnswer: string;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if not (LContext.ConnectionState in [csAuthenticated, csSelected]) then begin
SendWrongConnectionState(ASender);
Exit;
end;
if Assigned(FOnCommandSTATUS) then begin
OnCommandSTATUS(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if (not Assigned(OnDefMechDoesImapMailBoxExist))
or (not Assigned(OnDefMechReinterpretParamAsMailBox))
or (not Assigned(OnDefMechSetupMailbox)) then
begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
//This can be issued for ANY mailbox, not just the currently selected one.
//The format is:
//C5 STATUS "INBOX" (MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)
//* STATUS INBOX (MESSAGES 490 RECENT 132 UIDNEXT 6546 UIDVALIDITY 1065090323 UNSEEN 167)
//C5 OK Completed
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
if LParams.Count < 1 then begin
//Incorrect number of params...
SendIncorrectNumberOfParameters(ASender);
Exit;
end;
if not OnDefMechReinterpretParamAsMailBox(LParams, 0) then begin
SendBadReply(ASender, 'Mailbox parameter is invalid.'); {Do not Localize}
Exit;
end;
if not OnDefMechDoesImapMailBoxExist(LContext.LoginName, LParams[0]) then begin
SendNoReply(ASender, 'Mailbox does not exist.'); {Do not Localize}
Exit;
end;
{Get everything you need for this mailbox...}
LMailBox := TIdMailBox.Create;
try
OnDefMechSetupMailbox(LContext.LoginName, LParams[0], LMailBox);
{Send the stats...}
LAnswer := '* STATUS ' + LParams[0] + ' ('; {Do not Localize}
for LN := 1 to LParams.Count-1 do begin
LTemp := LParams[LN];
if LTemp <> '' then begin
//Strip brackets (will be on 1st & last param)
if LTemp[1] = '(' then begin {Do not Localize}
LTemp := Copy(LTemp, 2, MaxInt);
end;
if (LTemp <> '') and (LTemp[Length(LTemp)] = ')') then begin {Do not Localize}
LTemp := Copy(LTemp, 1, Length(LTemp)-1);
end;
case PosInStrArray(LTemp, ['MESSAGES', 'RECENT', 'UIDNEXT', 'UIDVALIDITY', 'UNSEEN'], False) of
0: // MESSAGES {Do not Localize}
begin
LAnswer := LAnswer + LTemp + ' ' + IntToStr(LMailBox.TotalMsgs) + ' '; {Do not Localize}
end;
1: // RECENT {Do not Localize}
begin
LAnswer := LAnswer + LTemp + ' ' + IntToStr(LMailBox.RecentMsgs) + ' '; {Do not Localize}
end;
2: // UIDNEXT {Do not Localize}
begin
LAnswer := LAnswer + LTemp + ' ' + LMailBox.UIDNext + ' '; {Do not Localize}
end;
3: // UIDVALIDITY {Do not Localize}
begin
LAnswer := LAnswer + LTemp + ' ' + LMailBox.UIDValidity + ' '; {Do not Localize}
end;
4: // UNSEEN {Do not Localize}
begin
LAnswer := LAnswer + LTemp + ' ' + IntToStr(LMailBox.UnseenMsgs) + ' '; {Do not Localize}
end;
else
begin
SendBadReply(ASender, 'Parameter not supported: ' + LTemp); {Do not Localize}
Exit;
end;
end;
end;
end;
if LAnswer[Length(LAnswer)] = ' ' then begin {Do not Localize}
LAnswer := Copy(LAnswer, 1, Length(LAnswer)-1);
end;
LAnswer := LAnswer + ')'; {Do not Localize}
DoSendReply(ASender.Context, LAnswer);
SendOkReply(ASender, 'Completed'); {Do not Localize}
finally
FreeAndNil(LMailBox);
end;
finally
FreeAndNil(LParams);
end;
end;
procedure TIdIMAP4Server.DoCommandAPPEND(ASender: TIdCommand);
var
LUID: string;
LStream: TStream;
LFile: string;
LTemp: string;
LParams: TStringList;
LParams2: TStringList;
LFlagsList: TStringList;
LSize: Int64;
LFlags, LInternalDateTime: string;
LN: integer;
LMessage: TIdMessage;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
//You do NOT need to be in selected state for this.
if LContext.ConnectionState <> csAuthenticated then begin
SendWrongConnectionState(ASender);
Exit;
end;
if LContext.MailBox.State = msReadOnly then begin
SendErrorOpenedReadOnly(ASender);
Exit;
end;
if Assigned(FOnCommandAPPEND) then begin
OnCommandAPPEND(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if (not Assigned(OnDefMechGetNextFreeUID))
or (not Assigned(OnDefMechReinterpretParamAsMailBox))
or (not Assigned(OnDefMechUpdateNextFreeUID))
or (not Assigned(OnDefMechDeleteMessage)) //Needed to reverse out a save if setting flags fail
or (not Assigned(OnDefMechGetFileNameToWriteAppendMessage)) then
begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
//Format (the flags and date/time are optional):
//C323 APPEND "INBOX.Sent" (\Seen) "internal date/time" {1876}
//+ go ahead
//...
//C323 OK [APPENDUID 1065095982 105] Completed
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
if LParams.Count < 2 then begin
//Incorrect number of params...
SendIncorrectNumberOfParameters(ASender);
Exit;
end;
if not OnDefMechReinterpretParamAsMailBox(LParams, 0) then begin
SendBadReply(ASender, 'Mailbox parameter is invalid.'); {Do not Localize}
Exit;
end;
LFlags := '';
LInternalDateTime := '';
LN := 1;
LTemp := LParams[Ln];
if TextStartsWith(LTemp, '(') then begin {Do not Localize}
if not ReinterpretParamAsFlags(LParams, Ln) then begin
SendBadReply(ASender, 'Flags parameter is invalid.'); {Do not Localize}
Exit;
end;
LFlags := LParams[Ln];
Inc(Ln);
end
else if TextIsSame(LTemp, 'NIL') then begin {Do not Localize}
Inc(Ln);
end;
LTemp := LParams[Ln];
if TextStartsWith(LTemp, '"') then begin {Do not Localize}
if not ReinterpretParamAsQuotedStr(LParams, Ln) then begin
SendBadReply(ASender, 'InternalDateTime parameter is invalid.'); {Do not Localize}
Exit;
end;
LInternalDateTime := LParams[Ln];
end;
LTemp := LParams[LParams.Count-1];
if not TextStartsWith(LTemp, '{') then begin {Do not Localize}
SendBadReply(ASender, 'Size parameter is invalid.'); {Do not Localize}
Exit;
end;
LSize := IndyStrToInt64(Copy(LTemp, 2, Length(LTemp)-2));
//Grab the next UID...
LUID := OnDefMechGetNextFreeUID(LContext.LoginName, LParams[0]);
//Get the message...
LFile := OnDefMechGetFileNameToWriteAppendMessage(LContext.LoginName, LContext.MailBox.Name, LUID);
LStream := TIdFileCreateStream.Create(LFile);
try
ASender.Context.Connection.IOHandler.ReadStream(LStream, LSize);
if LFlags = '' then begin
SendOkReply(ASender, 'Completed'); {Do not Localize}
end else begin
//Update the (optional) flags...
LParams2 := TStringList.Create;
try
LParams2.Add(LUID);
LParams2.Add('FLAGS.SILENT'); {Do not Localize}
{
for LN := 1 to LParams.Count-2 do begin
LParams2.Add(LParams[LN]);
end;
}
//The flags are in a string, need to reassemble...
LFlagsList := TStringList.Create;
try
BreakApart(LFlags, ' ', LFlagsList); {Do not Localize}
for LN := 0 to LFlagsList.Count-1 do begin
LTemp := LFlagsList[LN];
if LN = 0 then begin
LTemp := '(' + LTemp; {Do not Localize}
end;
if LN = LFlagsList.Count-1 then begin
LTemp := LTemp + ')'; {Do not Localize}
end;
LParams2.Add(LTemp);
end;
if not ProcessStore(True, ASender, LParams2) then begin
//Have to reverse out our changes if ANYTHING fails..
LMessage := TIdMessage.Create(Self);
try
LMessage.UID := LUID; //This is all we need for deletion
OnDefMechDeleteMessage(LContext.LoginName, LContext.MailBox.Name, LMessage);
finally
FreeAndNil(LMessage);
end;
Exit;
end;
finally
FreeAndNil(LFlagsList);
end;
finally
FreeAndNil(LParams2);
end;
end;
//Update the next free UID in the .uid file...
OnDefMechUpdateNextFreeUID(LContext.LoginName, LContext.MailBox.Name, IntToStr(IndyStrToInt64(LUID)+1));
// TODO: implement this
{
if LInternalDateTime <> '' then
begin
// what to do here?
end;
}
finally
FreeAndNil(LStream);
end;
finally
FreeAndNil(LParams);
end;
end;
procedure TIdIMAP4Server.DoCommandCHECK(ASender: TIdCommand);
var
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if LContext.ConnectionState <> csSelected then begin
SendWrongConnectionState(ASender);
Exit;
end;
if Assigned(fOnCommandCHECK) then begin
OnCommandCHECK(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
{On most servers, this does nothing, they always return OK...}
SendOkReply(ASender, 'Completed'); {Do not Localize}
end;
procedure TIdIMAP4Server.DoCommandCLOSE(ASender: TIdCommand);
var
LResult: Boolean;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if LContext.ConnectionState <> csSelected then begin
SendWrongConnectionState(ASender);
Exit;
end;
if Assigned(fOnCommandCLOSE) then begin
OnCommandCLOSE(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if not Assigned(OnDefMechDeleteMessage) then begin //Used by ExpungeRecords
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
{This is an implicit expunge...}
LResult := ExpungeRecords(ASender);
{Now close it...}
LContext.MailBox.Clear;
LContext.FConnectionState := csAuthenticated;
if LResult then begin
SendOkReply(ASender, 'Completed'); {Do not Localize}
end else begin
SendNoReply(ASender, 'Implicit expunge failed for one or more messages'); {Do not Localize}
end;
end;
procedure TIdIMAP4Server.DoCommandEXPUNGE(ASender: TIdCommand);
var
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if LContext.ConnectionState <> csSelected then begin
SendWrongConnectionState(ASender);
Exit;
end;
if LContext.MailBox.State = msReadOnly then begin
SendErrorOpenedReadOnly(ASender);
Exit;
end;
if Assigned(FOnCommandEXPUNGE) then begin
OnCommandEXPUNGE(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if not Assigned(OnDefMechDeleteMessage) then begin //Used by ExpungeRecords
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
if ExpungeRecords(ASender) then begin
SendOkReply(ASender, 'Completed'); {Do not Localize}
end else begin
SendNoReply(ASender, 'Expunge failed for one or more messages'); {Do not Localize}
end;
end;
procedure TIdIMAP4Server.DoCommandSEARCH(ASender: TIdCommand);
var
LParams: TStringList;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if LContext.ConnectionState <> csSelected then begin
SendWrongConnectionState(ASender);
Exit;
end;
if Assigned(fOnCommandSEARCH) then begin
OnCommandSEARCH(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if not Assigned(OnDefMechGetMessageHeader) then begin //Used by ProcessSearch
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
ProcessSearch(False, ASender, LParams);
finally
FreeAndNil(LParams);
end;
end;
procedure TIdIMAP4Server.DoCommandFETCH(ASender: TIdCommand);
var
LParams: TStringList;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if LContext.ConnectionState <> csSelected then begin
SendWrongConnectionState(ASender);
Exit;
end;
if Assigned(FOnCommandFETCH) then begin
OnCommandFETCH(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
if (not Assigned(OnDefMechGetMessageHeader)) //Used by ProcessFetch
or (not Assigned(OnDefMechGetMessageSize))
or (not Assigned(OnDefMechGetMessageRaw)) then
begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
ProcessFetch(False, ASender, LParams);
finally
FreeAndNil(LParams);
end;
end;
procedure TIdIMAP4Server.DoCommandSTORE(ASender: TIdCommand);
var
LParams: TStringList;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if LContext.ConnectionState <> csSelected then begin
SendWrongConnectionState(ASender);
Exit;
end;
if LContext.MailBox.State = msReadOnly then begin
SendErrorOpenedReadOnly(ASender);
Exit;
end;
if Assigned(fOnCommandSTORE) then begin
OnCommandSTORE(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
ProcessStore(False, ASender, LParams);
finally
FreeAndNil(LParams);
end;
end;
function TIdIMAP4Server.MessageFlagSetToStr(const AFlags: TIdMessageFlagsSet): String;
begin
Result := '';
if mfAnswered in AFlags then begin
Result := Result + MessageFlags[mfAnswered] + ' '; {Do not Localize}
end;
if mfFlagged in AFlags then begin
Result := Result + MessageFlags[mfFlagged] + ' '; {Do not Localize}
end;
if mfDeleted in AFlags then begin
Result := Result + MessageFlags[mfDeleted] + ' '; {Do not Localize}
end;
if mfDraft in AFlags then begin
Result := Result + MessageFlags[mfDraft] + ' '; {Do not Localize}
end;
if mfSeen in AFlags then begin
Result := Result + MessageFlags[mfSeen] + ' '; {Do not Localize}
end;
if Result <> '' then begin
Result := TrimRight(Result);
end;
end;
procedure TIdIMAP4Server.DoCommandCOPY(ASender: TIdCommand);
var
LParams: TStringList;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if LContext.ConnectionState <> csSelected then begin
SendWrongConnectionState(ASender);
Exit;
end;
if LContext.MailBox.State = msReadOnly then begin
SendErrorOpenedReadOnly(ASender);
Exit;
end;
if Assigned(FOnCommandCOPY) then begin
OnCommandCOPY(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
//Format is COPY 2:4 DestinationMailBoxName
if (not Assigned(OnDefMechReinterpretParamAsMailBox))
or (not Assigned(OnDefMechCopyMessage)) then //Needed for ProcessCopy
begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
ProcessCopy(False, ASender, LParams);
finally
FreeAndNil(LParams);
end;
end;
{UID before COPY, FETCH or STORE means the record numbers are UIDs.
UID before SEARCH means SEARCH is to _return_ UIDs rather than relative numbers.}
procedure TIdIMAP4Server.DoCommandUID(ASender: TIdCommand);
var
LParams: TStringList;
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if LContext.ConnectionState <> csSelected then begin
SendWrongConnectionState(ASender);
Exit;
end;
if Assigned(fOnCommandUID) then begin
OnCommandUID(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if not FUseDefaultMechanismsForUnassignedCommands then begin
Exit;
end;
LParams := TStringList.Create;
try
BreakApart(ASender.UnparsedParams, ' ', LParams); {Do not Localize}
if LParams.Count < 1 then begin
//Incorrect number of params...
SendIncorrectNumberOfParameters(ASender);
Exit;
end;
//Map the commands to the general handler but remove the FETCH or whatever...
case PosInStrArray(LParams[0], ['FETCH', 'COPY', 'STORE', 'SEARCH'], False) of
0: // FETCH {Do not Localize}
begin
if (not Assigned(OnDefMechGetMessageHeader)) //Used by ProcessFetch
or (not Assigned(OnDefMechGetMessageSize))
or (not Assigned(OnDefMechGetMessageRaw)) then
begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
LParams.Delete(0);
ProcessFetch(True, ASender, LParams);
end;
1: // COPY {Do not Localize}
begin
if (not Assigned(OnDefMechReinterpretParamAsMailBox))
or (not Assigned(OnDefMechCopyMessage)) then //Needed for ProcessCopy
begin
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
LParams.Delete(0);
ProcessCopy(True, ASender, LParams);
end;
2: // STORE {Do not Localize}
begin
LParams.Delete(0);
ProcessStore(True, ASender, LParams);
end;
3: // SEARCH {Do not Localize}
begin
if not Assigned(OnDefMechGetMessageHeader) then begin //Used by ProcessSearch
SendUnassignedDefaultMechanism(ASender);
Exit;
end;
LParams.Delete(0);
ProcessSearch(True, ASender, LParams);
end;
else
begin
SendUnsupportedCommand(ASender);
end;
end;
finally
FreeAndNil(LParams);
end;
end;
procedure TIdIMAP4Server.DoCommandX(ASender: TIdCommand);
begin
if not Assigned(fOnCommandX) then begin
OnCommandX(ASender.Context, TIdIMAP4PeerContext(ASender.Context).IMAP4Tag, ASender.UnparsedParams);
end else if FUseDefaultMechanismsForUnassignedCommands then begin
SendUnsupportedCommand(ASender);
end;
end;
procedure TIdIMAP4Server.DoCommandSTARTTLS(ASender: TIdCommand);
var
LContext: TIdIMAP4PeerContext;
begin
LContext := TIdIMAP4PeerContext(ASender.Context);
if (not (IOHandler is TIdServerIOHandlerSSLBase)) or (not (FUseTLS in ExplicitTLSVals)) then begin
OnCommandError(ASender.Context, LContext.IMAP4Tag, ASender.UnparsedParams);
Exit;
end;
if LContext.UsingTLS then begin // we are already using TLS
DoSendReply(ASender.Context, 'BAD %s', [RSIMAP4SvrNotPermittedWithTLS]); {do not localize}
Exit;
end;
// TODO: STARTTLS may only be issued in auth-state
DoSendReply(ASender.Context, 'OK %s', [RSIMAP4SvrBeginTLSNegotiation]); {do not localize}
(ASender.Context.Connection.IOHandler as TIdSSLIOHandlerSocketBase).PassThrough := False;
end;
end.
| 38.372838 | 227 | 0.681821 |
c3936c622c8f3e6b0a1d11027bce8a4f132cd397 | 1,419 | pas | Pascal | DXTypes_JSB.pas | randydom/commonx | 2315f1acf41167bd77ba4d040b3f5b15a5c5b81a | [
"MIT"
]
| 48 | 2018-11-19T22:13:00.000Z | 2021-11-02T17:25:41.000Z | DXTypes_JSB.pas | wkfff/commonx | 787b9a4a1e7c02f55d81d2236b0cc9f332b38f53 | [
"MIT"
]
| 6 | 2018-11-24T17:15:29.000Z | 2019-05-15T14:59:56.000Z | DXTypes_JSB.pas | adaloveless/commonx | ed37b239e925119c7ceb3ac7949eefb0259c7f77 | [
"MIT"
]
| 12 | 2018-11-20T15:15:44.000Z | 2021-09-14T10:12:43.000Z | unit DXTypes_JSB;
///////////////////////////////////////////////////////////////////////////////
//
// Copyright J S Bladen, Sheffield, UK.
//
// Date and time: 05/09/2009 13:48:30
//
// For use with JSB Delphi DirectX units.
//
// Please send bug reports, suggestions, requests and other comments to: DelphiInterfaceUnits@jsbmedical.co.uk
//
///////////////////////////////////////////////////////////////////////////////
interface
uses
Windows;
type
TInteger64=Int64;
TUnsignedInteger64=UInt64;
PLongBool=^LongBool;
PHRESULT=^HRESULT;
SIZE_T=LongWord; // 32 bit Delphi only!
PSIZE_T=^SIZE_T;
HANDLE=THandle;
RECT=TRect;
PTRect=PRect;
PTPoint=PPoint;
TColorArray=array[0..3] of Single;
TQuadArray_UInt=array[0..3] of LongWord;
TQuadArray_Float=array[0..3] of Single;
D3DCOLOR=LongWord;
TD3DColor=D3DCOLOR;
PD3DColor=^TD3DColor;
PTD3DColor=^TD3DColor;
D3DCOLORVALUE=packed record
R:Single;
G:Single;
B:Single;
A:Single;
end;
TD3DColorValue=D3DCOLORVALUE;
PD3DColorValue=^TD3DColorValue;
PTD3DColorValue=^TD3DColorValue;
function ColorArray(R,G,B,A:Single):TColorArray;
const
INT64_MAX=Int64(9223372036854775807);
ULONGLONG_MAX=UInt64($FFFFFFFFFFFFFFFF);
UINT64_MAX=UInt64($FFFFFFFFFFFFFFFF);
implementation
function ColorArray(R,G,B,A:Single):TColorArray;
begin
Result[0]:=R;
Result[1]:=G;
Result[2]:=B;
Result[3]:=A;
end;
end.
| 19.985915 | 110 | 0.642706 |
6af9b2bd94555a30ed11db853f0d45d3117cb8c9 | 575 | pas | Pascal | Examples/StringList2Json/_fmMain.pas | ryujt/ryulib-delphi | a59d308d6535de6a2fdb1ac49ded981849031c60 | [
"MIT"
]
| 12 | 2019-11-09T11:44:47.000Z | 2022-03-01T23:38:30.000Z | Examples/StringList2Json/_fmMain.pas | ryujt/ryulib-delphi | a59d308d6535de6a2fdb1ac49ded981849031c60 | [
"MIT"
]
| 1 | 2019-11-08T08:27:34.000Z | 2019-11-08T08:43:51.000Z | Examples/StringList2Json/_fmMain.pas | ryujt/ryulib-delphi | a59d308d6535de6a2fdb1ac49ded981849031c60 | [
"MIT"
]
| 15 | 2019-10-15T12:34:29.000Z | 2021-02-23T08:25:48.000Z | unit _fmMain;
interface
uses
JsonData,
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TfmMain = class(TForm)
Button1: TButton;
Memo1: TMemo;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
fmMain: TfmMain;
implementation
{$R *.dfm}
procedure TfmMain.Button1Click(Sender: TObject);
begin
Memo2.Text := StringsToJson(Memo1.Text);
end;
end.
| 16.428571 | 98 | 0.713043 |
c38b9b6ba8d221616ed48950b1befcdcd15ce8b8 | 246 | pas | Pascal | input/try3.pas | junaaaaloo/CMPILER-FINAL-MP | f2ab1e79e6c008eb6b4423777e95fa473f78f29b | [
"MIT"
]
| null | null | null | input/try3.pas | junaaaaloo/CMPILER-FINAL-MP | f2ab1e79e6c008eb6b4423777e95fa473f78f29b | [
"MIT"
]
| null | null | null | input/try3.pas | junaaaaloo/CMPILER-FINAL-MP | f2ab1e79e6c008eb6b4423777e95fa473f78f29b | [
"MIT"
]
| null | null | null | program try3;
(* BASICS TEST *)
var
a: char;
b: string;
c: integer;
d: Boolean;
begin
writeln('3 Data Types');
a := 'a';
writeln(a);
b := 'bertel';
writeln(b);
c := 5;
writeln(c);
d := true;
writeln(d);
end. | 12.947368 | 26 | 0.50813 |
83f2f7456224ca34652ba0d73f174f6e5063c715 | 2,822 | pas | Pascal | Catalogos/ProductosListaForm.pas | NetVaIT/MAS | ebdbf2dc8ca6405186683eb713b9068322feb675 | [
"Apache-2.0"
]
| null | null | null | Catalogos/ProductosListaForm.pas | NetVaIT/MAS | ebdbf2dc8ca6405186683eb713b9068322feb675 | [
"Apache-2.0"
]
| null | null | null | Catalogos/ProductosListaForm.pas | NetVaIT/MAS | ebdbf2dc8ca6405186683eb713b9068322feb675 | [
"Apache-2.0"
]
| null | null | null | unit ProductosListaForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, _StandarGFormGrid, cxGraphics,
cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxStyles, dxSkinsCore,
dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee,
dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue,
dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver,
dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver,
dxSkinOffice2013White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic,
dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringTime, dxSkinStardust,
dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinsDefaultPainters,
dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue,
dxSkinscxPCPainter, cxCustomData, cxFilter, cxData, cxDataStorage, cxEdit,
cxNavigator, Data.DB, cxDBData, cxGridCustomPopupMenu, cxGridPopupMenu,
cxClasses, Vcl.StdActns, Vcl.DBActns, System.Actions, Vcl.ActnList,
Vcl.ImgList, cxGridLevel, cxGridCustomView, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGrid, Vcl.ComCtrls, Vcl.ToolWin,
Vcl.ExtCtrls, Vcl.Buttons, Vcl.StdCtrls,Data.Win.ADODB;
type
TfrmListaProductosGrid = class(T_frmStandarGFormGrid)
tvMasterDescripcion: TcxGridDBColumn;
tvMasterIdentificador1: TcxGridDBColumn;
tvMasterIdentificador2: TcxGridDBColumn;
tvMasterIdentificador3: TcxGridDBColumn;
tvMasterPrecioUnitario: TcxGridDBColumn;
Panel1: TPanel;
RdGrpPor: TRadioGroup;
EdtBuscar: TEdit;
SpdBtnBuscar: TSpeedButton;
procedure SpdBtnBuscarClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmListaProductosGrid: TfrmListaProductosGrid;
implementation
{$R *.dfm}
uses ProductosListaDM;
procedure TfrmListaProductosGrid.SpdBtnBuscarClick(Sender: TObject);
var
idProd:String;
begin
inherited;
idProd:=EdtBuscar.Text;
DataSource.DataSet.Close;
case RdGrpPor.ItemIndex of
0: TAdoDataset(DataSource.DataSet).commandText:='Select * from Productos where (Identificador1 Like '''+IDProd+
'%'' or Identificador2 like '''+IDProd+'%'' or Identificador3 Like '''+IDProd+
'%'')';
1: TAdoDataset(DataSource.DataSet).commandText:='Select * from Productos where Descripcion like '''+IDProd+ '%''';
end;
DataSource.DataSet.open;
end;
end.
| 38.657534 | 117 | 0.762225 |
c3e9d5cc4654655a43087b0e5d9b3dcc9c0e5ce8 | 22,265 | pas | Pascal | Libraries/Spring4D/Tests/Source/VSoft.DUnit.XMLTestRunner.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| 62 | 2016-01-20T16:26:25.000Z | 2022-02-28T14:25:52.000Z | Libraries/Spring4D/Tests/Source/VSoft.DUnit.XMLTestRunner.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| null | null | null | Libraries/Spring4D/Tests/Source/VSoft.DUnit.XMLTestRunner.pas | jomael/Concepts | 82d18029e41d55e897d007f826c021cdf63e53f8 | [
"Apache-2.0"
]
| 20 | 2016-09-08T00:15:22.000Z | 2022-01-26T13:13:08.000Z | {***************************************************************************}
{ }
{ VSoft.DUnit.XMLTestRunner }
{ }
{ Copyright (C) 2012 Vincent Parrett }
{ }
{ http://www.finalbuilder.com }
{ }
{ }
{***************************************************************************}
{ }
{ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 }
{ }
{ Unless required by applicable law or agreed to in writing, software }
{ distributed under the License is distributed on an "AS IS" BASIS, }
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{ See the License for the specific language governing permissions and }
{ limitations under the License. }
{ }
{***************************************************************************}
// This is am modified XMLTestRunner which outputs in NUnit format
// so that it can be used with FinalBuilder and Continua CI.
unit VSoft.DUnit.XMLTestRunner;
{$IFDEF CONDITIONALEXPRESSIONS} // Delphi 6 or later
{$IF RtlVersion >= 22.0} // XE
{$DEFINE FORMATSETTINGS} // Change where Format accepts TFormatSettings as Param
{$IFEND}
{$ENDIF}
interface
uses
SysUtils,
Classes,
VSoft.MSXML6,
TestFramework;
const
DEFAULT_FILENAME = 'dunit-report.xml';
type
TSuiteData = class
Name : string;
SuiteElement : IXMLDOMElement;
ResultsElement : IXMLDOMElement;
FailureCount : integer;
ErrorCount : integer;
end;
TXMLTestListener = class(TInterfacedObject, ITestListener, ITestListenerX)
private
FSuiteDataStack : TList;
FMessageList : TStringList;
FFileName : String;
FStartDateTime : TDateTime;
FEndDateTime : TDateTime;
FXMLDoc : IXMLDOMDocument;
FTestResultsElement : IXMLDOMElement;
FCurrentTestElement : IXMLDOMElement;
FErrorCount : integer;
FFailureCount : integer;
{$IFDEF FORMATSETTINGS}
FFormatSettings : TFormatSettings;
{$ENDIF}
procedure PushSuite(const suiteElement, resultsElement : IXMLDOMElement; const name : string);
procedure PopSuite(var suiteElement, resultsElement : IXMLDOMElement; var name : string );
function CurrentSuiteElement : IXMLDOMElement;
function CurrentResultsElement : IXMLDOMElement;
protected
function PrintErrors(r: TTestResult): string; virtual;
function PrintFailures(r: TTestResult): string; virtual;
function PrintHeader(r: TTestResult): string; virtual;
function PrintFailureItems(r :TTestResult): string; virtual;
function PrintErrorItems(r :TTestResult): string; virtual;
function Report(r: TTestResult): string;
function IsNamespaceSuite(suite : ITest) : boolean;
function FormatNUnitTime(const value : Extended) : string;
public
// implement the ITestListener interface
procedure AddSuccess(test: ITest); virtual;
procedure AddError(error: TTestFailure); virtual;
procedure AddFailure(failure: TTestFailure); virtual;
function ShouldRunTest(test :ITest):boolean; virtual;
procedure StartSuite(suite: ITest); virtual;
procedure EndSuite(suite: ITest); virtual;
procedure StartTest(test: ITest); virtual;
procedure EndTest(test: ITest); virtual;
procedure TestingStarts; virtual;
procedure TestingEnds(testResult: TTestResult); virtual;
procedure Status(test :ITest; const Msg :string);
constructor Create; overload;
constructor Create(outputFile : String); overload;
destructor Destroy; override;
class function RunTest(suite: ITest; outputFile:String): TTestResult; overload;
class function RunRegisteredTests(outputFile:String): TTestResult;
class function text2sgml(text : String) : String;
class function StringReplaceAll (text,byt,mot : string ) :string;
//:Report filename. If an empty string, then standard output is used (compile with -CC option)
property FileName : String read FFileName write FFileName;
end;
{: Run the given test suite
}
function RunTest(suite: ITest; outputFile:String=DEFAULT_FILENAME) : TTestResult; overload;
function RunRegisteredTests(outputFile:String=DEFAULT_FILENAME) : TTestResult; overload;
var
PrintReportToConsole : boolean = true;
implementation
uses Forms, Windows, ActiveX;
const
CRLF = #13#10;
MAX_DEEP = 5;
function IsValidXMLChar(wc: WideChar): Boolean;
begin
case Word(wc) of
$0009, $000A, $000C, $000D,
$0020..$D7FF,
$E000..$FFFD, // Standard Unicode chars below $FFFF
$D800..$DBFF, // High surrogate of Unicode character = $10000 - $10FFFF
$DC00..$DFFF: // Low surrogate of Unicode character = $10000 - $10FFFF
result := True;
else
result := False;
end;
end;
function StripInvalidXML(const s: string): string;
var
i, count: Integer;
begin
count := Length(s);
setLength(result, count);
for i := 1 to Count do // Iterate
begin
if IsValidXMLChar(WideChar(s[i])) then
result[i] := s[i]
else
result[i] := ' ';
end; // for}
end;
function EscapeForXML(const value: string; const isAttribute: boolean = True; const isCDATASection : Boolean = False): string;
begin
result := StripInvalidXML(value);
if isCDATASection then
begin
Result := StringReplace(Result, ']]>', ']>',[rfReplaceAll]);
exit;
end;
//note we are avoiding replacing & with &amp; !!
Result := StringReplace(result, '&', '[[-xy-amp--]]',[rfReplaceAll]);
Result := StringReplace(result, '&', '&',[rfReplaceAll]);
Result := StringReplace(result, '[[-xy-amp--]]', '&amp;',[rfReplaceAll]);
Result := StringReplace(result, '<', '<',[rfReplaceAll]);
Result := StringReplace(result, '>', '>',[rfReplaceAll]);
if isAttribute then
begin
Result := StringReplace(result, '''', ''',[rfReplaceAll]);
Result := StringReplace(result, '"', '"',[rfReplaceAll]);
end;
end;
{ TXMLTestListener }
constructor TXMLTestListener.Create;
begin
Create(DEFAULT_FILENAME);
end;
constructor TXMLTestListener.Create(outputFile : String);
var
pi : IXMLDOMProcessingInstruction;
begin
inherited Create;
{$IFDEF FORMATSETTINGS}
FFormatSettings := TFormatSettings.Create('en-US');
{$ENDIF}
FileName := outputFile;
FMessageList := TStringList.Create;
CoInitializeEx(nil,COINIT_MULTITHREADED);
FXMLDoc := ComsFreeThreadedDOMDocument.Create;
{$IFDEF UNICODE}
pi := FXmlDoc.createProcessingInstruction('xml' ,'version="1.0" encoding="UTF-8"');
{$ELSE}
pi := FXmlDoc.createProcessingInstruction('xml' ,'version="1.0" encoding="ISO-8859-1"');
{$ENDIF}
FXMLDoc.appendChild(pi);
FTestResultsElement := FXMLDoc.createElement('test-results');
FTestResultsElement.setAttribute('name',ExtractFileName(ParamStr(0)));
FXMLDoc.appendChild(FTestResultsElement);
FSuiteDataStack := TList.Create;
end;
function TXMLTestListener.CurrentResultsElement: IXMLDOMElement;
begin
Assert(FSuiteDataStack.Count > 0);
result := TSuiteData(FSuiteDataStack.Items[0]).ResultsElement;
end;
function TXMLTestListener.CurrentSuiteElement: IXMLDOMElement;
begin
Assert(FSuiteDataStack.Count > 0);
result := TSuiteData(FSuiteDataStack.Items[0]).SuiteElement;
end;
const
TrueFalse : array[Boolean] of string = ('False', 'True');
procedure TXMLTestListener.AddSuccess(test: ITest);
var
msgElement : IXMLDOMElement;
reasonElement : IXMLDOMElement;
cData : IXMLDOMCDATASection;
sMessage : string;
i : integer;
begin
if FCurrentTestElement <> nil then
begin
FCurrentTestElement.setAttribute('success','True');
FCurrentTestElement.setAttribute('result','Success');
FCurrentTestElement.setAttribute('time',FormatNUnitTime(test.ElapsedTestTime / 1000));
if FMessageList.Count > 0 then
begin
reasonElement := FXMLDoc.createElement('reason');
FCurrentTestElement.appendChild(reasonElement);
msgElement := FXMLDoc.createElement('message');
reasonElement.appendChild(msgElement);
for i := 0 to FMessageList.Count - 1 do
sMessage := sMessage + EscapeForXML(FMessageList.Strings[i],false) + #13#10;
cData := FXMLDoc.createCDATASection(sMessage);
msgElement.appendChild(cData);
end;
FMessageList.Clear;
end;
end;
procedure TXMLTestListener.AddError(error: TTestFailure);
var
msgElement : IXMLDOMElement;
failureElement : IXMLDOMElement;
cData : IXMLDOMCDATASection;
begin
if FCurrentTestElement <> nil then
begin
FCurrentTestElement.setAttribute('success','False');
FCurrentTestElement.setAttribute('result','Error');
FCurrentTestElement.setAttribute('time',FormatNUnitTime(error.FailedTest.ElapsedTestTime / 1000));
failureElement := FXMLDoc.createElement('failure');
FCurrentTestElement.appendChild(failureElement);
msgElement := FXMLDoc.createElement('message');
failureElement.appendChild(msgElement);
cData := FXMLDoc.createCDATASection(EscapeForXML(error.ThrownExceptionMessage,false));
msgElement.appendChild(cData);
end;
Inc(FErrorCount);
end;
procedure TXMLTestListener.AddFailure(failure: TTestFailure);
var
msgElement : IXMLDOMElement;
failureElement : IXMLDOMElement;
cData : IXMLDOMCDATASection;
begin
if FCurrentTestElement <> nil then
begin
FCurrentTestElement.setAttribute('success','False');
FCurrentTestElement.setAttribute('result','Failure');
FCurrentTestElement.setAttribute('time',FormatNUnitTime(failure.FailedTest.ElapsedTestTime / 1000));
failureElement := FXMLDoc.createElement('failure');
FCurrentTestElement.appendChild(failureElement);
msgElement := FXMLDoc.createElement('message');
failureElement.appendChild(msgElement);
cData := FXMLDoc.createCDATASection(EscapeForXML(failure.ThrownExceptionMessage,false));
msgElement.appendChild(cData);
end;
Inc(FFailureCount);
end;
procedure TXMLTestListener.StartTest(test: ITest);
begin
FMessageList.Clear;
if Supports(test,ITestSuite) then
exit;
FCurrentTestElement := FXMLDoc.createElement('test-case');
FCurrentTestElement.setAttribute('name',test.Name);
FCurrentTestElement.setAttribute('executed','True');
FCurrentTestElement.setAttribute('success','True');
FCurrentTestElement.setAttribute('result','Success');
FCurrentTestElement.setAttribute('time','0');
CurrentResultsElement.appendChild(FCurrentTestElement);
end;
procedure TXMLTestListener.EndTest(test: ITest);
begin
FCurrentTestElement := nil;
end;
function TXMLTestListener.FormatNUnitTime(const value: Extended): string;
{$IFNDEF FORMATSETTINGS}
var
oldDecimalSeparator : Char;
{$ENDIF}
begin
{$IFDEF FORMATSETTINGS}
result := Format('%1.3f',[value],FFormatSettings);
{$ELSE}
oldDecimalSeparator := SysUtils.DecimalSeparator;
SysUtils.DecimalSeparator := '.';
result := Format('%1.3f',[value]);
SysUtils.DecimalSeparator := oldDecimalSeparator;
{$ENDIF}
end;
procedure TXMLTestListener.TestingStarts;
var
sFileName : string;
begin
FStartDateTime := Now;
sFileName := ExtractFileName(ParamStr(0));
end;
procedure TXMLTestListener.TestingEnds(testResult: TTestResult);
var
dtRunTime : TDateTime;
h, m, s, l :Word;
begin
//when no namespaces are used for registering test suites, it seems startsuite is called for the exe,
//but endsuite is not.
if FSuiteDataStack.Count > 0 then
begin
CurrentSuiteElement.setAttribute('time',FormatNUnitTime(testResult.TotalTime / 1000));
if (FErrorCount > 0) or (FFailureCount > 0) then
begin
CurrentSuiteElement.setAttribute('result','Failure');
CurrentSuiteElement.setAttribute('success','False');
end
else
begin
CurrentSuiteElement.setAttribute('result','Success');
CurrentSuiteElement.setAttribute('success','True');
end;
end;
FTestResultsElement.setAttribute('total',IntToStr(RegisteredTests.CountTestCases));
FTestResultsElement.setAttribute('not-run',IntToStr(RegisteredTests.CountTestCases - RegisteredTests.CountEnabledTestCases));
FTestResultsElement.setAttribute('errors',IntToStr(testResult.errorCount));
FTestResultsElement.setAttribute('failures',IntToStr(testResult.FailureCount));
FTestResultsElement.setAttribute('date',DateToStr(Now));
FTestResultsElement.setAttribute('time',FormatNUnitTime(testResult.TotalTime / 1000));
if ExtractFilePath(FFileName) = '' then
FFileName := ExtractFilePath(ParamStr(0)) + FFileName;
ForceDirectories(ExtractFilePath(FFileName));
FXMLDoc.save(FFileName);
if PrintReportToConsole then
begin
FEndDateTime := now;
dtRunTime := Now-FStartDateTime;
writeln;
DecodeTime(dtRunTime, h, m, s, l);
writeln(Format('Time: %d:%2.2d:%2.2d.%d', [h, m, s, l]));
writeln(Report(testResult));
writeln;
end;
end;
class function TXMLTestListener.RunTest(suite: ITest; outputFile:String): TTestResult;
begin
Result := TestFramework.RunTest(suite, [TXMLTestListener.Create(outputFile)]);
end;
function TXMLTestListener.Report(r: TTestResult): string;
begin
result := PrintHeader(r) +
PrintErrors(r) +
PrintFailures(r);
end;
class function TXMLTestListener.RunRegisteredTests(outputFile:String): TTestResult;
begin
Result := RunTest(registeredTests, outputFile);
end;
function RunTest(suite: ITest; outputFile:String=DEFAULT_FILENAME): TTestResult;
begin
Result := TestFramework.RunTest(suite, [TXMLTestListener.Create(outputFile)]);
end;
function RunRegisteredTests(outputFile:String=DEFAULT_FILENAME): TTestResult;
begin
Result := RunTest(registeredTests, outputFile);
end;
procedure TXMLTestListener.Status(test: ITest; const Msg: string);
begin
FMessageList.Add(Format('STATUS: %s: %s', [test.Name, Msg]));
end;
function TXMLTestListener.ShouldRunTest(test: ITest): boolean;
begin
Result := test.Enabled;
(*
if not Result then
writeReport(Format('<test-case name="%s%s" executed="False"/>',
[GetCurrentSuiteName, test.GetName]));
*)
end;
procedure TXMLTestListener.EndSuite(suite: ITest);
var
suiteElement : IXMLDOMElement;
resultsElement : IXMLDOMElement;
name : string;
begin
//update the current suite.. then pop.
CurrentSuiteElement.setAttribute('time',FormatNUnitTime(suite.ElapsedTestTime / 1000));
if (FErrorCount > 0) or (FFailureCount > 0) then
begin
CurrentSuiteElement.setAttribute('result','Failure');
CurrentSuiteElement.setAttribute('success','False');
end
else
begin
CurrentSuiteElement.setAttribute('result','Success');
CurrentSuiteElement.setAttribute('success','True');
end;
PopSuite(suiteElement,resultsElement,name);
end;
procedure TXMLTestListener.StartSuite(suite: ITest);
var
suiteElement : IXMLDOMElement;
resultsElement : IXMLDOMElement;
sType : string;
sNameSpace : string;
begin
sNameSpace := ExtractFileName(ParamStr(0));
//treat the application suite as the assembly.
if CompareText(suite.Name, sNameSpace) = 0 then
begin
suiteElement := FXMLDoc.createElement('test-suite');
suiteElement.setAttribute('type','Assembly');
suiteElement.setAttribute('name',suite.Name);
{ suiteElement.setAttribute('result','Success');
suiteElement.setAttribute('success','True');
suiteElement.setAttribute('time','0');}
FTestResultsElement.appendChild(suiteElement);
resultsElement := FXMLDoc.createElement('results');
suiteElement.appendChild(resultsElement);
PushSuite(suiteElement,resultsElement,suite.Name);
exit;
end;
//treat suites that only have other suites as children as namespaces.
if IsNamespaceSuite(suite) then
sType := 'Namespace'
else
sType := 'TestFixture';
//make sure we have a parent namespace for the testfixture
if sType = 'TestFixture' then
begin
if CurrentSuiteElement.getAttribute('type') <> 'Namespace' then
begin
sNameSpace := ChangeFileExt(sNameSpace,'');
suiteElement := FXMLDoc.createElement('test-suite');
suiteElement.setAttribute('type','Namespace');
suiteElement.setAttribute('name',sNameSpace);
CurrentResultsElement.appendChild(suiteElement);
resultsElement := FXMLDoc.createElement('results');
suiteElement.appendChild(resultsElement);
PushSuite(suiteElement,resultsElement,suite.Name);
end;
end;
suiteElement := FXMLDoc.createElement('test-suite');
suiteElement.setAttribute('type',sType);
suiteElement.setAttribute('name',suite.Name);
CurrentResultsElement.appendChild(suiteElement);
resultsElement := FXMLDoc.createElement('results');
suiteElement.appendChild(resultsElement);
PushSuite(suiteElement,resultsElement,suite.Name);
end;
{:
Replace byt string by mot in text string
}
class function TXMLTestListener.StringReplaceAll (text,byt,mot : string ) :string;
var
plats : integer;
begin
While pos(byt,text) > 0 do
begin
plats := pos(byt,text);
delete (text,plats,length(byt));
insert (mot,text,plats);
end;
result := text;
end;
{:
Replace special character by sgml compliant characters
}
class function TXMLTestListener.text2sgml(text : String) : String;
begin
text := stringreplaceall (text,'<','<');
text := stringreplaceall (text,'>','>');
result := text;
end;
destructor TXMLTestListener.Destroy;
begin
FMessageList.Free;
FSuiteDataStack.Destroy;
inherited Destroy;
end;
//A namespace suite will only have test suites as children.
function TXMLTestListener.IsNamespaceSuite(suite: ITest): boolean;
var
i: Integer;
test : ITest;
begin
result := True;
for i := 0 to suite.Tests.Count -1 do
begin
test := suite.Tests.Items[i] as ITest;
if not Supports(test,ITestSuite) then
begin
result := False;
exit;
end;
end;
end;
procedure TXMLTestListener.PopSuite(var suiteElement, resultsElement : IXMLDOMElement; var name : string);
var
data : TSuiteData;
begin
Assert(FSuiteDataStack.Count > 0);
data := TSuiteData(FSuiteDataStack.Items[0]);
suiteElement := data.SuiteElement;
resultsElement := data.ResultsElement;
name := data.Name;
FSuiteDataStack.Delete(0);
FErrorCount := FErrorCount + data.ErrorCount;
FFailureCount := FFailureCount + data.FailureCount;
data.Free;
end;
function TXMLTestListener.PrintErrorItems(r: TTestResult): string;
var
i: Integer;
failure: TTestFailure;
begin
result := '';
for i := 0 to r.ErrorCount-1 do begin
failure := r.Errors[i];
result := result + format('%3d) %s: %s'#13#10' at %s'#13#10' "%s"',
[
i+1,
failure.failedTest.name,
failure.thrownExceptionName,
failure.LocationInfo,
failure.thrownExceptionMessage
]) + CRLF;
end;
end;
function TXMLTestListener.PrintErrors(r: TTestResult): string;
begin
result := '';
if (r.errorCount <> 0) then begin
if (r.errorCount = 1) then
result := result + format('There was %d error:', [r.errorCount]) + CRLF
else
result := result + format('There were %d errors:', [r.errorCount]) + CRLF;
result := result + PrintErrorItems(r);
result := result + CRLF
end
end;
function TXMLTestListener.PrintFailureItems(r: TTestResult): string;
var
i: Integer;
failure: TTestFailure;
begin
result := '';
for i := 0 to r.FailureCount-1 do begin
failure := r.Failures[i];
result := result + format('%3d) %s: %s'#13#10' at %s'#13#10' "%s"',
[
i+1,
failure.failedTest.name,
failure.thrownExceptionName,
failure.LocationInfo,
failure.thrownExceptionMessage
]) + CRLF;
end;
end;
function TXMLTestListener.PrintFailures(r: TTestResult): string;
begin
result := '';
if (r.failureCount <> 0) then begin
if (r.failureCount = 1) then
result := result + format('There was %d failure:', [r.failureCount]) + CRLF
else
result := result + format('There were %d failures:', [r.failureCount]) + CRLF;
result := result + PrintFailureItems(r);
result := result + CRLF
end
end;
function TXMLTestListener.PrintHeader(r: TTestResult): string;
begin
result := '';
if r.wasSuccessful then
begin
result := result + CRLF;
result := result + format('OK: %d tests'+CRLF, [r.runCount]);
end
else
begin
result := result + CRLF;
result := result + 'FAILURES!!!'+CRLF;
result := result + 'Test Results:'+CRLF;
result := result + format('Run: %8d'+CRLF+'Failures: %8d'+CRLF+'Errors: %8d'+CRLF,
[r.runCount, r.failureCount, r.errorCount]
);
end
end;
procedure TXMLTestListener.PushSuite(const suiteElement, resultsElement : IXMLDOMElement; const name : string);
var
data : TSuiteData;
begin
data := TSuiteData.Create;
data.SuiteElement := suiteElement;
data.ResultsElement := resultsElement;
data.ErrorCount := FErrorCount;
data.FailureCount := FFailureCount;
data.Name := name;
FSuiteDataStack.Insert(0,data);
FFailureCount := 0;
FErrorCount := 0;
end;
end.
| 31.359155 | 127 | 0.667146 |
fcb7876f1e0fad233e765e5533c4b6a73df501d0 | 333 | pas | Pascal | guihelperunit.pas | Jeff-Bouchard/EmerAPI_KeyKeeper | ff79e71e0d1505de3a78b6543483355c1ac320ae | [
"MIT"
]
| 2 | 2019-02-05T18:34:05.000Z | 2019-04-14T13:52:44.000Z | guihelperunit.pas | DenisDx/EmerAPI_KeyKeeper | c6921710413871ca039e5bebea0877aceb9a8b74 | [
"MIT"
]
| null | null | null | guihelperunit.pas | DenisDx/EmerAPI_KeyKeeper | c6921710413871ca039e5bebea0877aceb9a8b74 | [
"MIT"
]
| 2 | 2019-04-10T21:23:42.000Z | 2020-12-11T20:59:13.000Z | unit GUIHelperUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, graphics, StdCtrls, ExtCtrls ;
type
tVisualData = class(tObject)
public
bgColor:tColor;
slabel:tLabel;
sEdit:tEdit;
sgroupbox:tGroupBox;
sPanel:tPanel;
sButton:tButton;
end;
implementation
end.
| 11.892857 | 78 | 0.6997 |
fcca18a88ace790e1351cfd58d69bc16afe49e9a | 849 | dpr | Pascal | Source/SimpleWizardD2010.dpr | androschuk/D.Wizard.Simple | af242533cea8ce477e3a62176669e76a1c5f44dd | [
"MIT"
]
| 1 | 2019-03-24T00:28:33.000Z | 2019-03-24T00:28:33.000Z | Source/SimpleWizardD2010.dpr | androschuk/D.Wizard.Simple | af242533cea8ce477e3a62176669e76a1c5f44dd | [
"MIT"
]
| null | null | null | Source/SimpleWizardD2010.dpr | androschuk/D.Wizard.Simple | af242533cea8ce477e3a62176669e76a1c5f44dd | [
"MIT"
]
| null | null | null | library SimpleWizardD2010;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
ShareMem,
SysUtils,
Classes,
WizardInit in 'WizardInit.pas',
WizardImpl in 'WizardImpl.pas';
{$R *.res}
exports
InitWizard name 'INITWIZARD0001',
InitWizard name 'WizardEntryPoint';
begin
end.
| 30.321429 | 72 | 0.772674 |
c3aa4ebb3256a68cff05b002f96463f1c77c2571 | 1,441 | pas | Pascal | sources/Firebase.Response.pas | wfssoftware/firebaseD10 | c0daa94df22856828d4565755c258fb1c63e3263 | [
"Apache-2.0"
]
| 109 | 2015-06-02T06:54:44.000Z | 2022-02-28T20:48:41.000Z | sources/Firebase.Response.pas | wfssoftware/firebaseD10 | c0daa94df22856828d4565755c258fb1c63e3263 | [
"Apache-2.0"
]
| 10 | 2019-12-30T04:09:37.000Z | 2022-03-02T06:06:19.000Z | sources/Firebase.Response.pas | wfssoftware/firebaseD10 | c0daa94df22856828d4565755c258fb1c63e3263 | [
"Apache-2.0"
]
| 31 | 2016-01-11T17:40:43.000Z | 2021-09-03T16:33:06.000Z | { *******************************************************************************
Copyright 2015 Daniele Spinetti
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
********************************************************************************}
unit Firebase.Response;
interface
uses
Firebase.Interfaces,
System.SysUtils,
System.Net.HttpClient;
type
TFirebaseResponse = class(TInterfacedObject, IFirebaseResponse)
private
FHttpResponse: IHTTPResponse;
public
constructor Create(AHTTPResponse: IHTTPResponse);
function ContentAsString(const AEncoding: TEncoding = nil): string;
end;
implementation
{ TFirebaseResponse }
function TFirebaseResponse.ContentAsString(const AEncoding
: TEncoding = nil): string;
begin
Result := FHttpResponse.ContentAsString(AEncoding);
end;
constructor TFirebaseResponse.Create(AHTTPResponse: IHTTPResponse);
begin
inherited Create;
FHttpResponse := AHTTPResponse;
end;
end.
| 27.188679 | 83 | 0.689799 |
47012a0413ed771defad16ffdc39962174e4645f | 19,060 | dfm | Pascal | M2Server/NpcCustomU.dfm | 98kmir2/98kmir2 | 46196a161d46cc7a85d168dca683b4aff477a709 | [
"BSD-3-Clause"
]
| 15 | 2020-02-13T11:59:11.000Z | 2021-12-31T14:53:44.000Z | M2Server/NpcCustomU.dfm | bsjzx8/98 | 46196a161d46cc7a85d168dca683b4aff477a709 | [
"BSD-3-Clause"
]
| null | null | null | M2Server/NpcCustomU.dfm | bsjzx8/98 | 46196a161d46cc7a85d168dca683b4aff477a709 | [
"BSD-3-Clause"
]
| 13 | 2020-02-20T07:22:09.000Z | 2021-12-31T14:56:09.000Z | object ftmNpcCustom: TftmNpcCustom
Left = 551
Top = 233
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle
Caption = #33258#23450#20041'NPC'
ClientHeight = 473
ClientWidth = 884
Color = clBtnFace
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -12
Font.Name = #23435#20307
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 12
object lbl: TLabel
Left = 25
Top = 11
Width = 80
Height = 12
AutoSize = False
Caption = 'NPC'#20195#30721
end
object lbl1: TLabel
Left = 24
Top = 36
Width = 80
Height = 12
AutoSize = False
Caption = 'NPC'#36164#28304#25991#20214
end
object lbl4: TLabel
Left = 17
Top = 82
Width = 91
Height = 12
AutoSize = False
Caption = #25773#25918#36895#24230'('#27627#31186')'
end
object lbl5: TLabel
Left = 25
Top = 60
Width = 54
Height = 12
AutoSize = False
Caption = 'NPC'#26041#21521
end
object BtnAdd: TButton
Left = 778
Top = 8
Width = 36
Height = 25
Caption = #26032#22686
TabOrder = 0
OnClick = BtnAddClick
end
object btnDel: TButton
Left = 789
Top = 34
Width = 77
Height = 23
Caption = #21333#26465#21024#38500
TabOrder = 1
OnClick = btnDelClick
end
object btnSave: TButton
Left = 789
Top = 82
Width = 77
Height = 23
Caption = #20445#23384
TabOrder = 2
OnClick = btnSaveClick
end
object EdtNpcCode: TSpinEdit
Left = 105
Top = 7
Width = 144
Height = 21
Hint = #25903#25345#30340#33258#23450#20041'NPC'#20195#30721#20026'500..999|'#25903#25345#30340#33258#23450#20041#29305#25928#31867#22411#20026'100..199'
MaxValue = 999
MinValue = 500
ParentShowHint = False
ShowHint = True
TabOrder = 3
Value = 500
end
object comboResourceFileIndex: TComboBox
Left = 104
Top = 31
Width = 145
Height = 22
Hint = #21462#20540#26469#28304#33258#23450#20041#36164#28304#25991#20214#21015#34920
Style = csOwnerDrawFixed
ItemHeight = 16
ParentShowHint = False
ShowHint = True
TabOrder = 4
end
object EdtPlaySpeed: TSpinEdit
Left = 105
Top = 78
Width = 144
Height = 21
Hint = #25773#25918#36895#24230'('#27627#31186')'#33539#22260#20026'1..999999999'
MaxValue = 999999999
MinValue = 1
ParentShowHint = False
ShowHint = True
TabOrder = 5
Value = 20
end
object ComboNPCDir: TComboBox
Left = 104
Top = 55
Width = 145
Height = 22
Hint = 'NPC'#26041#21521#20026'8'#21521'0..7,0'#20026#38754#26397#19978#26041',2'#20026#38754#26397#21491#26041#65292'4'#20026#38754#26397#19979#26041',6'#20026#38754#26397#24038#26041
Style = csOwnerDrawFixed
ItemHeight = 16
ItemIndex = 0
ParentShowHint = False
ShowHint = True
TabOrder = 6
Text = '0'
Items.Strings = (
'0'
'1'
'2'
'3'
'4'
'5'
'6'
'7')
end
object grp1: TGroupBox
Left = 8
Top = 105
Width = 214
Height = 346
Caption = 'NPC'#20195#30721#31579#36873#27719#24635
TabOrder = 7
object lstNpcCode: TListBox
Left = 4
Top = 13
Width = 205
Height = 329
ItemHeight = 12
TabOrder = 0
OnClick = lstNpcCodeClick
end
end
object grp2: TGroupBox
Left = 224
Top = 288
Width = 638
Height = 169
Caption = #25152#26377#33258#23450#20041'NPC'#35760#24405'('#20379#26597#30475')'
TabOrder = 8
Visible = False
object lvNpcCustom: TListView
Left = 1
Top = 14
Width = 633
Height = 151
Columns = <
item
Caption = 'NPC'#20195#30721
Width = 60
end
item
Caption = #36164#28304#25991#20214#32034#24341
Width = 85
end
item
Caption = #36164#28304#25991#20214#21517#31216
Width = 85
end
item
Caption = 'NPC'#26041#21521
Width = 60
end
item
Caption = #25773#25918#36895#24230
Width = 60
end
item
Caption = #31449#31435#26412#20307#36215#22987#24103
Width = 100
end
item
Caption = #21551#29992#31449#31435#29305#25928
Width = 85
end
item
Caption = #31449#31435#29305#25928#36215#22987#24103
Width = 100
end
item
Caption = #31449#31435#25773#25918#24103#25968
Width = 85
end
item
Caption = #21160#20316#26412#20307#36215#22987#24103
Width = 100
end
item
Caption = #21551#29992#21160#20316#29305#25928
Width = 85
end
item
Caption = #21160#20316#29305#25928#36215#22987#24103
Width = 100
end
item
Caption = #21160#20316#25773#25918#24103#25968
Width = 85
end>
GridLines = True
ReadOnly = True
TabOrder = 0
ViewStyle = vsReport
end
end
object grp3: TGroupBox
Left = 225
Top = 286
Width = 638
Height = 169
Caption = #24403#21069#31579#36873#33258#23450#20041'NPC'#35760#24405'('#25353'SHIFT'#38190#25110'CTRL'#38190#21487#20197#36873#25321#22810#26465#35760#24405')'
TabOrder = 9
object lvFilterNpcCustom: TListView
Left = 5
Top = 14
Width = 629
Height = 151
Columns = <
item
Caption = 'NPC'#20195#30721
Width = 60
end
item
Caption = #36164#28304#25991#20214#32034#24341
Width = 85
end
item
Caption = #36164#28304#25991#20214#21517#31216
Width = 85
end
item
Caption = 'NPC'#26041#21521
Width = 60
end
item
Caption = #25773#25918#36895#24230
Width = 60
end
item
Caption = #31449#31435#36215#22987#24103
Width = 75
end
item
Caption = #21551#29992#31449#31435#29305#25928
Width = 85
end
item
Caption = #31449#31435#29305#25928#36215#22987#24103
Width = 100
end
item
Caption = #31449#31435#25773#25918#24103#25968
Width = 85
end
item
Caption = #21160#20316#36215#22987#24103
Width = 75
end
item
Caption = #21551#29992#21160#20316#29305#25928
Width = 85
end
item
Caption = #21160#20316#29305#25928#36215#22987#24103
Width = 100
end
item
Caption = #21160#20316#25773#25918#24103#25968
Width = 85
end>
GridLines = True
MultiSelect = True
ReadOnly = True
RowSelect = True
TabOrder = 0
ViewStyle = vsReport
OnClick = lvFilterNpcCustomClick
end
end
object grp4: TGroupBox
Left = 256
Top = 0
Width = 249
Height = 105
Caption = #31449#31435#21160#30011
TabOrder = 10
object lbl2: TLabel
Left = 9
Top = 18
Width = 89
Height = 12
AutoSize = False
Caption = #31449#31435#36215#22987#24103
end
object lbl3: TLabel
Left = 9
Top = 42
Width = 80
Height = 12
AutoSize = False
Caption = #25773#25918#24103#24635#25968
end
object lbl6: TLabel
Left = 9
Top = 64
Width = 89
Height = 12
AutoSize = False
Caption = #29305#25928#36215#22987#24103
end
object EdtStandStartOffset: TSpinEdit
Left = 97
Top = 14
Width = 144
Height = 21
Hint = #31449#31435#26412#20307#36215#22987#24103#20026'0..65535'
MaxValue = 65535
MinValue = 0
ParentShowHint = False
ShowHint = True
TabOrder = 0
Value = 0
end
object EdtStandPlayCount: TSpinEdit
Left = 97
Top = 38
Width = 144
Height = 21
Hint = #31449#31435#25773#25918#24103#25968#33539#22260#20026'1..65535'
MaxValue = 65535
MinValue = 1
ParentShowHint = False
ShowHint = True
TabOrder = 1
Value = 1
end
object chkStandUseEffect: TCheckBox
Left = 96
Top = 83
Width = 113
Height = 17
Caption = #21551#29992#31449#31435#29305#25928
TabOrder = 2
end
object EdtStandEffectStartOffset: TSpinEdit
Left = 97
Top = 59
Width = 144
Height = 21
Hint = #31449#31435#29305#25928#36215#22987#24103#20026'0..65535'
MaxValue = 65535
MinValue = 0
ParentShowHint = False
ShowHint = True
TabOrder = 3
Value = 0
end
end
object grp5: TGroupBox
Left = 512
Top = 0
Width = 265
Height = 106
Caption = #21160#20316#21160#30011
TabOrder = 11
object lbl7: TLabel
Left = 16
Top = 18
Width = 89
Height = 12
AutoSize = False
Caption = #21160#20316#36215#22987#24103
end
object lbl8: TLabel
Left = 16
Top = 64
Width = 89
Height = 12
AutoSize = False
Caption = #29305#25928#36215#22987#24103
end
object lbl9: TLabel
Left = 17
Top = 41
Width = 80
Height = 12
AutoSize = False
Caption = #25773#25918#24103#24635#25968
end
object ChkHitUseEffect: TCheckBox
Left = 105
Top = 83
Width = 129
Height = 17
Caption = #21551#29992#21160#20316#29305#25928
TabOrder = 0
end
object EdtHitStartOffset: TSpinEdit
Left = 105
Top = 14
Width = 144
Height = 21
Hint = #21160#20316#26412#20307#36215#22987#24103#20026'0..65535'
MaxValue = 65535
MinValue = 0
ParentShowHint = False
ShowHint = True
TabOrder = 1
Value = 0
end
object EdtHitEffectStartOffset: TSpinEdit
Left = 104
Top = 60
Width = 144
Height = 21
Hint = #21160#20316#29305#25928#36215#22987#24103#20026'0..65535'
MaxValue = 65535
MinValue = 0
ParentShowHint = False
ShowHint = True
TabOrder = 2
Value = 0
end
object EdtHitPlayCount: TSpinEdit
Left = 105
Top = 37
Width = 144
Height = 21
Hint = #21160#20316#25773#25918#24103#25968#33539#22260#20026'1..65535'
MaxValue = 65535
MinValue = 1
ParentShowHint = False
ShowHint = True
TabOrder = 3
Value = 1
end
end
object btnUpdate: TButton
Left = 789
Top = 58
Width = 77
Height = 23
Caption = #21333#26465#20462#25913
TabOrder = 12
OnClick = btnUpdateClick
end
object grp6: TGroupBox
Left = 225
Top = 105
Width = 376
Height = 176
Caption = #25209#37327#21151#33021
TabOrder = 13
object lbl10: TLabel
Left = 134
Top = 18
Width = 80
Height = 12
AutoSize = False
Caption = 'NPC'#36164#28304#25991#20214
end
object lbl11: TLabel
Left = 133
Top = 40
Width = 91
Height = 12
AutoSize = False
Caption = #25773#25918#36895#24230'('#27627#31186')'
end
object lbl12: TLabel
Left = 134
Top = 64
Width = 80
Height = 12
AutoSize = False
Caption = #21551#29992#31449#31435#29305#25928
end
object lbl13: TLabel
Left = 134
Top = 88
Width = 80
Height = 12
AutoSize = False
Caption = #21551#29992#21160#20316#29305#25928
end
object lbl14: TLabel
Left = 133
Top = 111
Width = 91
Height = 12
AutoSize = False
Caption = #31449#31435#25773#25918#24103#24635#25968
end
object lbl15: TLabel
Left = 132
Top = 134
Width = 91
Height = 12
AutoSize = False
Caption = #21160#20316#25773#25918#24103#24635#25968
end
object btnBatchUpdate: TButton
Left = 150
Top = 150
Width = 73
Height = 23
Caption = #25209#37327#20462#25913
TabOrder = 0
OnClick = btnBatchUpdateClick
end
object chkBatchUpdateResource: TCheckBox
Left = 9
Top = 17
Width = 122
Height = 17
Caption = #25209#37327#20462#25913#36164#28304#25991#20214
TabOrder = 1
OnClick = chkBatchUpdateResourceClick
end
object comboResourceFileIndexBatch: TComboBox
Left = 220
Top = 11
Width = 145
Height = 22
Hint = #21462#20540#26469#28304#33258#23450#20041#36164#28304#25991#20214#21015#34920
Style = csOwnerDrawFixed
ItemHeight = 16
ParentShowHint = False
ShowHint = True
TabOrder = 2
end
object chkBatchUpdatePlaySpeed: TCheckBox
Left = 9
Top = 39
Width = 119
Height = 17
Caption = #25209#37327#20462#25913#25773#25918#36895#24230
TabOrder = 3
OnClick = chkBatchUpdatePlaySpeedClick
end
object comboPlaySpeedBatch: TSpinEdit
Left = 221
Top = 35
Width = 144
Height = 21
Hint = #25773#25918#36895#24230'('#27627#31186')'#33539#22260#20026'1..999999999'
MaxValue = 999999999
MinValue = 1
ParentShowHint = False
ShowHint = True
TabOrder = 4
Value = 20
end
object chkBatchUpdateStandEffect: TCheckBox
Left = 9
Top = 63
Width = 122
Height = 17
Caption = #25209#37327#20462#25913#31449#31435#29305#25928
TabOrder = 5
OnClick = chkBatchUpdateStandEffectClick
end
object comboStandEffect: TComboBox
Left = 220
Top = 58
Width = 145
Height = 22
Hint = '0.'#20851#38381#13#10'1.'#21551#29992
Style = csOwnerDrawFixed
ItemHeight = 16
ItemIndex = 0
ParentShowHint = False
ShowHint = True
TabOrder = 6
Text = '0'
Items.Strings = (
'0'
'1')
end
object chkBatchUpdateHitEffect: TCheckBox
Left = 9
Top = 87
Width = 122
Height = 17
Caption = #25209#37327#20462#25913#21160#20316#29305#25928
TabOrder = 7
OnClick = chkBatchUpdateHitEffectClick
end
object comboHitEffect: TComboBox
Left = 220
Top = 82
Width = 145
Height = 22
Hint = '0.'#20851#38381#13#10'1.'#21551#29992
Style = csOwnerDrawFixed
ItemHeight = 16
ItemIndex = 0
ParentShowHint = False
ShowHint = True
TabOrder = 8
Text = '0'
Items.Strings = (
'0'
'1')
end
object chkBatchUpdateStandCount: TCheckBox
Left = 9
Top = 110
Width = 119
Height = 17
Caption = #25209#37327#20462#25913#31449#31435#24103#25968
TabOrder = 9
OnClick = chkBatchUpdateStandCountClick
end
object EdtStandPlayCountBatch: TSpinEdit
Left = 220
Top = 106
Width = 145
Height = 21
Hint = #25773#25918#24103#25968#33539#22260#20026'1..65535'
MaxValue = 65535
MinValue = 1
ParentShowHint = False
ShowHint = True
TabOrder = 10
Value = 1
end
object chkBatchUpdateHitCount: TCheckBox
Left = 8
Top = 133
Width = 119
Height = 17
Caption = #25209#37327#20462#25913#21160#20316#24103#25968
TabOrder = 11
OnClick = chkBatchUpdateHitCountClick
end
object EdtHitPlayCountBatch: TSpinEdit
Left = 220
Top = 129
Width = 145
Height = 21
Hint = #25773#25918#24103#25968#33539#22260#20026'1..65535'
MaxValue = 65535
MinValue = 1
ParentShowHint = False
ShowHint = True
TabOrder = 12
Value = 1
end
end
object grp7: TGroupBox
Left = 608
Top = 106
Width = 254
Height = 175
Caption = #26234#33021#21151#33021
TabOrder = 14
object lbl16: TLabel
Left = 9
Top = 43
Width = 89
Height = 12
AutoSize = False
Caption = #31449#31435#31354#30333#24103#25968
end
object lbl17: TLabel
Left = 9
Top = 67
Width = 89
Height = 12
AutoSize = False
Caption = #31449#31435#29305#25928#31354#30333#24103
end
object lbl18: TLabel
Left = 9
Top = 91
Width = 89
Height = 12
AutoSize = False
Caption = #21160#20316#31354#30333#24103#25968
end
object lbl19: TLabel
Left = 9
Top = 115
Width = 89
Height = 12
AutoSize = False
Caption = #21160#20316#29305#25928#31354#30333#24103
end
object lbl20: TLabel
Left = 9
Top = 18
Width = 81
Height = 12
AutoSize = False
Caption = #21442#32771#22522#20934#26041#21521
end
object btnAutoFill: TButton
Left = 36
Top = 136
Width = 182
Height = 34
Caption = #25353#22522#20934#26041#21521#20026#21442#32771','#25209#37327#35745#31639#26356#26032#20854#23427#26041#21521'('#31449#31435'/'#21160#20316')'#24103#25968#25454
TabOrder = 0
WordWrap = True
OnClick = btnAutoFillClick
end
object EdtStandBlankCount: TSpinEdit
Left = 97
Top = 39
Width = 144
Height = 21
Hint = #24103#25968#33539#22260#20026'0..65535'
MaxValue = 65535
MinValue = 0
ParentShowHint = False
ShowHint = True
TabOrder = 1
Value = 0
end
object EdtStandEffectBlankCount: TSpinEdit
Left = 97
Top = 63
Width = 144
Height = 21
Hint = #24103#25968#33539#22260#20026'0..65535'
MaxValue = 65535
MinValue = 0
ParentShowHint = False
ShowHint = True
TabOrder = 2
Value = 0
end
object EdtHitBlankCount: TSpinEdit
Left = 97
Top = 87
Width = 144
Height = 21
Hint = #24103#25968#33539#22260#20026'0..65535'
MaxValue = 65535
MinValue = 0
ParentShowHint = False
ShowHint = True
TabOrder = 3
Value = 0
end
object EdtHitEffectBlankCount: TSpinEdit
Left = 97
Top = 111
Width = 144
Height = 21
Hint = #24103#25968#33539#22260#20026'0..65535'
MaxValue = 65535
MinValue = 0
ParentShowHint = False
ShowHint = True
TabOrder = 4
Value = 0
end
object comboBaseDir: TComboBox
Left = 96
Top = 13
Width = 145
Height = 22
Hint = 'NPC'#26041#21521#20026'8'#21521'0..7,0'#20026#38754#26397#19978#26041',2'#20026#38754#26397#21491#26041#65292'4'#20026#38754#26397#19979#26041',6'#20026#38754#26397#24038#26041
Style = csOwnerDrawFixed
ItemHeight = 16
ItemIndex = 0
ParentShowHint = False
ShowHint = True
TabOrder = 5
Text = '0'
Items.Strings = (
'0')
end
end
object btnBatchAdd: TButton
Left = 816
Top = 8
Width = 65
Height = 25
Caption = #20840#26041#21521#26032#22686
TabOrder = 15
OnClick = btnBatchAddClick
end
end
| 23.559951 | 190 | 0.571983 |
fc93352f186fd8fd9018110ad3657a713f43fa16 | 4,216 | pas | Pascal | ui.pas | neurolabusc/Part | 7c99841238aba2c3cd38b7121f5b1066e8454c7a | [
"BSD-2-Clause"
]
| 1 | 2020-06-06T08:22:33.000Z | 2020-06-06T08:22:33.000Z | ui.pas | neurolabusc/Part | 7c99841238aba2c3cd38b7121f5b1066e8454c7a | [
"BSD-2-Clause"
]
| null | null | null | ui.pas | neurolabusc/Part | 7c99841238aba2c3cd38b7121f5b1066e8454c7a | [
"BSD-2-Clause"
]
| null | null | null | unit ui;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ToolWin, ComCtrls,nii_core,nii_math, upart, define_types,ezdicom, nii_ttest;
type
Tuiform = class(TForm)
ToolBar1: TToolBar;
AddBtn: TButton;
Memo1: TMemo;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
InspectBtn: TButton;
PartBtn: TButton;
OpenDialog2: TOpenDialog;
ttestBtn: TButton;
procedure DisplayMessages;
function SelectFiles(lTitle: string; AllowMultiSelect: boolean):boolean;
procedure AddBtnClick(Sender: TObject);
procedure InspectBtnClick(Sender: TObject);
procedure PartBtnClick(Sender: TObject);
procedure StrToMemo(lStr: String);
procedure ttestBtnClick(Sender: TObject);
//procedure SelectFiles(AllowMultiSelect: boolean): boolean;
private
{ Private declarations }
public
{ Public declarations }
end;
var
uiform: Tuiform;
implementation
{$R *.dfm}
procedure TuiForm.StrToMemo(lStr: String);
var
lLen,lPos: integer;
lOutStr: string;
begin
lLen := length(lStr);
if lLen < 1 then exit;
lOutStr := '';
for lPos := 1 to lLen do begin
if lStr[lPos] = kCR then begin
Memo1.lines.add(lOutStr);
lOutStr := '';
end else
lOutStr := lOutStr + lStr[lPos];
end;
if lOutStr <> '' then
Memo1.lines.add(lOutStr);
end;
function GetInt (title: string; min, default,max: integer): integer;
var
s: string;
begin
s := inttostr(default);
InputQuery('Integer required',title,s);
try
result := StrToInt(S);
except
on Exception : EConvertError do
result := default;
end;
end;
procedure Tuiform.DisplayMessages;
begin
Memo1.Lines.Clear;
Memo1.Lines.AddStrings(DebugStrings);
DebugStrings.Clear;
end;
function Tuiform.SelectFiles(lTitle: string; AllowMultiSelect: boolean):boolean;
begin
OpenDialog1.Title := lTItle;
if AllowMultiSelect then
OpenDialog1.Options := [ofAllowMultiSelect,ofFileMustExist]
else
OpenDialog1.Options := [ofFileMustExist];
result := OpenDialog1.Execute;
end;
procedure Tuiform.AddBtnClick(Sender: TObject);
begin
if not SelectFiles('Select images to combine',true) then exit;
if not SaveDialog1.Execute then exit;
AddVols3D(OpenDialog1.Files,SaveDialog1.FileName);
DisplayMessages;
end;
procedure Tuiform.InspectBtnClick(Sender: TObject);
begin
if not SelectFiles('Select image[s] to inspect',true) then exit;
InspectVols(OpenDialog1.Files);
DisplayMessages;
end;
procedure Tuiform.PartBtnClick(Sender: TObject);
var
lPhysioNames: TStringlist;
lImgFilename,lPhysioFilename2,lOutname,lComments,lDICOMname: string;
bins: integer;
begin
if not SelectFiles('Select images for correction',false) then exit;
lImgFilename := OpenDialog1.filename;
if not OpenDialog2.execute then exit;
lPhysioNames := TStringlist.Create;
lPhysioNames.AddStrings(OpenDialog2.files);
if lPhysioNames.count = 1 then begin
if UpCaseExt(lPhysioNames[0]) = '.PULS' then
lPhysioFilename2 := (changefileext(lPhysioNames[0],'.resp'))
else
lPhysioFilename2 := (changefileext(lPhysioNames[0],'.puls'));
if fileexists(lPhysioFilename2) then
lPhysioNames.add(lPhysioFilename2);
end;
bins := 20;//GetInt ('Number of bins?', 5, 20,60);
lOutname := ChangeFilePrefix(lImgFilename,'p');
lComments := ApplyPart( lImgFilename,lOutname,'',lPhysioNames,bins,0,0,false,false);
lPhysioNames.free;
DisplayMessages;
StrToMemo(lComments);
end;
procedure Tuiform.ttestBtnClick(Sender: TObject);
var
lMask: ansistring;
lImgNames: TStringlist;
begin
(*if not SelectFiles('Select mask ',true) then exit;
lMask := OpenDialog1.FileName;
if not SelectFiles('Select images from patients with deficit',true) then exit;
lImgNames := TStringlist.Create;
lImgNames.AddStrings(OpenDialog1.files);
//if not SaveDialog1.Execute then exit;
maskedttest(lMask,'c:\pas\test22.nii.gz',lImgNames);
DisplayMessages;
lImgNames.Free; *)
end;
end.
| 27.92053 | 98 | 0.692837 |
Subsets and Splits