review, source comment, minor fixes, todo update

This commit is contained in:
Basile Burg 2015-02-22 16:21:44 +01:00
parent 06deabd011
commit e1034fa8a4
12 changed files with 104 additions and 97 deletions

View File

@ -957,7 +957,7 @@ end;
destructor TOtherOpts.destroy;
begin
fCustom.Destroy;
fCustom.Free;
inherited;
end;

View File

@ -13,13 +13,15 @@ type
(**
* The option frame to edit the docking option, displayed in the option form.
*)
TEditableAnchorDockOptions = class(TAnchorDockOptionsFrame, ICEEditableOptions)
TDockOptionsEditor = class(TAnchorDockOptionsFrame, ICEEditableOptions)
private
fBackup: TXMLConfigStorage;
//
function optionedWantCategory(): string;
function optionedWantEditorKind: TOptionEditorKind;
function optionedWantContainer: TPersistent;
procedure optionedEvent(anEvent: TOptionEditorEvent);
//
procedure doChanged(Sender: TObject);
public
constructor Create(TheOwner: TComponent); override;
@ -29,12 +31,12 @@ type
implementation
var
DockOptionsEditor: TEditableAnchorDockOptions;
DockOptionsEditor: TDockOptionsEditor;
constructor TEditableAnchorDockOptions.Create(TheOwner: TComponent);
constructor TDockOptionsEditor.Create(TheOwner: TComponent);
begin
inherited;
fBackup := TXMLConfigStorage.Create('',false);
fBackup := TXMLConfigStorage.Create('', false);
Master := AnchorDocking.DockMaster;
//
HeaderAlignLeftTrackBar.OnChange := @doChanged;
@ -54,23 +56,23 @@ begin
EntitiesConnector.addObserver(self);
end;
destructor TEditableAnchorDockOptions.Destroy;
destructor TDockOptionsEditor.Destroy;
begin
fBackup.Free;
inherited;
end;
function TEditableAnchorDockOptions.optionedWantCategory(): string;
function TDockOptionsEditor.optionedWantCategory(): string;
begin
exit('Docking')
end;
function TEditableAnchorDockOptions.optionedWantEditorKind: TOptionEditorKind;
function TDockOptionsEditor.optionedWantEditorKind: TOptionEditorKind;
begin
exit(oekControl);
end;
function TEditableAnchorDockOptions.optionedWantContainer: TPersistent;
function TDockOptionsEditor.optionedWantContainer: TPersistent;
begin
fBackup.Clear;
DockMaster.SaveSettingsToConfig(fBackup);
@ -78,7 +80,7 @@ begin
exit(self);
end;
procedure TEditableAnchorDockOptions.optionedEvent(anEvent: TOptionEditorEvent);
procedure TDockOptionsEditor.optionedEvent(anEvent: TOptionEditorEvent);
begin
// restores
if anEvent = oeeCancel then
@ -97,7 +99,7 @@ begin
end;
end;
procedure TEditableAnchorDockOptions.doChanged(Sender: TObject);
procedure TDockOptionsEditor.doChanged(Sender: TObject);
begin
DragThresholdLabel.Caption:=adrsDragThreshold +
' ('+IntToStr(DragThresholdTrackBar.Position)+')';
@ -113,7 +115,7 @@ begin
end;
initialization
DockOptionsEditor := TEditableAnchorDockOptions.create(nil);
DockOptionsEditor := TDockOptionsEditor.create(nil);
finalization
DockOptionsEditor.free;
end.

View File

@ -11,18 +11,10 @@ uses
type
TDHighligthOptions = class(TPersistent)
end;
TTxtHighligthOptions = class(TPersistent)
end;
(**
* Container for the editor and highlither options.
* The base class is also used to backup the settings
* to allow a live preview and to restore them when not accepted.
* to allow a to preview and restore the settings when rejected.
*
* note: when adding a new property, the default value must be set in
* the constructor according to the default value of the member binded
@ -30,11 +22,15 @@ type
*)
TCEEditorOptionsBase = class(TWritableLfmTextComponent)
private
// note this is how a TComponent can be edited in
// a basic TTIGrid: in the ctor create the component
// but expose it as a published TPersistent.
fD2Syn: TPersistent;
fTxtSyn: TPersistent;
//
fSelCol: TSynSelectedColor;
fFoldCol: TSynSelectedColor;
fLinkCol: TSynSelectedColor;
fFoldedColor: TSynSelectedColor;
fMouseLinkColor: TSynSelectedColor;
fFont: TFont;
//
fTabWidth: Integer;
@ -43,28 +39,28 @@ type
fCharSpacing: Integer;
fRightEdge: Integer;
fBackground: TColor;
fRightEdgeCol: TColor;
fRightEdgeColor: TColor;
fOptions1: TSynEditorOptions;
fOptions2: TSynEditorOptions2;
fMouseOptions: TSynEditorMouseOptions;
//
procedure setFont(aValue: TFont);
procedure setSelCol(aValue: TSynSelectedColor);
procedure setFoldCol(aValue: TSynSelectedColor);
procedure setLinkCol(aValue: TSynSelectedColor);
procedure setFoldedColor(aValue: TSynSelectedColor);
procedure setMouseLinkColor(aValue: TSynSelectedColor);
procedure setD2Syn(aValue: TPersistent);
procedure setTxtSyn(aValue: TPersistent);
published
property mouseLinkColor: TSynSelectedColor read fLinkCol write setLinkCol;
property mouseLinkColor: TSynSelectedColor read fMouseLinkColor write setMouseLinkColor;
property selectedColor: TSynSelectedColor read fSelCol write setSelCol;
property foldedColor: TSynSelectedColor read fFoldCol write setFoldCol;
property foldedColor: TSynSelectedColor read fFoldedColor write setFoldedColor;
property background: TColor read fBackground write fBackground default clWhite;
property tabulationWidth: Integer read fTabWidth write fTabWidth default 4;
property blockIdentation: Integer read fBlockIdent write fBlockIdent default 4;
property lineSpacing: Integer read fLineSpacing write fLineSpacing default 0;
property characterSpacing: Integer read fCharSpacing write fCharSpacing default 0;
property rightEdge: Integer read fRightEdge write fRightEdge default 80;
property rightEdgeColor: TColor read fRightEdgeCol write fRightEdgeCol default clSilver;
property rightEdgeColor: TColor read fRightEdgeColor write fRightEdgeColor default clSilver;
property font: TFont read fFont write setFont;
property options1: TSynEditorOptions read fOptions1 write fOptions1;
property options2: TSynEditorOptions2 read fOptions2 write fOptions2;
@ -80,6 +76,7 @@ type
(**
* Manages and exposes all the editor and highligther options to an TCEOptionsEditor.
* It's also responsible to give the current options to a new editor.
*)
TCEEditorOptions = class(TCEEditorOptionsBase, ICEEditableOptions, ICEMultiDocObserver)
private
@ -129,24 +126,24 @@ begin
fTxtSyn.Assign(TxtSyn);
//
fSelCol := TSynSelectedColor.Create;
fFoldCol := TSynSelectedColor.Create;
fLinkCol := TSynSelectedColor.Create;
fFoldedColor := TSynSelectedColor.Create;
fMouseLinkColor := TSynSelectedColor.Create;
//
// note: default values come from TSynEditFoldedView ctor.
fFoldCol.Background := clNone;
fFoldCol.Foreground := clDkGray;
fFoldCol.FrameColor := clDkGray;
fFoldedColor.Background := clNone;
fFoldedColor.Foreground := clDkGray;
fFoldedColor.FrameColor := clDkGray;
//
fLinkCol.Style := [fsUnderline, fsBold];
fLinkCol.StyleMask := [];
fLinkCol.Foreground := clNone;
fLinkCol.Background := clNone;
fMouseLinkColor.Style := [fsUnderline, fsBold];
fMouseLinkColor.StyleMask := [];
fMouseLinkColor.Foreground := clNone;
fMouseLinkColor.Background := clNone;
//
rightEdge := 80;
tabulationWidth := 4;
blockIdentation := 4;
fBackground := clWhite;
fRightEdgeCol := clSilver;
fRightEdgeColor := clSilver;
//
options1 :=
[eoAutoIndent, eoBracketHighlight, eoGroupUndo, eoTabsToSpaces,
@ -162,8 +159,8 @@ destructor TCEEditorOptionsBase.Destroy;
begin
fFont.Free;
fSelCol.Free;
fFoldCol.Free;
fLinkCol.Free;
fFoldedColor.Free;
fMouseLinkColor.Free;
inherited;
end;
@ -177,8 +174,8 @@ begin
//
fFont.Assign(srcopt.fFont);
fSelCol.Assign(srcopt.fSelCol);
fFoldCol.Assign(srcopt.fFoldCol);
fLinkCol.Assign(srcopt.fLinkCol);
fFoldedColor.Assign(srcopt.fFoldedColor);
fMouseLinkColor.Assign(srcopt.fMouseLinkColor);
fD2Syn.Assign(srcopt.fD2Syn);
fTxtSyn.Assign(srcopt.fTxtSyn);
background := srcopt.background;
@ -205,14 +202,14 @@ begin
fSelCol.Assign(aValue);
end;
procedure TCEEditorOptionsBase.setFoldCol(aValue: TSynSelectedColor);
procedure TCEEditorOptionsBase.setFoldedColor(aValue: TSynSelectedColor);
begin
fFoldCol.Assign(aValue);
fFoldedColor.Assign(aValue);
end;
procedure TCEEditorOptionsBase.setLinkCol(aValue: TSynSelectedColor);
procedure TCEEditorOptionsBase.setMouseLinkColor(aValue: TSynSelectedColor);
begin
fLinkCol.Assign(aValue);
fMouseLinkColor.Assign(aValue);
end;
procedure TCEEditorOptionsBase.setD2Syn(aValue: TPersistent);
@ -324,7 +321,6 @@ begin
multied := getMultiDocHandler;
for i := 0 to multied.documentCount-1 do
applyChangeToEditor(multied.document[i]);
end;
procedure TCEEditorOptions.applyChangeToEditor(anEditor: TCESynMemo);
@ -332,8 +328,8 @@ begin
anEditor.defaultFontSize := font.Size;
anEditor.Font.Assign(font);
anEditor.SelectedColor.Assign(fSelCol);
anEditor.FoldedCodeColor.Assign(fFoldCol);
anEditor.MouseLinkColor.Assign(fLinkCol);
anEditor.FoldedCodeColor.Assign(fFoldedColor);
anEditor.MouseLinkColor.Assign(fMouseLinkColor);
anEditor.TabWidth := tabulationWidth;
anEditor.BlockIndent := blockIdentation;
anEditor.ExtraLineSpacing := lineSpacing;

View File

@ -14,6 +14,9 @@ type
TCustomPathType = (ptFile, ptFolder);
// base class for a property representing a path
// additionaly to the text field, a dialog can be opened
// to select the directory or the file.
TCECustomPathEditor = class(TStringPropertyEditor)
private
fType: TCustomPathType;
@ -30,7 +33,6 @@ type
constructor Create(Hook: TPropertyEditorHook; APropCount: Integer); override;
end;
implementation
function TCECustomPathEditor.GetAttributes: TPropertyAttributes;

View File

@ -88,7 +88,7 @@ type
procedure updateObservers; virtual;
//
property observersCount: Integer read getObserversCount;
property observers[index: Integer]: TObject read getObserver;
property observers[index: Integer]: TObject read getObserver; default;
end;
var

View File

@ -11,6 +11,8 @@ uses
type
// store the information about the obsever
// exposing some editable options.
PCategoryData = ^TCategoryData;
TCategoryData = record
kind: TOptionEditorKind;
@ -110,9 +112,12 @@ procedure TCEOptionEditorWidget.selCatSelectionChanged(Sender: TObject);
var
dt: PCategoryData;
begin
// remove either the control, the form or the inspector
// being used as editor.
inspector.TIObject := nil;
if pnlEd.ControlCount > 0 then
pnlEd.Controls[0].Parent := nil;
//
if selCat.Selected = nil then exit;
if selCat.Selected.Data = nil then exit;
//
@ -173,7 +178,6 @@ begin
.observer
.optionedEvent(oeeAccept);
end;
{$ENDREGION}
end.

View File

@ -71,7 +71,7 @@ object CEShortcutEditor: TCEShortcutEditor
BorderStyle = sbsSunken
TabOrder = 0
end
object shcCatch: TEdit
object shortcutCatcher: TEdit
Left = 310
Height = 22
Top = 2
@ -81,9 +81,9 @@ object CEShortcutEditor: TCEShortcutEditor
BorderSpacing.Bottom = 1
BorderSpacing.Around = 1
Enabled = False
OnExit = shcCatchExit
OnExit = shortcutCatcherExit
OnKeyDown = LabeledEdit1KeyDown
OnMouseLeave = shcCatchMouseLeave
OnMouseLeave = shortcutCatcherMouseLeave
TabOrder = 1
end
object btnActivate: TSpeedButton

View File

@ -24,12 +24,12 @@ type
TShortCutCollection = class(TWritableLfmTextComponent)
private
fCollection: TCollection;
procedure setCollection(aValue: TCollection);
fItems: TCollection;
procedure setItems(aValue: TCollection);
function getCount: Integer;
function getShortcut(index: Integer): TShortcutItem;
function getItem(index: Integer): TShortcutItem;
published
property items: TCollection read fCollection write setCollection;
property items: TCollection read fItems write setItems;
public
constructor create(AOwner: TComponent); override;
destructor destroy; override;
@ -38,11 +38,11 @@ type
function findShortcut(aShortcut: Word): boolean;
//
property count: Integer read getCount;
property item[index: Integer]: TShortcutItem read getShortcut; default;
property item[index: Integer]: TShortcutItem read getItem; default;
end;
TCEShortcutEditor = class(TFrame, ICEEditableOptions)
shcCatch: TEdit;
shortcutCatcher: TEdit;
Panel1: TPanel;
fltItems: TTreeFilterEdit;
Panel2: TPanel;
@ -51,8 +51,8 @@ type
tree: TTreeView;
procedure btnActivateClick(Sender: TObject);
procedure LabeledEdit1KeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
procedure shcCatchExit(Sender: TObject);
procedure shcCatchMouseLeave(Sender: TObject);
procedure shortcutCatcherExit(Sender: TObject);
procedure shortcutCatcherMouseLeave(Sender: TObject);
procedure treeSelectionChanged(Sender: TObject);
private
fObservers: TCEEditableShortCutSubject;
@ -89,28 +89,28 @@ end;
constructor TShortCutCollection.create(AOwner: TComponent);
begin
inherited;
fCollection := TCollection.Create(TShortcutItem);
fItems := TCollection.Create(TShortcutItem);
end;
destructor TShortCutCollection.destroy;
begin
fCollection.Free;
fItems.Free;
inherited;
end;
procedure TShortCutCollection.setCollection(aValue: TCollection);
procedure TShortCutCollection.setItems(aValue: TCollection);
begin
fCollection.Assign(aValue);
fItems.Assign(aValue);
end;
function TShortCutCollection.getCount: Integer;
begin
exit(fCollection.Count);
exit(fItems.Count);
end;
function TShortCutCollection.getShortcut(index: Integer): TShortcutItem;
function TShortCutCollection.getItem(index: Integer): TShortcutItem;
begin
exit(TShortcutItem(fCollection.Items[index]));
exit(TShortcutItem(fItems.Items[index]));
end;
function TShortCutCollection.findIdentifier(const identifier: string): boolean;
@ -187,6 +187,7 @@ end;
procedure TCEShortcutEditor.optionedEvent(anEvent: TOptionEditorEvent);
begin
// TODO-cfeature: pass new shortcut to observer
end;
{$ENDREGION}
@ -196,15 +197,15 @@ begin
updateEditCtrls;
end;
procedure TCEShortcutEditor.shcCatchExit(Sender: TObject);
procedure TCEShortcutEditor.shortcutCatcherExit(Sender: TObject);
begin
shcCatch.Enabled := false;
shortcutCatcher.Enabled := false;
updateEditCtrls;
end;
procedure TCEShortcutEditor.shcCatchMouseLeave(Sender: TObject);
procedure TCEShortcutEditor.shortcutCatcherMouseLeave(Sender: TObject);
begin
shcCatch.Enabled := false;
shortcutCatcher.Enabled := false;
updateEditCtrls;
end;
@ -214,17 +215,16 @@ begin
if tree.Selected.Level = 0 then exit;
if tree.Selected.Data = nil then exit;
//
shcCatch.Enabled := not shcCatch.Enabled;
shortcutCatcher.Enabled := not shortcutCatcher.Enabled;
end;
procedure TCEShortcutEditor.LabeledEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure TCEShortcutEditor.LabeledEdit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if tree.Selected = nil then exit;
if tree.Selected.Level = 0 then exit;
if tree.Selected.Data = nil then exit;
//
if Key = VK_RETURN then shcCatch.Enabled := false
if Key = VK_RETURN then shortcutCatcher.Enabled := false
else TShortcutItem(tree.Selected.Data).data := Shortcut(Key, Shift);
//
updateEditCtrls;
@ -239,7 +239,7 @@ begin
if tree.Selected.Data = nil then exit;
//
schrtText.Caption := TShortcutItem(tree.Selected.Data).combination;
shcCatch.Text:= '';
shortcutCatcher.Text := '';
end;
function TCEShortcutEditor.findCategory(const aName: string; aData: Pointer): TTreeNode;

View File

@ -14,6 +14,7 @@ type
TCESynMemo = class;
// SImple THintWindow descendant allowing the font size to be in sync with the editor.
TCEEditorHintWindow = class(THintWindow)
public
class var FontSize: Integer;
@ -22,6 +23,7 @@ type
AData: Pointer): TRect; override;
end;
// Stores the state of a particulat source code folding.
TCEFoldCache = class(TCollectionItem)
private
fCollapsed: boolean;
@ -33,6 +35,7 @@ type
property nestedIndex: Integer read fNestedIndex write fNestedIndex;
end;
// Stores the state of a document between two cessions.
TCESynMemoCache = class(TWritableLfmTextComponent)
private
fMemo: TCESynMemo;
@ -58,6 +61,7 @@ type
procedure load;
end;
// buffer of caret positions allowing to jump quickly to the most recent locations.
TCESynMemoPositions = class
private
fPos: Integer;
@ -159,6 +163,7 @@ end;
destructor TCESynMemoCache.destroy;
begin
fFolds.Free;
inherited;
end;
procedure TCESynMemoCache.setFolds(someFolds: TCollection);

View File

@ -49,7 +49,7 @@ type
public
constructor create(AOwner: TComponent); override;
destructor destroy; override;
// str will be set on the tool process output.
// str is the output stream of the tool process.
procedure loadFromTxtStream(str: TMemoryStream);
property count: integer read getCount;
property item[index: integer]: TTodoItem read getItem; default;
@ -177,8 +177,6 @@ begin
lstItems.OnCompare := @lstItemsCompare;
fAutoRefresh := true;
mnuAutoRefresh.Checked := true;
// TODO-cLCL&LAZ-specific, try the new TListViewFilterEdit here.
// TODO-cLCL&LAZ-specific, the align/anchors of filterxxx must be redefined, previously there was a bug.
lstfilter.OnChange:= @filterItems;
//
png := TPortableNetworkGraphic.Create;
@ -430,7 +428,7 @@ begin
//
if src.category <> '' then lstItems.Column[1].Visible := true;
if src.assignee <> '' then lstItems.Column[2].Visible := true;
if src.status <> '' then lstItems.Column[3].Visible := true;
if src.status <> '' then lstItems.Column[3].Visible := true;
if src.priority <> '' then lstItems.Column[4].Visible := true;
end;
end;
@ -514,7 +512,7 @@ procedure TCETodoListWidget.filterItems(sender: TObject);
begin
fillTodoList
end;
{$ENDREGION}
end.

View File

@ -10,6 +10,8 @@ uses
type
//TODO-cfeature: declare tools shortcuts, set TCETools ICEEditableShortcut
TCEToolItem = class(TCollectionItem)
private
fProcess: TCheckedAsyncProcess;
@ -22,7 +24,7 @@ type
fQueryParams: boolean;
fChainBefore: TStringList;
fChainAfter: TStringList;
//fShortcut: string;
//fShortcut: TShortcut;
fMsgs: ICEMessagesDisplay;
procedure setParameters(aValue: TStringList);
procedure setChainBefore(aValue: TStringList);
@ -39,7 +41,7 @@ type
property queryParameters: boolean read fQueryParams write fQueryParams;
property chainBefore: TStringList read fChainBefore write setchainBefore;
property chainAfter: TStringList read fChainAfter write setChainAfter;
//property shortcut: string read fShortcut write fShortcut;
//property shortcut: TShortcut read fShortcut write fShortcut;
public
constructor create(ACollection: TCollection); override;
destructor destroy; override;
@ -66,10 +68,9 @@ type
property tool[index: integer]: TCEToolItem read getTool; default;
end;
const
toolsFname = 'tools.txt';
//TODO-crefactor: either set the tools as a service of merge the tools collection& tool editor in a single unit.
Var
var
CustomTools: TCETools;
implementation
@ -77,6 +78,9 @@ implementation
uses
ce_symstring, dialogs;
const
toolsFname = 'tools.txt';
constructor TCEToolItem.create(ACollection: TCollection);
begin
inherited;
@ -185,7 +189,6 @@ end;
procedure TCETools.executeToolFromMenu(sender: TObject);
begin
//TCEToolItem(TMenuItem(sender).tag).execute;
executeTool(TCEToolItem(TMenuItem(sender).tag));
end;
@ -213,11 +216,8 @@ var
begin
if item = nil then exit;
if item.Count <> tools.Count then
begin
menuDeclare(item);
exit;
end;
for i:= 0 to tools.Count-1 do
menuDeclare(item)
else for i:= 0 to tools.Count-1 do
begin
if ptrInt(tool[i]) <> item.Items[i].Tag then
item.Items[i].Tag := ptrInt(tool[i]);

View File

@ -109,7 +109,7 @@ uses
{$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEWidget.create(aOwner: TComponent);
var
i: NativeInt;
i: Integer;
itm: TmenuItem;
begin
inherited;