Fixed: Issue #123
Fixed: Issue #124 Fixed: Issue #128 Fixed: Issue #133 Fixed: Issue #136
This commit is contained in:
parent
d0fe05e179
commit
61a4f9c651
@ -120,7 +120,7 @@
|
|||||||
</Linker>
|
</Linker>
|
||||||
<Directories>
|
<Directories>
|
||||||
<Directories Name="OutputDir"></Directories>
|
<Directories Name="OutputDir"></Directories>
|
||||||
<Directories Name="UnitOutputDir"></Directories>
|
<Directories Name="UnitOutputDir">..\..\Lib\D2006</Directories>
|
||||||
<Directories Name="PackageDLLOutputDir">..\..\Lib\D2006</Directories>
|
<Directories Name="PackageDLLOutputDir">..\..\Lib\D2006</Directories>
|
||||||
<Directories Name="PackageDCPOutputDir"></Directories>
|
<Directories Name="PackageDCPOutputDir"></Directories>
|
||||||
<Directories Name="SearchPath"></Directories>
|
<Directories Name="SearchPath"></Directories>
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
-M
|
-M
|
||||||
-$M16384,1048576
|
-$M16384,1048576
|
||||||
-K$00400000
|
-K$00400000
|
||||||
|
-N0"..\..\Lib\D2006"
|
||||||
-LE"..\..\Lib\D2006"
|
-LE"..\..\Lib\D2006"
|
||||||
-LN"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl"
|
-LN"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl"
|
||||||
-Z
|
-Z
|
||||||
|
@ -35,6 +35,8 @@ contains
|
|||||||
UnSwClient in '..\..\Source\UnSwClient.pas',
|
UnSwClient in '..\..\Source\UnSwClient.pas',
|
||||||
UnSwObjects in '..\..\Source\UnSwObjects.pas',
|
UnSwObjects in '..\..\Source\UnSwObjects.pas',
|
||||||
UnSwDialog in '..\..\Source\UnSwDialog.pas' {frmUnSwDialog},
|
UnSwDialog in '..\..\Source\UnSwDialog.pas' {frmUnSwDialog},
|
||||||
UnSwFilters in '..\..\Source\UnSwFilters.pas';
|
UnSwFilters in '..\..\Source\UnSwFilters.pas',
|
||||||
|
UnSwConfiguration in '..\..\Source\UnSwConfiguration.pas' {frmUnSwConfiguration},
|
||||||
|
UnSwSettings in '..\..\Source\UnSwSettings.pas';
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -31,8 +31,9 @@
|
|||||||
-M
|
-M
|
||||||
-$M16384,1048576
|
-$M16384,1048576
|
||||||
-K$00400000
|
-K$00400000
|
||||||
|
-N0"..\..\Lib\D7"
|
||||||
-LE"..\..\Lib\D7"
|
-LE"..\..\Lib\D7"
|
||||||
-LN"c:\program files\borland\delphi7\Projects\Bpl"
|
-LN"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl"
|
||||||
-Z
|
-Z
|
||||||
-w-UNSAFE_TYPE
|
-w-UNSAFE_TYPE
|
||||||
-w-UNSAFE_CODE
|
-w-UNSAFE_CODE
|
||||||
|
BIN
Resources/About.ico
Normal file
BIN
Resources/About.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 766 B |
@ -1,3 +1,9 @@
|
|||||||
|
{: Connects UnitSwitcher to the IDE.
|
||||||
|
|
||||||
|
Last changed: $Date$
|
||||||
|
Revision: $Rev$
|
||||||
|
Author: $Author$
|
||||||
|
}
|
||||||
{$ASSERTIONS ON}
|
{$ASSERTIONS ON}
|
||||||
unit UnSwClient;
|
unit UnSwClient;
|
||||||
|
|
||||||
@ -39,14 +45,14 @@ type
|
|||||||
{ TUnitSwitcherHook}
|
{ TUnitSwitcherHook}
|
||||||
constructor TUnitSwitcherHook.Create();
|
constructor TUnitSwitcherHook.Create();
|
||||||
var
|
var
|
||||||
iAction: Integer;
|
actionIndex: Integer;
|
||||||
ifNTA: INTAServices;
|
ntaServices: INTAServices;
|
||||||
pAction: TContainedAction;
|
action: TContainedAction;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
Assert(Assigned(BorlandIDEServices), 'BorlandIDEServices not available.');
|
Assert(Assigned(BorlandIDEServices), 'BorlandIDEServices not available.');
|
||||||
Assert(Supports(BorlandIDEServices, INTAServices, ifNTA),
|
Assert(Supports(BorlandIDEServices, INTAServices, ntaServices),
|
||||||
'BorlandIDEServices does not support the ' +
|
'BorlandIDEServices does not support the ' +
|
||||||
'INTAServices interface.');
|
'INTAServices interface.');
|
||||||
Assert(Supports(BorlandIDEServices, IOTAModuleServices),
|
Assert(Supports(BorlandIDEServices, IOTAModuleServices),
|
||||||
@ -58,19 +64,19 @@ begin
|
|||||||
'IOTAActionServices interface.');
|
'IOTAActionServices interface.');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
for iAction := 0 to Pred(ifNTA.ActionList.ActionCount) do
|
for actionIndex := 0 to Pred(ntaServices.ActionList.ActionCount) do
|
||||||
begin
|
begin
|
||||||
pAction := ifNTA.ActionList.Actions[iAction];
|
action := ntaServices.ActionList.Actions[actionIndex];
|
||||||
if pAction.Name = 'ViewUnitCommand' then
|
if action.Name = 'ViewUnitCommand' then
|
||||||
begin
|
begin
|
||||||
FOldUnitExecute := pAction.OnExecute;
|
FOldUnitExecute := action.OnExecute;
|
||||||
pAction.OnExecute := NewExecute;
|
action.OnExecute := NewExecute;
|
||||||
FViewUnitAction := pAction;
|
FViewUnitAction := action;
|
||||||
end else if pAction.Name = 'ViewFormCommand' then
|
end else if action.Name = 'ViewFormCommand' then
|
||||||
begin
|
begin
|
||||||
FOldFormExecute := pAction.OnExecute;
|
FOldFormExecute := action.OnExecute;
|
||||||
pAction.OnExecute := NewExecute;
|
action.OnExecute := NewExecute;
|
||||||
FViewFormAction := pAction;
|
FViewFormAction := action;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -98,32 +104,32 @@ end;
|
|||||||
|
|
||||||
function TUnitSwitcherHook.ActiveFileName(): String;
|
function TUnitSwitcherHook.ActiveFileName(): String;
|
||||||
var
|
var
|
||||||
ifModule: IOTAModule;
|
module: IOTAModule;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
ifModule := (BorlandIDEServices as IOTAModuleServices).CurrentModule;
|
module := (BorlandIDEServices as IOTAModuleServices).CurrentModule;
|
||||||
if Assigned(ifModule) then
|
if Assigned(module) then
|
||||||
begin
|
begin
|
||||||
if Assigned(ifModule.CurrentEditor) then
|
if Assigned(module.CurrentEditor) then
|
||||||
Result := ifModule.FileName;
|
Result := module.FileName;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF DELPHI7}
|
{$IFDEF DELPHI7}
|
||||||
function TUnitSwitcherHook.ActiveGroup(): IOTAProjectGroup;
|
function TUnitSwitcherHook.ActiveGroup(): IOTAProjectGroup;
|
||||||
var
|
var
|
||||||
ifModule: IOTAModule;
|
module: IOTAModule;
|
||||||
ifModules: IOTAModuleServices;
|
moduleServices: IOTAModuleServices;
|
||||||
iModule: Integer;
|
moduleIndex: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
ifModules := (BorlandIDEServices as IOTAModuleServices);
|
moduleServices := (BorlandIDEServices as IOTAModuleServices);
|
||||||
for iModule := 0 to Pred(ifModules.ModuleCount) do
|
for moduleIndex := 0 to Pred(moduleServices.ModuleCount) do
|
||||||
begin
|
begin
|
||||||
ifModule := ifModules.Modules[iModule];
|
module := moduleServices.Modules[moduleIndex];
|
||||||
if Supports(ifModule, IOTAProjectGroup, Result) then
|
if Supports(module, IOTAProjectGroup, Result) then
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -132,64 +138,64 @@ end;
|
|||||||
function TUnitSwitcherHook.ActiveProject(): IOTAProject;
|
function TUnitSwitcherHook.ActiveProject(): IOTAProject;
|
||||||
{$IFDEF DELPHI7}
|
{$IFDEF DELPHI7}
|
||||||
var
|
var
|
||||||
ifGroup: IOTAProjectGroup;
|
projectGroup: IOTAProjectGroup;
|
||||||
ifModule: IOTAModule;
|
module: IOTAModule;
|
||||||
ifModules: IOTAModuleServices;
|
moduleServices: IOTAModuleServices;
|
||||||
iModule: Integer;
|
moduleIndex: Integer;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF DELPHI7}
|
{$IFDEF DELPHI7}
|
||||||
Result := nil;
|
Result := nil;
|
||||||
ifGroup := ActiveGroup();
|
projectGroup := ActiveGroup();
|
||||||
if not Assigned(ifGroup) then
|
if not Assigned(projectGroup) then
|
||||||
begin
|
begin
|
||||||
ifModules := (BorlandIDEServices as IOTAModuleServices);
|
moduleServices := (BorlandIDEServices as IOTAModuleServices);
|
||||||
for iModule := 0 to Pred(ifModules.ModuleCount) do
|
for moduleIndex := 0 to Pred(moduleServices.ModuleCount) do
|
||||||
begin
|
begin
|
||||||
ifModule := ifModules.Modules[iModule];
|
module := moduleServices.Modules[moduleIndex];
|
||||||
if Supports(ifModule, IOTAProject, Result) then
|
if Supports(module, IOTAProject, Result) then
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
Result := ifGroup.ActiveProject;
|
Result := projectGroup.ActiveProject;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Result := (BorlandIDEServices as IOTAModuleServices).GetActiveProject
|
Result := (BorlandIDEServices as IOTAModuleServices).GetActiveProject();
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TUnitSwitcherHook.NewExecute(Sender: TObject);
|
procedure TUnitSwitcherHook.NewExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
iActive: Integer;
|
activeIndex: Integer;
|
||||||
ifProject: IOTAProject;
|
project: IOTAProject;
|
||||||
iModule: Integer;
|
moduleIndex: Integer;
|
||||||
pActive: TUnSwUnit;
|
activeUnit: TUnSwUnit;
|
||||||
pUnits: TUnSwUnitList;
|
unitList: TUnSwUnitList;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ifProject := ActiveProject();
|
project := ActiveProject();
|
||||||
if not Assigned(ifProject) then
|
if not Assigned(project) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
pUnits := TUnSwUnitList.Create();
|
unitList := TUnSwUnitList.Create();
|
||||||
try
|
try
|
||||||
pUnits.Add(TUnSwProjectUnit.Create(ifProject));
|
unitList.Add(TUnSwProjectUnit.Create(project));
|
||||||
|
|
||||||
for iModule := 0 to Pred(ifProject.GetModuleCount) do
|
for moduleIndex := 0 to Pred(project.GetModuleCount) do
|
||||||
pUnits.Add(TUnSwModuleUnit.Create(ifProject.GetModule(iModule)));
|
unitList.Add(TUnSwModuleUnit.Create(project.GetModule(moduleIndex)));
|
||||||
|
|
||||||
pActive := nil;
|
activeUnit := nil;
|
||||||
iActive := pUnits.IndexOfFileName(ActiveFileName());
|
activeIndex := unitList.IndexOfFileName(ActiveFileName());
|
||||||
if iActive > -1 then
|
if activeIndex > -1 then
|
||||||
pActive := pUnits[iActive];
|
activeUnit := unitList[activeIndex];
|
||||||
|
|
||||||
pActive := TfrmUnSwDialog.Execute(pUnits, (Sender = FViewFormAction),
|
activeUnit := TfrmUnSwDialog.Execute(unitList, (Sender = FViewFormAction),
|
||||||
pActive);
|
activeUnit);
|
||||||
if Assigned(pActive) then
|
if Assigned(activeUnit) then
|
||||||
pActive.Activate((Sender = FViewUnitAction));
|
activeUnit.Activate((Sender = FViewUnitAction));
|
||||||
finally
|
finally
|
||||||
FreeAndNil(pUnits);
|
FreeAndNil(unitList);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
327
Source/UnSwConfiguration.dfm
Normal file
327
Source/UnSwConfiguration.dfm
Normal file
@ -0,0 +1,327 @@
|
|||||||
|
object frmUnSwConfiguration: TfrmUnSwConfiguration
|
||||||
|
Left = 279
|
||||||
|
Top = 170
|
||||||
|
BorderIcons = [biSystemMenu]
|
||||||
|
BorderStyle = bsDialog
|
||||||
|
Caption = 'UnitSwitcher Configuration'
|
||||||
|
ClientHeight = 250
|
||||||
|
ClientWidth = 303
|
||||||
|
Color = clBtnFace
|
||||||
|
Font.Charset = DEFAULT_CHARSET
|
||||||
|
Font.Color = clWindowText
|
||||||
|
Font.Height = -11
|
||||||
|
Font.Name = 'Tahoma'
|
||||||
|
Font.Style = []
|
||||||
|
OldCreateOrder = False
|
||||||
|
Position = poScreenCenter
|
||||||
|
DesignSize = (
|
||||||
|
303
|
||||||
|
250)
|
||||||
|
PixelsPerInch = 96
|
||||||
|
TextHeight = 13
|
||||||
|
object pcConfiguration: TPageControl
|
||||||
|
Left = 4
|
||||||
|
Top = 4
|
||||||
|
Width = 295
|
||||||
|
Height = 209
|
||||||
|
ActivePage = tsGeneral
|
||||||
|
Anchors = [akLeft, akTop, akRight, akBottom]
|
||||||
|
TabOrder = 0
|
||||||
|
ExplicitHeight = 299
|
||||||
|
object tsGeneral: TTabSheet
|
||||||
|
Caption = 'General'
|
||||||
|
object chkCustomColor: TCheckBox
|
||||||
|
Left = 8
|
||||||
|
Top = 8
|
||||||
|
Width = 249
|
||||||
|
Height = 17
|
||||||
|
Caption = 'Use custom text &colors to indicate the unit type:'
|
||||||
|
Checked = True
|
||||||
|
State = cbChecked
|
||||||
|
TabOrder = 0
|
||||||
|
OnClick = chkCustomColorClick
|
||||||
|
end
|
||||||
|
object pnlCustomColor: TPanel
|
||||||
|
Left = 8
|
||||||
|
Top = 31
|
||||||
|
Width = 273
|
||||||
|
Height = 98
|
||||||
|
BevelOuter = bvNone
|
||||||
|
BorderStyle = bsSingle
|
||||||
|
Color = clWindow
|
||||||
|
TabOrder = 1
|
||||||
|
object TImage
|
||||||
|
Left = 8
|
||||||
|
Top = 8
|
||||||
|
Width = 16
|
||||||
|
Height = 16
|
||||||
|
Picture.Data = {
|
||||||
|
055449636F6E0000010001001010100001000400280100001600000028000000
|
||||||
|
1000000020000000010004000000000080000000000000000000000000000000
|
||||||
|
0000000000000000000080000080000000808000800000008000800080800000
|
||||||
|
80808000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000
|
||||||
|
FFFFFF0000000000000000000000F777777777700000FF8F8F8F8F700000F8F8
|
||||||
|
F8F8F8700000FF0000000F700000F8F8F8F8F8700000F999999999700400F9FF
|
||||||
|
FFFFF9700000F999999999700000F8F8F8F8F8700000FF0000008F700000F8F8
|
||||||
|
F8F8F7700000FF00008F00000000F8F8F8F80F000000FFFFFFFF000000000000
|
||||||
|
00000000E0000000E0000000E0000000E0000000E00000006000000020000000
|
||||||
|
000000002000000060000000E0000000E0000000E0000000E0010000E0030000
|
||||||
|
E0070000}
|
||||||
|
end
|
||||||
|
object TImage
|
||||||
|
Left = 8
|
||||||
|
Top = 68
|
||||||
|
Width = 16
|
||||||
|
Height = 16
|
||||||
|
Picture.Data = {
|
||||||
|
055449636F6E0000010001001010100001000400280100001600000028000000
|
||||||
|
1000000020000000010004000000000080000000000000000000000000000000
|
||||||
|
0000000000000000000080000080000000808000800000008000800080800000
|
||||||
|
80808000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000
|
||||||
|
FFFFFF0000000000000000000F777777777770000FF8F8F8F8F870000F8F8F80
|
||||||
|
000000000FF8F8F0F77777700F8F8F80FF8F8F700FF8F8F0F8F8F8700F8F8F80
|
||||||
|
FFFFFFF00FF8F8F0000000000F8F8F80CCCCC0800FF8F8F0000000000F8F8F8F
|
||||||
|
8F8F70000FFFFFFFFFFFF00000000000000000000CCCCCC08080800000000000
|
||||||
|
0000000000030000000300000003000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000030000000300000003000000030000
|
||||||
|
00030000}
|
||||||
|
end
|
||||||
|
object TImage
|
||||||
|
Left = 8
|
||||||
|
Top = 48
|
||||||
|
Width = 16
|
||||||
|
Height = 16
|
||||||
|
Picture.Data = {
|
||||||
|
055449636F6E0000010001001010100001000400280100001600000028000000
|
||||||
|
1000000020000000010004000000000080000000000000000000000000000000
|
||||||
|
0000000000000000000080000080000000808000800000008000800080800000
|
||||||
|
80808000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000
|
||||||
|
FFFFFF0000040070000000000444407888800000040400777077000004000000
|
||||||
|
700000000000000000000000700000000000000077000F777777777000000F8F
|
||||||
|
8F8F8F7000000FF89998F87000000F8F998F8F7000000FF89899F87000000F8F
|
||||||
|
8F8F8F7000000FFFFFFFFFF0000000000000000000000CCCC080808000000000
|
||||||
|
00000000EC0F0000840F0000AC0F0000BF3F0000FFFF00001000000010000000
|
||||||
|
B0000000F0000000F0000000F0000000F0000000F0000000F0000000F0000000
|
||||||
|
F0000000}
|
||||||
|
end
|
||||||
|
object TImage
|
||||||
|
Left = 8
|
||||||
|
Top = 28
|
||||||
|
Width = 16
|
||||||
|
Height = 16
|
||||||
|
Picture.Data = {
|
||||||
|
055449636F6E0000010001001010100001000400280100001600000028000000
|
||||||
|
1000000020000000010004000000000080000000000000000000000000000000
|
||||||
|
0000000000000000000080000080000000808000800000008000800080800000
|
||||||
|
80808000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000
|
||||||
|
FFFFFF000000000000000000000000000000000000000000000000000F777777
|
||||||
|
777777700FF8F8F8F8F8F8700F8F8F8F8F8F8F700FF8F8F8F8F8F8700F8F8F8F
|
||||||
|
8F8F8F700FF8F8F8F8F8F8700F8F8F8F8F8F8F700FFFFFFFFFFFFFF000000000
|
||||||
|
000000000CCCCCCCC08080800000000000000000000000000000000000000000
|
||||||
|
00000000FFFF0000FFFF00000000000000000000000000000000000000000000
|
||||||
|
00000000000000000000000000000000000000000000000000000000FFFF0000
|
||||||
|
FFFF0000}
|
||||||
|
end
|
||||||
|
object lblUnitColor: TLabel
|
||||||
|
Tag = 1
|
||||||
|
Left = 32
|
||||||
|
Top = 10
|
||||||
|
Width = 19
|
||||||
|
Height = 13
|
||||||
|
Cursor = crHandPoint
|
||||||
|
Caption = 'Unit'
|
||||||
|
OnClick = PickColor
|
||||||
|
end
|
||||||
|
object lblFormColor: TLabel
|
||||||
|
Tag = 2
|
||||||
|
Left = 32
|
||||||
|
Top = 30
|
||||||
|
Width = 24
|
||||||
|
Height = 13
|
||||||
|
Cursor = crHandPoint
|
||||||
|
Caption = 'Form'
|
||||||
|
OnClick = PickColor
|
||||||
|
end
|
||||||
|
object lblDataModuleColor: TLabel
|
||||||
|
Tag = 3
|
||||||
|
Left = 32
|
||||||
|
Top = 50
|
||||||
|
Width = 60
|
||||||
|
Height = 13
|
||||||
|
Cursor = crHandPoint
|
||||||
|
Caption = 'Data Module'
|
||||||
|
OnClick = PickColor
|
||||||
|
end
|
||||||
|
object lblProjectColor: TLabel
|
||||||
|
Tag = 4
|
||||||
|
Left = 32
|
||||||
|
Top = 70
|
||||||
|
Width = 70
|
||||||
|
Height = 13
|
||||||
|
Cursor = crHandPoint
|
||||||
|
Caption = 'Project Source'
|
||||||
|
OnClick = PickColor
|
||||||
|
end
|
||||||
|
object btnUnitColor: TButton
|
||||||
|
Tag = 1
|
||||||
|
Left = 240
|
||||||
|
Top = 8
|
||||||
|
Width = 23
|
||||||
|
Height = 18
|
||||||
|
Caption = '...'
|
||||||
|
TabOrder = 0
|
||||||
|
OnClick = PickColor
|
||||||
|
end
|
||||||
|
object btnFormColor: TButton
|
||||||
|
Tag = 2
|
||||||
|
Left = 240
|
||||||
|
Top = 28
|
||||||
|
Width = 23
|
||||||
|
Height = 18
|
||||||
|
Caption = '...'
|
||||||
|
TabOrder = 1
|
||||||
|
OnClick = PickColor
|
||||||
|
end
|
||||||
|
object btnDataModuleColor: TButton
|
||||||
|
Tag = 3
|
||||||
|
Left = 240
|
||||||
|
Top = 48
|
||||||
|
Width = 23
|
||||||
|
Height = 18
|
||||||
|
Caption = '...'
|
||||||
|
TabOrder = 2
|
||||||
|
OnClick = PickColor
|
||||||
|
end
|
||||||
|
object btnProjectColor: TButton
|
||||||
|
Tag = 4
|
||||||
|
Left = 240
|
||||||
|
Top = 68
|
||||||
|
Width = 23
|
||||||
|
Height = 18
|
||||||
|
Caption = '...'
|
||||||
|
TabOrder = 3
|
||||||
|
OnClick = PickColor
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object tsAbout: TTabSheet
|
||||||
|
Caption = 'About...'
|
||||||
|
ImageIndex = 1
|
||||||
|
DesignSize = (
|
||||||
|
287
|
||||||
|
181)
|
||||||
|
object imgAbout: TImage
|
||||||
|
Left = 8
|
||||||
|
Top = 8
|
||||||
|
Width = 32
|
||||||
|
Height = 32
|
||||||
|
Picture.Data = {
|
||||||
|
055449636F6E0000010001002020100001000400E80200001600000028000000
|
||||||
|
2000000040000000010004000000000000020000000000000000000000000000
|
||||||
|
0000000000000000000080000080000000808000800000008000800080800000
|
||||||
|
80808000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000
|
||||||
|
FFFFFF0000000000000000000000000000000000000000000000000000000000
|
||||||
|
00000000000000F7777777777777777777777700000000F8F8F8F8F8F8F8F8F8
|
||||||
|
F8F8F700000000FF8F8F8F8F8F8F8F8F8F8F8700000000F8F8F8F8F8F8F8F8F8
|
||||||
|
F8F8F700000000FF8F8F8F8F8F8F8F8F8F8F8700000000F8F000000000000000
|
||||||
|
0008F700000000FF8F8F8F8F8F8F8F8F8F8F8700000000F8F8F8F8F8F8F8F8F8
|
||||||
|
F8F8F700000000FF8F8F8F8F8F8F8F8F8F8F8700000000F8F000000000000000
|
||||||
|
0008F700000000FF8F8F8F8F8F8F8F8F8F8F87000C0000F99999999999999999
|
||||||
|
999997000CC000F99999999999999999999997000CCE00F99FFFFFFFFFFFFFFF
|
||||||
|
FFF997000CE000F99999999999999999999997000E0000F99999999999999999
|
||||||
|
99999700000000FF8F8F8F8F8F8F8F8F8F8F8700000000F8F000000000000000
|
||||||
|
0008F700000000FF8F8F8F8F8F8F8F8F8F8F8700000000F8F8F8F8F8F8F8F8F8
|
||||||
|
F8F8F700000000FF8F8F8F8F8F8F8F8F8F8F8700000000F8F0000000000008F8
|
||||||
|
77777700000000FF8F8F8F8F8F8F8F8000000000000000F8F8F8F8F8F8F8F8F0
|
||||||
|
FFFFF000000000FF8F8F8F8F8F8F8F80FFFF0000000000F8F0000000000008F0
|
||||||
|
FFF00000000000FF8F8F8F8F8F8F8F80FF000000000000F8F8F8F8F8F8F8F8F0
|
||||||
|
F0000000000000FFFFFFFFFFFFFFFFF000000000000000000000000000000000
|
||||||
|
00000000FFFFFFFFF8000001F8000001F8000001F8000001F8000001F8000001
|
||||||
|
F8000001F8000001F8000001F800000178000001380000011800000108000001
|
||||||
|
0000000108000001180000013800000178000001F8000001F8000001F8000001
|
||||||
|
F8000001F8000001F8000003F8000007F800000FF800001FF800003FF800007F
|
||||||
|
F80000FF}
|
||||||
|
end
|
||||||
|
object TLabel
|
||||||
|
Left = 56
|
||||||
|
Top = 8
|
||||||
|
Width = 82
|
||||||
|
Height = 16
|
||||||
|
Caption = 'UnitSwitcher'
|
||||||
|
Font.Charset = DEFAULT_CHARSET
|
||||||
|
Font.Color = clWindowText
|
||||||
|
Font.Height = -13
|
||||||
|
Font.Name = 'Tahoma'
|
||||||
|
Font.Style = [fsBold]
|
||||||
|
ParentFont = False
|
||||||
|
end
|
||||||
|
object lblVersion: TLabel
|
||||||
|
Left = 56
|
||||||
|
Top = 23
|
||||||
|
Width = 54
|
||||||
|
Height = 13
|
||||||
|
Caption = 'Version 0.2'
|
||||||
|
end
|
||||||
|
object TLabel
|
||||||
|
Left = 56
|
||||||
|
Top = 106
|
||||||
|
Width = 145
|
||||||
|
Height = 13
|
||||||
|
Anchors = [akLeft, akBottom]
|
||||||
|
Caption = 'Copyright '#169' 2006 X'#178'Software'
|
||||||
|
ExplicitTop = 196
|
||||||
|
end
|
||||||
|
object TLabel
|
||||||
|
Left = 56
|
||||||
|
Top = 130
|
||||||
|
Width = 225
|
||||||
|
Height = 41
|
||||||
|
Anchors = [akLeft, akRight, akBottom]
|
||||||
|
AutoSize = False
|
||||||
|
Caption =
|
||||||
|
'UnitSwitcher is released as open-source under the zlib/libpng OS' +
|
||||||
|
'I-approved license. See license.txt for details.'
|
||||||
|
WordWrap = True
|
||||||
|
ExplicitTop = 220
|
||||||
|
end
|
||||||
|
object TLabel
|
||||||
|
Left = 56
|
||||||
|
Top = 56
|
||||||
|
Width = 225
|
||||||
|
Height = 29
|
||||||
|
Anchors = [akLeft, akTop, akRight]
|
||||||
|
AutoSize = False
|
||||||
|
Caption =
|
||||||
|
'Many thanks to Richard L. for the idea, feedback and beta testin' +
|
||||||
|
'g.'
|
||||||
|
WordWrap = True
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object btnCancel: TButton
|
||||||
|
Left = 224
|
||||||
|
Top = 219
|
||||||
|
Width = 75
|
||||||
|
Height = 25
|
||||||
|
Anchors = [akRight, akBottom]
|
||||||
|
Cancel = True
|
||||||
|
Caption = 'Cancel'
|
||||||
|
ModalResult = 2
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
object btnOk: TButton
|
||||||
|
Left = 143
|
||||||
|
Top = 219
|
||||||
|
Width = 75
|
||||||
|
Height = 25
|
||||||
|
Anchors = [akRight, akBottom]
|
||||||
|
Caption = 'OK'
|
||||||
|
ModalResult = 1
|
||||||
|
TabOrder = 2
|
||||||
|
end
|
||||||
|
object dlgColor: TColorDialog
|
||||||
|
Options = [cdFullOpen]
|
||||||
|
Left = 8
|
||||||
|
Top = 216
|
||||||
|
end
|
||||||
|
end
|
129
Source/UnSwConfiguration.pas
Normal file
129
Source/UnSwConfiguration.pas
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
{: Contains the configuration dialog.
|
||||||
|
|
||||||
|
Last changed: $Date$
|
||||||
|
Revision: $Rev$
|
||||||
|
Author: $Author$
|
||||||
|
}
|
||||||
|
unit UnSwConfiguration;
|
||||||
|
|
||||||
|
interface
|
||||||
|
uses
|
||||||
|
Classes,
|
||||||
|
ComCtrls,
|
||||||
|
Controls,
|
||||||
|
Dialogs,
|
||||||
|
ExtCtrls,
|
||||||
|
Forms,
|
||||||
|
Graphics,
|
||||||
|
StdCtrls;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfrmUnSwConfiguration = class(TForm)
|
||||||
|
btnCancel: TButton;
|
||||||
|
btnDataModuleColor: TButton;
|
||||||
|
btnFormColor: TButton;
|
||||||
|
btnOk: TButton;
|
||||||
|
btnProjectColor: TButton;
|
||||||
|
btnUnitColor: TButton;
|
||||||
|
chkCustomColor: TCheckBox;
|
||||||
|
dlgColor: TColorDialog;
|
||||||
|
imgAbout: TImage;
|
||||||
|
lblDataModuleColor: TLabel;
|
||||||
|
lblFormColor: TLabel;
|
||||||
|
lblProjectColor: TLabel;
|
||||||
|
lblUnitColor: TLabel;
|
||||||
|
lblVersion: TLabel;
|
||||||
|
pcConfiguration: TPageControl;
|
||||||
|
pnlCustomColor: TPanel;
|
||||||
|
tsAbout: TTabSheet;
|
||||||
|
tsGeneral: TTabSheet;
|
||||||
|
|
||||||
|
procedure chkCustomColorClick(Sender: TObject);
|
||||||
|
procedure PickColor(Sender: TObject);
|
||||||
|
private
|
||||||
|
FLabels: array[0..3] of TLabel;
|
||||||
|
|
||||||
|
function InternalExecute(): Boolean;
|
||||||
|
|
||||||
|
procedure LoadSettings();
|
||||||
|
procedure SaveSettings();
|
||||||
|
public
|
||||||
|
class function Execute(): Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
uses
|
||||||
|
UnSwSettings;
|
||||||
|
|
||||||
|
{$R *.dfm}
|
||||||
|
|
||||||
|
{ TfrmUnSwConfiguration }
|
||||||
|
class function TfrmUnSwConfiguration.Execute(): Boolean;
|
||||||
|
begin
|
||||||
|
with Self.Create(nil) do
|
||||||
|
try
|
||||||
|
Result := InternalExecute();
|
||||||
|
finally
|
||||||
|
Free();
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TfrmUnSwConfiguration.InternalExecute(): Boolean;
|
||||||
|
var
|
||||||
|
iLabel: Integer;
|
||||||
|
|
||||||
|
begin
|
||||||
|
for iLabel := 0 to Pred(pnlCustomColor.ControlCount) do
|
||||||
|
with pnlCustomColor do
|
||||||
|
if (Controls[iLabel] is TLabel) and
|
||||||
|
(Controls[iLabel].Tag > 0) then
|
||||||
|
FLabels[Pred(Controls[iLabel].Tag)] := TLabel(Controls[iLabel]);
|
||||||
|
|
||||||
|
LoadSettings();
|
||||||
|
Result := (ShowModal() = mrOk);
|
||||||
|
if Result then
|
||||||
|
SaveSettings();
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TfrmUnSwConfiguration.LoadSettings();
|
||||||
|
begin
|
||||||
|
chkCustomColor.Checked := Settings.Colors.Enabled;
|
||||||
|
lblDataModuleColor.Font.Color := Settings.Colors.DataModules;
|
||||||
|
lblFormColor.Font.Color := Settings.Colors.Forms;
|
||||||
|
lblProjectColor.Font.Color := Settings.Colors.ProjectSource;
|
||||||
|
lblUnitColor.Font.Color := Settings.Colors.Units;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmUnSwConfiguration.SaveSettings();
|
||||||
|
begin
|
||||||
|
Settings.Colors.Enabled := chkCustomColor.Checked;
|
||||||
|
Settings.Colors.DataModules := lblDataModuleColor.Font.Color;
|
||||||
|
Settings.Colors.Forms := lblFormColor.Font.Color;
|
||||||
|
Settings.Colors.ProjectSource := lblProjectColor.Font.Color;
|
||||||
|
Settings.Colors.Units := lblUnitColor.Font.Color;
|
||||||
|
Settings.Save();
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TfrmUnSwConfiguration.chkCustomColorClick(Sender: TObject);
|
||||||
|
const
|
||||||
|
Colors: array[Boolean] of TColor = (clBtnFace, clWindow);
|
||||||
|
|
||||||
|
begin
|
||||||
|
pnlCustomColor.Enabled := chkCustomColor.Checked;
|
||||||
|
pnlCustomColor.Color := Colors[pnlCustomColor.Enabled];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmUnSwConfiguration.PickColor(Sender: TObject);
|
||||||
|
var
|
||||||
|
typeLabel: TLabel;
|
||||||
|
|
||||||
|
begin
|
||||||
|
typeLabel := FLabels[Pred((Sender as TComponent).Tag)];
|
||||||
|
dlgColor.Color := typeLabel.Font.Color;
|
||||||
|
if dlgColor.Execute() then
|
||||||
|
typeLabel.Font.Color := dlgColor.Color;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
@ -3,37 +3,47 @@ object frmUnSwDialog: TfrmUnSwDialog
|
|||||||
Top = 83
|
Top = 83
|
||||||
BorderIcons = [biSystemMenu]
|
BorderIcons = [biSystemMenu]
|
||||||
Caption = 'UnitSwitcher'
|
Caption = 'UnitSwitcher'
|
||||||
ClientHeight = 400
|
ClientHeight = 398
|
||||||
ClientWidth = 320
|
ClientWidth = 292
|
||||||
Color = clBtnFace
|
Color = clBtnFace
|
||||||
Constraints.MinHeight = 240
|
Constraints.MinHeight = 240
|
||||||
Constraints.MinWidth = 172
|
Constraints.MinWidth = 270
|
||||||
Font.Charset = DEFAULT_CHARSET
|
Font.Charset = DEFAULT_CHARSET
|
||||||
Font.Color = clWindowText
|
Font.Color = clWindowText
|
||||||
Font.Height = -11
|
Font.Height = -11
|
||||||
Font.Name = 'Tahoma'
|
Font.Name = 'Tahoma'
|
||||||
Font.Style = []
|
Font.Style = []
|
||||||
|
Icon.Data = {
|
||||||
|
0000010001001010100001000400280100001600000028000000100000002000
|
||||||
|
0000010004000000000080000000000000000000000000000000000000000000
|
||||||
|
000000008000008000000080800080000000800080008080000080808000C0C0
|
||||||
|
C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000
|
||||||
|
0000000000000000F777777777700000FF8F8F8F8F700000F8F8F8F8F8700000
|
||||||
|
FF0000000F700000F8F8F8F8F8700000F999999999700400F9FFFFFFF9700000
|
||||||
|
F999999999700000F8F8F8F8F8700000FF0000008F700000F8F8F8F8F7700000
|
||||||
|
FF00008F00000000F8F8F8F80F000000FFFFFFFF00000000000000000000E000
|
||||||
|
0000E0000000E0000000E0000000E00000006000000020000000000000002000
|
||||||
|
000060000000E0000000E0000000E0000000E0010000E0030000E0070000}
|
||||||
OldCreateOrder = False
|
OldCreateOrder = False
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
|
OnResize = FormResize
|
||||||
PixelsPerInch = 96
|
PixelsPerInch = 96
|
||||||
TextHeight = 13
|
TextHeight = 13
|
||||||
object sbStatus: TStatusBar
|
object sbStatus: TStatusBar
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 381
|
Top = 379
|
||||||
Width = 320
|
Width = 292
|
||||||
Height = 19
|
Height = 19
|
||||||
Panels = <
|
Panels = <
|
||||||
item
|
item
|
||||||
Width = 50
|
Width = 50
|
||||||
end>
|
end>
|
||||||
ExplicitTop = 408
|
|
||||||
ExplicitWidth = 299
|
|
||||||
end
|
end
|
||||||
object pnlMain: TPanel
|
object pnlMain: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 320
|
Width = 292
|
||||||
Height = 290
|
Height = 288
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
BorderWidth = 4
|
BorderWidth = 4
|
||||||
@ -43,57 +53,52 @@ object frmUnSwDialog: TfrmUnSwDialog
|
|||||||
object pnlSearch: TPanel
|
object pnlSearch: TPanel
|
||||||
Left = 4
|
Left = 4
|
||||||
Top = 4
|
Top = 4
|
||||||
Width = 312
|
Width = 284
|
||||||
Height = 25
|
Height = 25
|
||||||
Align = alTop
|
Align = alTop
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
ExplicitWidth = 291
|
|
||||||
DesignSize = (
|
DesignSize = (
|
||||||
312
|
284
|
||||||
25)
|
25)
|
||||||
object edtSearch: TEdit
|
object edtSearch: TEdit
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 312
|
Width = 284
|
||||||
Height = 21
|
Height = 21
|
||||||
Anchors = [akLeft, akTop, akRight]
|
Anchors = [akLeft, akTop, akRight]
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
OnChange = edtSearchChange
|
OnChange = edtSearchChange
|
||||||
OnKeyDown = edtSearchKeyDown
|
OnKeyDown = edtSearchKeyDown
|
||||||
ExplicitWidth = 291
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object lstUnits: TListBox
|
object lstUnits: TListBox
|
||||||
Left = 4
|
Left = 4
|
||||||
Top = 29
|
Top = 29
|
||||||
Width = 312
|
Width = 284
|
||||||
Height = 257
|
Height = 255
|
||||||
Style = lbVirtualOwnerDraw
|
Style = lbVirtualOwnerDraw
|
||||||
Align = alClient
|
Align = alClient
|
||||||
ItemHeight = 20
|
ItemHeight = 20
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
OnData = lstUnitsData
|
OnData = lstUnitsData
|
||||||
|
OnDblClick = lstUnitsDblClick
|
||||||
OnDrawItem = lstUnitsDrawItem
|
OnDrawItem = lstUnitsDrawItem
|
||||||
ExplicitWidth = 291
|
|
||||||
ExplicitHeight = 284
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object pnlButtons: TPanel
|
object pnlButtons: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 345
|
Top = 343
|
||||||
Width = 320
|
Width = 292
|
||||||
Height = 36
|
Height = 36
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
ExplicitTop = 372
|
|
||||||
ExplicitWidth = 299
|
|
||||||
DesignSize = (
|
DesignSize = (
|
||||||
320
|
292
|
||||||
36)
|
36)
|
||||||
object btnCancel: TButton
|
object btnCancel: TButton
|
||||||
Left = 241
|
Left = 213
|
||||||
Top = 5
|
Top = 5
|
||||||
Width = 75
|
Width = 75
|
||||||
Height = 25
|
Height = 25
|
||||||
@ -102,10 +107,9 @@ object frmUnSwDialog: TfrmUnSwDialog
|
|||||||
Caption = 'Cancel'
|
Caption = 'Cancel'
|
||||||
ModalResult = 2
|
ModalResult = 2
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
ExplicitLeft = 220
|
|
||||||
end
|
end
|
||||||
object btnOK: TButton
|
object btnOK: TButton
|
||||||
Left = 160
|
Left = 132
|
||||||
Top = 5
|
Top = 5
|
||||||
Width = 75
|
Width = 75
|
||||||
Height = 25
|
Height = 25
|
||||||
@ -114,23 +118,29 @@ object frmUnSwDialog: TfrmUnSwDialog
|
|||||||
Default = True
|
Default = True
|
||||||
ModalResult = 1
|
ModalResult = 1
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
ExplicitLeft = 139
|
end
|
||||||
|
object btnConfiguration: TButton
|
||||||
|
Left = 4
|
||||||
|
Top = 5
|
||||||
|
Width = 85
|
||||||
|
Height = 25
|
||||||
|
Caption = '&Configuration'
|
||||||
|
TabOrder = 2
|
||||||
|
OnClick = btnConfigurationClick
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object pnlIncludeTypes: TPanel
|
object pnlIncludeTypes: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 290
|
Top = 288
|
||||||
Width = 320
|
Width = 292
|
||||||
Height = 55
|
Height = 55
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
ExplicitTop = 317
|
|
||||||
ExplicitWidth = 299
|
|
||||||
object chkDataModules: TCheckBox
|
object chkDataModules: TCheckBox
|
||||||
Left = 4
|
Left = 4
|
||||||
Top = 19
|
Top = 19
|
||||||
Width = 291
|
Width = 137
|
||||||
Height = 17
|
Height = 17
|
||||||
Caption = 'Show &DataModule units'
|
Caption = 'Show &DataModule units'
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
@ -139,7 +149,7 @@ object frmUnSwDialog: TfrmUnSwDialog
|
|||||||
object chkForms: TCheckBox
|
object chkForms: TCheckBox
|
||||||
Left = 4
|
Left = 4
|
||||||
Top = 2
|
Top = 2
|
||||||
Width = 291
|
Width = 101
|
||||||
Height = 17
|
Height = 17
|
||||||
Caption = 'Show &Form units'
|
Caption = 'Show &Form units'
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
@ -148,7 +158,7 @@ object frmUnSwDialog: TfrmUnSwDialog
|
|||||||
object chkProjectSource: TCheckBox
|
object chkProjectSource: TCheckBox
|
||||||
Left = 4
|
Left = 4
|
||||||
Top = 36
|
Top = 36
|
||||||
Width = 291
|
Width = 121
|
||||||
Height = 17
|
Height = 17
|
||||||
Caption = 'Show &Project source'
|
Caption = 'Show &Project source'
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
{: Contains the UnitSwitcher main dialog.
|
||||||
|
|
||||||
|
Last changed: $Date$
|
||||||
|
Revision: $Rev$
|
||||||
|
Author: $Author$
|
||||||
|
}
|
||||||
unit UnSwDialog;
|
unit UnSwDialog;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -7,6 +13,7 @@ uses
|
|||||||
Controls,
|
Controls,
|
||||||
ExtCtrls,
|
ExtCtrls,
|
||||||
Forms,
|
Forms,
|
||||||
|
Graphics,
|
||||||
ImgList,
|
ImgList,
|
||||||
StdCtrls,
|
StdCtrls,
|
||||||
Windows,
|
Windows,
|
||||||
@ -15,18 +22,21 @@ uses
|
|||||||
UnSwFilters;
|
UnSwFilters;
|
||||||
|
|
||||||
type
|
type
|
||||||
TUnSwIconVisitor = class(TUnSwNoRefIntfObject, IUnSwVisitor)
|
TUnSwStyleVisitor = class(TUnSwNoRefIntfObject, IUnSwVisitor)
|
||||||
private
|
private
|
||||||
|
FColor: TColor;
|
||||||
FImageIndex: Integer;
|
FImageIndex: Integer;
|
||||||
protected
|
protected
|
||||||
procedure VisitModule(const AUnit: TUnSwModuleUnit);
|
procedure VisitModule(const AUnit: TUnSwModuleUnit);
|
||||||
procedure VisitProject(const AUnit: TUnSwProjectUnit);
|
procedure VisitProject(const AUnit: TUnSwProjectUnit);
|
||||||
public
|
public
|
||||||
|
property Color: TColor read FColor;
|
||||||
property ImageIndex: Integer read FImageIndex;
|
property ImageIndex: Integer read FImageIndex;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TfrmUnSwDialog = class(TForm)
|
TfrmUnSwDialog = class(TForm)
|
||||||
btnCancel: TButton;
|
btnCancel: TButton;
|
||||||
|
btnConfiguration: TButton;
|
||||||
btnOK: TButton;
|
btnOK: TButton;
|
||||||
chkDataModules: TCheckBox;
|
chkDataModules: TCheckBox;
|
||||||
chkForms: TCheckBox;
|
chkForms: TCheckBox;
|
||||||
@ -40,9 +50,12 @@ type
|
|||||||
pnlSearch: TPanel;
|
pnlSearch: TPanel;
|
||||||
sbStatus: TStatusBar;
|
sbStatus: TStatusBar;
|
||||||
|
|
||||||
|
procedure FormResize(Sender: TObject);
|
||||||
|
procedure btnConfigurationClick(Sender: TObject);
|
||||||
procedure edtSearchChange(Sender: TObject);
|
procedure edtSearchChange(Sender: TObject);
|
||||||
procedure edtSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure edtSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure TypeFilterChange(Sender: TObject);
|
procedure TypeFilterChange(Sender: TObject);
|
||||||
|
procedure lstUnitsDblClick(Sender: TObject);
|
||||||
procedure lstUnitsData(Control: TWinControl; Index: Integer; var Data: string);
|
procedure lstUnitsData(Control: TWinControl; Index: Integer; var Data: string);
|
||||||
procedure lstUnitsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
procedure lstUnitsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
||||||
private
|
private
|
||||||
@ -57,7 +70,7 @@ type
|
|||||||
FTypeFilter: TUnSwUnitTypeFilter;
|
FTypeFilter: TUnSwUnitTypeFilter;
|
||||||
FInputFilter: TUnSwUnitSimpleFilter;
|
FInputFilter: TUnSwUnitSimpleFilter;
|
||||||
|
|
||||||
FIconVisitor: TUnSwIconVisitor;
|
FStyleVisitor: TUnSwStyleVisitor;
|
||||||
|
|
||||||
function InternalExecute(): TUnSwUnit;
|
function InternalExecute(): TUnSwUnit;
|
||||||
procedure UpdateTypeFilter();
|
procedure UpdateTypeFilter();
|
||||||
@ -75,28 +88,44 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
Graphics,
|
|
||||||
Messages,
|
Messages,
|
||||||
SysUtils;
|
SysUtils,
|
||||||
|
|
||||||
|
UnSwConfiguration,
|
||||||
|
UnSwSettings;
|
||||||
|
|
||||||
|
|
||||||
{$R *.dfm}
|
{$R *.dfm}
|
||||||
|
|
||||||
|
|
||||||
{ TUnSwIconVisitor }
|
{ TUnSwStyleVisitor }
|
||||||
procedure TUnSwIconVisitor.VisitModule(const AUnit: TUnSwModuleUnit);
|
procedure TUnSwStyleVisitor.VisitModule(const AUnit: TUnSwModuleUnit);
|
||||||
begin
|
begin
|
||||||
case AUnit.UnitType of
|
case AUnit.UnitType of
|
||||||
swutUnit: FImageIndex := 1;
|
swutUnit:
|
||||||
swutForm: FImageIndex := 2;
|
begin
|
||||||
swutDataModule: FImageIndex := 3;
|
FColor := Settings.Colors.Units;
|
||||||
|
FImageIndex := 1;
|
||||||
|
end;
|
||||||
|
swutForm:
|
||||||
|
begin
|
||||||
|
FColor := Settings.Colors.Forms;
|
||||||
|
FImageIndex := 2;
|
||||||
|
end;
|
||||||
|
swutDataModule:
|
||||||
|
begin
|
||||||
|
FColor := Settings.Colors.DataModules;
|
||||||
|
FImageIndex := 3;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
FImageIndex := 0;
|
FColor := clWindowText;
|
||||||
|
FImageIndex := 0;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnSwIconVisitor.VisitProject(const AUnit: TUnSwProjectUnit);
|
procedure TUnSwStyleVisitor.VisitProject(const AUnit: TUnSwProjectUnit);
|
||||||
begin
|
begin
|
||||||
|
FColor := Settings.Colors.ProjectSource;
|
||||||
FImageIndex := 4;
|
FImageIndex := 4;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -117,6 +146,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TfrmUnSwDialog.FormResize(Sender: TObject);
|
||||||
|
begin
|
||||||
|
lstUnits.Invalidate();
|
||||||
|
end;
|
||||||
|
|
||||||
function SortByName(Item1, Item2: Pointer): Integer;
|
function SortByName(Item1, Item2: Pointer): Integer;
|
||||||
begin
|
begin
|
||||||
Result := CompareText(TUnSwUnit(Item1).Name, TUnSwUnit(Item2).Name)
|
Result := CompareText(TUnSwUnit(Item1).Name, TUnSwUnit(Item2).Name)
|
||||||
@ -137,18 +171,22 @@ begin
|
|||||||
LoadSettings();
|
LoadSettings();
|
||||||
|
|
||||||
if FFormsOnly then
|
if FFormsOnly then
|
||||||
|
begin
|
||||||
pnlIncludeTypes.Visible := False;
|
pnlIncludeTypes.Visible := False;
|
||||||
|
Self.Caption := 'UnitSwitcher - View Form';
|
||||||
|
end else
|
||||||
|
Self.Caption := 'UnitSwitcher - View Unit';
|
||||||
|
|
||||||
UpdateTypeFilter();
|
UpdateTypeFilter();
|
||||||
|
|
||||||
FIconVisitor := TUnSwIconVisitor.Create();
|
FStyleVisitor := TUnSwStyleVisitor.Create();
|
||||||
try
|
try
|
||||||
if Self.ShowModal() = mrOk then
|
if Self.ShowModal() = mrOk then
|
||||||
Result := GetActiveUnit();
|
Result := GetActiveUnit();
|
||||||
|
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
finally
|
finally
|
||||||
FreeAndNil(FIconVisitor);
|
FreeAndNil(FStyleVisitor);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
FreeAndNil(FInputFilter);
|
FreeAndNil(FInputFilter);
|
||||||
@ -160,10 +198,10 @@ end;
|
|||||||
|
|
||||||
procedure TfrmUnSwDialog.UpdateList();
|
procedure TfrmUnSwDialog.UpdateList();
|
||||||
var
|
var
|
||||||
pActive: TUnSwUnit;
|
activeUnit: TUnSwUnit;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
pActive := GetActiveUnit();
|
activeUnit := GetActiveUnit();
|
||||||
|
|
||||||
FInputFilteredList.Clone(FTypeFilteredList);
|
FInputFilteredList.Clone(FTypeFilteredList);
|
||||||
FInputFilteredList.AcceptVisitor(FInputFilter);
|
FInputFilteredList.AcceptVisitor(FInputFilter);
|
||||||
@ -171,8 +209,8 @@ begin
|
|||||||
lstUnits.Count := FInputFilteredList.Count;
|
lstUnits.Count := FInputFilteredList.Count;
|
||||||
if FInputFilteredList.Count > 0 then
|
if FInputFilteredList.Count > 0 then
|
||||||
begin
|
begin
|
||||||
if Assigned(pActive) then
|
if Assigned(activeUnit) then
|
||||||
lstUnits.ItemIndex := FInputFilteredList.IndexOf(pActive);
|
lstUnits.ItemIndex := FInputFilteredList.IndexOf(activeUnit);
|
||||||
|
|
||||||
if lstUnits.ItemIndex = -1 then
|
if lstUnits.ItemIndex = -1 then
|
||||||
lstUnits.ItemIndex := 0;
|
lstUnits.ItemIndex := 0;
|
||||||
@ -206,91 +244,54 @@ end;
|
|||||||
|
|
||||||
procedure TfrmUnSwDialog.LoadSettings();
|
procedure TfrmUnSwDialog.LoadSettings();
|
||||||
var
|
var
|
||||||
pSettings: TUnSwRegistry;
|
dialogSettings: TUnSwDialogSettings;
|
||||||
|
|
||||||
function ReadBoolDef(const AName: String; const ADefault: Boolean): Boolean;
|
|
||||||
begin
|
|
||||||
if pSettings.ValueExists(AName) then
|
|
||||||
Result := pSettings.ReadBool(AName)
|
|
||||||
else
|
|
||||||
Result := ADefault;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function ReadIntegerDef(const AName: String; const ADefault: Integer): Integer;
|
|
||||||
|
|
||||||
begin
|
|
||||||
if pSettings.ValueExists(AName) then
|
|
||||||
Result := pSettings.ReadInteger(AName)
|
|
||||||
else
|
|
||||||
Result := ADefault;
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
|
||||||
sKey: String;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
pSettings := TUnSwRegistry.Create();
|
if FFormsOnly then
|
||||||
with pSettings do
|
dialogSettings := Settings.FormsDialog
|
||||||
|
else
|
||||||
|
dialogSettings := Settings.UnitsDialog;
|
||||||
|
|
||||||
|
FLoading := True;
|
||||||
try
|
try
|
||||||
FLoading := True;
|
chkDataModules.Checked := dialogSettings.IncludeDataModules;
|
||||||
RootKey := HKEY_CURRENT_USER;
|
chkForms.Checked := dialogSettings.IncludeForms;
|
||||||
|
chkProjectSource.Checked := dialogSettings.IncludeProjectSource;
|
||||||
|
|
||||||
if OpenIDEKey() then
|
Self.ClientWidth := dialogSettings.Width;
|
||||||
begin
|
Self.ClientHeight := dialogSettings.Height;
|
||||||
chkForms.Checked := ReadBoolDef('IncludeForms', FTypeFilter.IncludeForms);
|
|
||||||
chkDataModules.Checked := ReadBoolDef('IncludeDataModules', FTypeFilter.IncludeDataModules);
|
|
||||||
chkProjectSource.Checked := ReadBoolDef('IncludeProjectSource', FTypeFilter.IncludeProjectSource);
|
|
||||||
|
|
||||||
if FFormsOnly then
|
|
||||||
sKey := 'Forms'
|
|
||||||
else
|
|
||||||
sKey := 'Units';
|
|
||||||
|
|
||||||
Self.ClientWidth := ReadIntegerDef(sKey + 'DialogWidth', Self.ClientWidth);
|
|
||||||
Self.ClientHeight := ReadIntegerDef(sKey + 'DialogHeight', Self.ClientHeight);
|
|
||||||
Self.Caption := 'UnitSwitcher - View ' + sKey;
|
|
||||||
|
|
||||||
CloseKey();
|
|
||||||
end;
|
|
||||||
finally
|
finally
|
||||||
FLoading := False;
|
FLoading := False;
|
||||||
FreeAndNil(pSettings);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmUnSwDialog.SaveSettings();
|
procedure TfrmUnSwDialog.SaveSettings();
|
||||||
var
|
var
|
||||||
sKey: String;
|
dialogSettings: TUnSwDialogSettings;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
with TUnSwRegistry.Create() do
|
if FFormsOnly then
|
||||||
try
|
dialogSettings := Settings.FormsDialog
|
||||||
FLoading := True;
|
else
|
||||||
RootKey := HKEY_CURRENT_USER;
|
dialogSettings := Settings.UnitsDialog;
|
||||||
|
|
||||||
if OpenIDEKey() then
|
dialogSettings.IncludeDataModules := chkForms.Checked;
|
||||||
begin
|
dialogSettings.IncludeForms := chkDataModules.Checked;
|
||||||
WriteBool('IncludeForms', chkForms.Checked);
|
dialogSettings.IncludeProjectSource := chkProjectSource.Checked;
|
||||||
WriteBool('IncludeDataModules', chkDataModules.Checked);
|
|
||||||
WriteBool('IncludeProjectSource', chkProjectSource.Checked);
|
|
||||||
|
|
||||||
if FFormsOnly then
|
dialogSettings.Width := Self.ClientWidth;
|
||||||
sKey := 'Forms'
|
dialogSettings.Height := Self.ClientHeight;
|
||||||
else
|
|
||||||
sKey := 'Units';
|
|
||||||
|
|
||||||
WriteInteger(sKey + 'DialogWidth', Self.ClientWidth);
|
Settings.Save();
|
||||||
WriteInteger(sKey + 'DialogHeight', Self.ClientHeight);
|
|
||||||
|
|
||||||
CloseKey();
|
|
||||||
end;
|
|
||||||
finally
|
|
||||||
FLoading := False;
|
|
||||||
Free();
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TfrmUnSwDialog.btnConfigurationClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if TfrmUnSwConfiguration.Execute() then
|
||||||
|
lstUnits.Invalidate();
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TfrmUnSwDialog.edtSearchChange(Sender: TObject);
|
procedure TfrmUnSwDialog.edtSearchChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FInputFilter.Filter := edtSearch.Text;
|
FInputFilter.Filter := edtSearch.Text;
|
||||||
@ -310,6 +311,11 @@ begin
|
|||||||
UpdateTypeFilter();
|
UpdateTypeFilter();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TfrmUnSwDialog.lstUnitsDblClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
btnOK.Click();
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TfrmUnSwDialog.lstUnitsData(Control: TWinControl; Index: Integer;
|
procedure TfrmUnSwDialog.lstUnitsData(Control: TWinControl; Index: Integer;
|
||||||
var Data: string);
|
var Data: string);
|
||||||
begin
|
begin
|
||||||
@ -319,18 +325,20 @@ end;
|
|||||||
procedure TfrmUnSwDialog.lstUnitsDrawItem(Control: TWinControl; Index: Integer;
|
procedure TfrmUnSwDialog.lstUnitsDrawItem(Control: TWinControl; Index: Integer;
|
||||||
Rect: TRect; State: TOwnerDrawState);
|
Rect: TRect; State: TOwnerDrawState);
|
||||||
var
|
var
|
||||||
pUnit: TUnSwUnit;
|
currentUnit: TUnSwUnit;
|
||||||
rText: TRect;
|
textRect: TRect;
|
||||||
sText: String;
|
text: String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
with TListBox(Control) do
|
with TListBox(Control) do
|
||||||
begin
|
begin
|
||||||
pUnit := FInputFilteredList[Index];
|
currentUnit := FInputFilteredList[Index];
|
||||||
if FFormsOnly and (pUnit is TUnSwModuleUnit) then
|
currentUnit.AcceptVisitor(FStyleVisitor);
|
||||||
sText := TUnSwModuleUnit(pUnit).FormName
|
|
||||||
|
if FFormsOnly and (currentUnit is TUnSwModuleUnit) then
|
||||||
|
text := TUnSwModuleUnit(currentUnit).FormName
|
||||||
else
|
else
|
||||||
sText := pUnit.Name;
|
text := currentUnit.Name;
|
||||||
|
|
||||||
if odSelected in State then
|
if odSelected in State then
|
||||||
begin
|
begin
|
||||||
@ -339,18 +347,19 @@ begin
|
|||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
Canvas.Brush.Color := clWindow;
|
Canvas.Brush.Color := clWindow;
|
||||||
Canvas.Font.Color := clWindowText;
|
if Settings.Colors.Enabled then
|
||||||
|
Canvas.Font.Color := FStyleVisitor.Color
|
||||||
|
else
|
||||||
|
Canvas.Font.Color := clWindowText;
|
||||||
end;
|
end;
|
||||||
Canvas.FillRect(Rect);
|
Canvas.FillRect(Rect);
|
||||||
|
|
||||||
rText := Rect;
|
textRect := Rect;
|
||||||
InflateRect(rText, -2, -2);
|
InflateRect(textRect, -2, -2);
|
||||||
|
ilsTypes.Draw(Canvas, textRect.Left, textRect.Top, FStyleVisitor.ImageIndex);
|
||||||
|
|
||||||
pUnit.AcceptVisitor(FIconVisitor);
|
Inc(textRect.Left, ilsTypes.Width + 4);
|
||||||
ilsTypes.Draw(Canvas, rText.Left, rText.Top, FIconVisitor.ImageIndex);
|
DrawText(Canvas.Handle, PChar(text), Length(text), textRect, DT_SINGLELINE or
|
||||||
|
|
||||||
Inc(rText.Left, ilsTypes.Width + 4);
|
|
||||||
DrawText(Canvas.Handle, PChar(sText), Length(sText), rText, DT_SINGLELINE or
|
|
||||||
DT_LEFT or DT_VCENTER or DT_END_ELLIPSIS);
|
DT_LEFT or DT_VCENTER or DT_END_ELLIPSIS);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
{: Implements unit filtering visitors.
|
||||||
|
|
||||||
|
Last changed: $Date$
|
||||||
|
Revision: $Rev$
|
||||||
|
Author: $Author$
|
||||||
|
}
|
||||||
unit UnSwFilters;
|
unit UnSwFilters;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -129,21 +135,21 @@ end;
|
|||||||
|
|
||||||
procedure TUnSwUnitTypeFilter.VisitModule(const AUnit: TUnSwModuleUnit);
|
procedure TUnSwUnitTypeFilter.VisitModule(const AUnit: TUnSwModuleUnit);
|
||||||
var
|
var
|
||||||
eValidTypes: TUnSwUnitTypes;
|
validTypes: TUnSwUnitTypes;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
eValidTypes := [];
|
validTypes := [];
|
||||||
|
|
||||||
if FIncludeDataModules then
|
if FIncludeDataModules then
|
||||||
Include(eValidTypes, swutDataModule);
|
Include(validTypes, swutDataModule);
|
||||||
|
|
||||||
if FIncludeForms then
|
if FIncludeForms then
|
||||||
Include(eValidTypes, swutForm);
|
Include(validTypes, swutForm);
|
||||||
|
|
||||||
if FIncludeUnits then
|
if FIncludeUnits then
|
||||||
Include(eValidTypes, swutUnit);
|
Include(validTypes, swutUnit);
|
||||||
|
|
||||||
if not (AUnit.UnitType in eValidTypes) then
|
if not (AUnit.UnitType in validTypes) then
|
||||||
FilterUnit(AUnit);
|
FilterUnit(AUnit);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
{: Implements unit handling.
|
||||||
|
|
||||||
|
Last changed: $Date$
|
||||||
|
Revision: $Rev$
|
||||||
|
Author: $Author$
|
||||||
|
}
|
||||||
unit UnSwObjects;
|
unit UnSwObjects;
|
||||||
|
|
||||||
{$I UnSwDefines.inc}
|
{$I UnSwDefines.inc}
|
||||||
@ -6,7 +12,6 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes,
|
Classes,
|
||||||
Contnrs,
|
Contnrs,
|
||||||
Registry,
|
|
||||||
ToolsAPI;
|
ToolsAPI;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -133,13 +138,11 @@ type
|
|||||||
write SetItem; default;
|
write SetItem; default;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TUnSwRegistry = class(TRegistry)
|
|
||||||
public
|
|
||||||
function OpenIDEKey(): Boolean;
|
|
||||||
end;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
|
{$IFDEF DELPHI7}
|
||||||
|
ActnList,
|
||||||
|
{$ENDIF}
|
||||||
SysUtils;
|
SysUtils;
|
||||||
|
|
||||||
|
|
||||||
@ -178,27 +181,27 @@ end;
|
|||||||
procedure TUnSwUnit.OpenModule(const AModule: IOTAModule; const ASource: Boolean);
|
procedure TUnSwUnit.OpenModule(const AModule: IOTAModule; const ASource: Boolean);
|
||||||
{$IFDEF DELPHI7}
|
{$IFDEF DELPHI7}
|
||||||
var
|
var
|
||||||
ifEditor: IOTAEditor;
|
editor: IOTAEditor;
|
||||||
iModule: Integer;
|
formEditor: IOTAFormEditor;
|
||||||
|
moduleIndex: Integer;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF DELPHI7}
|
{$IFDEF DELPHI7}
|
||||||
for iModule := 0 to Pred(AModule.ModuleFileCount) do
|
for moduleIndex := 0 to Pred(AModule.ModuleFileCount) do
|
||||||
if Supports(AModule.ModuleFileEditors[iModule], IOTAFormEditor,
|
begin
|
||||||
ifEditor) then
|
editor := AModule.ModuleFileEditors[moduleIndex];
|
||||||
|
|
||||||
|
if not ASource then
|
||||||
begin
|
begin
|
||||||
if not ASource then
|
if not Assigned(formEditor) then
|
||||||
begin
|
Supports(editor, IOTAFormEditor, formEditor);
|
||||||
ifEditor.Show();
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end else
|
end else
|
||||||
if ASource then
|
editor.Show();
|
||||||
begin
|
end;
|
||||||
AModule.ModuleFileEditors[iModule].Show();
|
|
||||||
break;
|
if Assigned(formEditor) then
|
||||||
end;
|
formEditor.Show();
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
if ASource then
|
if ASource then
|
||||||
AModule.ShowFilename(AModule.FileName)
|
AModule.ShowFilename(AModule.FileName)
|
||||||
@ -270,8 +273,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnSwProjectUnit.Activate(const ASource: Boolean);
|
procedure TUnSwProjectUnit.Activate(const ASource: Boolean);
|
||||||
|
{$IFDEF DELPHI7}
|
||||||
|
var
|
||||||
|
actionIndex: Integer;
|
||||||
|
ntaServices: INTAServices;
|
||||||
|
action: TContainedAction;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
OpenModule(FProject, False);
|
{$IFDEF DELPHI7}
|
||||||
|
// Bit of a hack, but opening the file itself will result in Delphi 7
|
||||||
|
// reloading the project...
|
||||||
|
ntaServices := (BorlandIDEServices as INTAServices);
|
||||||
|
for actionIndex := 0 to Pred(ntaServices.ActionList.ActionCount) do
|
||||||
|
begin
|
||||||
|
action := ntaServices.ActionList.Actions[actionIndex];
|
||||||
|
if action.Name = 'ProjectViewSourceCommand' then
|
||||||
|
begin
|
||||||
|
action.Execute();
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ELSE}
|
||||||
|
OpenModule(FProject, True);
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnSwProjectUnit.AcceptVisitor(const AVisitor: IUnSwVisitor);
|
procedure TUnSwProjectUnit.AcceptVisitor(const AVisitor: IUnSwVisitor);
|
||||||
@ -286,7 +311,7 @@ end;
|
|||||||
|
|
||||||
function TUnSwProjectUnit.GetFileName(): String;
|
function TUnSwProjectUnit.GetFileName(): String;
|
||||||
begin
|
begin
|
||||||
|
Result := FProject.FileName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -309,11 +334,11 @@ end;
|
|||||||
|
|
||||||
procedure TUnSwUnitList.AcceptVisitor(const AVisitor: IUnSwVisitor);
|
procedure TUnSwUnitList.AcceptVisitor(const AVisitor: IUnSwVisitor);
|
||||||
var
|
var
|
||||||
iItem: Integer;
|
itemIndex: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
for iItem := Pred(Count) downto 0 do
|
for itemIndex := Pred(Count) downto 0 do
|
||||||
Items[iItem].AcceptVisitor(AVisitor);
|
Items[itemIndex].AcceptVisitor(AVisitor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TUnSwUnitList.Add(const AUnit: TUnSwUnit): Integer;
|
function TUnSwUnitList.Add(const AUnit: TUnSwUnit): Integer;
|
||||||
@ -328,17 +353,17 @@ end;
|
|||||||
|
|
||||||
function TUnSwUnitList.IndexOfFileName(const AFileName: String): Integer;
|
function TUnSwUnitList.IndexOfFileName(const AFileName: String): Integer;
|
||||||
var
|
var
|
||||||
iItem: Integer;
|
itemIndex: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := -1;
|
Result := -1;
|
||||||
if Length(AFileName) = 0 then
|
if Length(AFileName) = 0 then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
for iItem := Pred(Count) downto 0 do
|
for itemIndex := Pred(Count) downto 0 do
|
||||||
if SameText(Items[iItem].FileName, AFileName) then
|
if SameText(Items[itemIndex].FileName, AFileName) then
|
||||||
begin
|
begin
|
||||||
Result := iItem;
|
Result := itemIndex;
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -360,14 +385,14 @@ end;
|
|||||||
|
|
||||||
procedure TUnSwUnitList.Clone(const ASource: TUnSwUnitList);
|
procedure TUnSwUnitList.Clone(const ASource: TUnSwUnitList);
|
||||||
var
|
var
|
||||||
iItem: Integer;
|
itemIndex: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FItems.Clear();
|
FItems.Clear();
|
||||||
FItems.OwnsObjects := False;
|
FItems.OwnsObjects := False;
|
||||||
|
|
||||||
for iItem := 0 to Pred(ASource.Count) do
|
for itemIndex := 0 to Pred(ASource.Count) do
|
||||||
FItems.Add(ASource[iItem]);
|
FItems.Add(ASource[itemIndex]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -386,12 +411,4 @@ begin
|
|||||||
FItems[Index] := Value;
|
FItems[Index] := Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TUnSwRegistry }
|
|
||||||
function TUnSwRegistry.OpenIDEKey(): Boolean;
|
|
||||||
begin
|
|
||||||
Result := OpenKey((BorlandIDEServices as IOTAServices).GetBaseRegistryKey() +
|
|
||||||
'\UnitSwitcher', True);
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
332
Source/UnSwSettings.pas
Normal file
332
Source/UnSwSettings.pas
Normal file
@ -0,0 +1,332 @@
|
|||||||
|
{: Encapsulates the settings.
|
||||||
|
|
||||||
|
Last changed: $Date$
|
||||||
|
Revision: $Rev$
|
||||||
|
Author: $Author$
|
||||||
|
}
|
||||||
|
unit UnSwSettings;
|
||||||
|
|
||||||
|
interface
|
||||||
|
uses
|
||||||
|
Graphics,
|
||||||
|
Registry;
|
||||||
|
|
||||||
|
type
|
||||||
|
TUnSwBaseSettings = class(TObject)
|
||||||
|
protected
|
||||||
|
procedure Load(const ARegistry: TRegistry); virtual; abstract;
|
||||||
|
procedure Save(const ARegistry: TRegistry); virtual; abstract;
|
||||||
|
|
||||||
|
function GetKeyName(const AName: String): String; virtual;
|
||||||
|
|
||||||
|
procedure ReadBoolDef(const ARegistry: TRegistry; var AValue: Boolean; const AName: String);
|
||||||
|
procedure ReadIntegerDef(const ARegistry: TRegistry; var AValue: Integer; const AName: String);
|
||||||
|
procedure ReadColorDef(const ARegistry: TRegistry; var AValue: TColor; const AName: String);
|
||||||
|
|
||||||
|
procedure WriteBool(const ARegistry: TRegistry; const AValue: Boolean; const AName: String);
|
||||||
|
procedure WriteInteger(const ARegistry: TRegistry; const AValue: Integer; const AName: String);
|
||||||
|
procedure WriteColor(const ARegistry: TRegistry; const AValue: TColor; const AName: String);
|
||||||
|
end;
|
||||||
|
|
||||||
|
TUnSwDialogSettings = class(TUnSwBaseSettings)
|
||||||
|
private
|
||||||
|
FHeight: Integer;
|
||||||
|
FIncludeDataModules: Boolean;
|
||||||
|
FIncludeForms: Boolean;
|
||||||
|
FIncludeProjectSource: Boolean;
|
||||||
|
FIncludeUnits: Boolean;
|
||||||
|
FPrefix: String;
|
||||||
|
FWidth: Integer;
|
||||||
|
protected
|
||||||
|
function GetKeyName(const AName: String): String; override;
|
||||||
|
procedure Load(const ARegistry: TRegistry); override;
|
||||||
|
procedure Save(const ARegistry: TRegistry); override;
|
||||||
|
public
|
||||||
|
constructor Create(const APrefix: String);
|
||||||
|
|
||||||
|
property Height: Integer read FHeight write FHeight;
|
||||||
|
property IncludeDataModules: Boolean read FIncludeDataModules write FIncludeDataModules;
|
||||||
|
property IncludeForms: Boolean read FIncludeForms write FIncludeForms;
|
||||||
|
property IncludeProjectSource: Boolean read FIncludeProjectSource write FIncludeProjectSource;
|
||||||
|
property IncludeUnits: Boolean read FIncludeUnits write FIncludeUnits;
|
||||||
|
property Width: Integer read FWidth write FWidth;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TUnSwColorSettings = class(TUnSwBaseSettings)
|
||||||
|
private
|
||||||
|
FDataModules: TColor;
|
||||||
|
FEnabled: Boolean;
|
||||||
|
FForms: TColor;
|
||||||
|
FProjectSource: TColor;
|
||||||
|
FUnits: TColor;
|
||||||
|
protected
|
||||||
|
procedure Load(const ARegistry: TRegistry); override;
|
||||||
|
procedure Save(const ARegistry: TRegistry); override;
|
||||||
|
public
|
||||||
|
property DataModules: TColor read FDataModules write FDataModules;
|
||||||
|
property Enabled: Boolean read FEnabled write FEnabled;
|
||||||
|
property Forms: TColor read FForms write FForms;
|
||||||
|
property ProjectSource: TColor read FProjectSource write FProjectSource;
|
||||||
|
property Units: TColor read FUnits write FUnits;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TUnSwSettings = class(TObject)
|
||||||
|
private
|
||||||
|
FColors: TUnSwColorSettings;
|
||||||
|
FFormsDialog: TUnSwDialogSettings;
|
||||||
|
FUnitsDialog: TUnSwDialogSettings;
|
||||||
|
|
||||||
|
FRegistryKey: String;
|
||||||
|
protected
|
||||||
|
procedure Load();
|
||||||
|
public
|
||||||
|
constructor Create();
|
||||||
|
destructor Destroy(); override;
|
||||||
|
|
||||||
|
procedure ResetDefaults();
|
||||||
|
procedure Save();
|
||||||
|
|
||||||
|
property Colors: TUnSwColorSettings read FColors write FColors;
|
||||||
|
property FormsDialog: TUnSwDialogSettings read FFormsDialog write FFormsDialog;
|
||||||
|
property UnitsDialog: TUnSwDialogSettings read FUnitsDialog write FUnitsDialog;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Settings(): TUnSwSettings;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
uses
|
||||||
|
SysUtils,
|
||||||
|
ToolsAPI,
|
||||||
|
Windows;
|
||||||
|
|
||||||
|
var
|
||||||
|
GSettings: TUnSwSettings;
|
||||||
|
|
||||||
|
|
||||||
|
function Settings(): TUnSwSettings;
|
||||||
|
begin
|
||||||
|
if not Assigned(GSettings) then
|
||||||
|
GSettings := TUnSwSettings.Create();
|
||||||
|
|
||||||
|
Result := GSettings;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TUnSwBaseSettings }
|
||||||
|
function TUnSwBaseSettings.GetKeyName(const AName: String): String;
|
||||||
|
begin
|
||||||
|
Result := AName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnSwBaseSettings.ReadBoolDef(const ARegistry: TRegistry;
|
||||||
|
var AValue: Boolean;
|
||||||
|
const AName: String);
|
||||||
|
begin
|
||||||
|
if ARegistry.ValueExists(GetKeyName(AName)) then
|
||||||
|
AValue := ARegistry.ReadBool(GetKeyName(AName));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnSwBaseSettings.ReadColorDef(const ARegistry: TRegistry;
|
||||||
|
var AValue: TColor;
|
||||||
|
const AName: String);
|
||||||
|
begin
|
||||||
|
if ARegistry.ValueExists(GetKeyName(AName)) then
|
||||||
|
AValue := TColor(ARegistry.ReadInteger(GetKeyName(AName)));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnSwBaseSettings.ReadIntegerDef(const ARegistry: TRegistry;
|
||||||
|
var AValue: Integer;
|
||||||
|
const AName: String);
|
||||||
|
begin
|
||||||
|
if ARegistry.ValueExists(GetKeyName(AName)) then
|
||||||
|
AValue := ARegistry.ReadInteger(GetKeyName(AName));
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TUnSwBaseSettings.WriteBool(const ARegistry: TRegistry;
|
||||||
|
const AValue: Boolean;
|
||||||
|
const AName: String);
|
||||||
|
begin
|
||||||
|
ARegistry.WriteBool(GetKeyName(AName), AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnSwBaseSettings.WriteColor(const ARegistry: TRegistry;
|
||||||
|
const AValue: TColor;
|
||||||
|
const AName: String);
|
||||||
|
begin
|
||||||
|
WriteInteger(ARegistry, Integer(AValue), AName);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnSwBaseSettings.WriteInteger(const ARegistry: TRegistry;
|
||||||
|
const AValue: Integer;
|
||||||
|
const AName: String);
|
||||||
|
begin
|
||||||
|
ARegistry.WriteInteger(GetKeyName(AName), AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TUnSwDialogSettings }
|
||||||
|
constructor TUnSwDialogSettings.Create(const APrefix: String);
|
||||||
|
begin
|
||||||
|
inherited Create();
|
||||||
|
|
||||||
|
FPrefix := APrefix;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TUnSwDialogSettings.GetKeyName(const AName: String): String;
|
||||||
|
begin
|
||||||
|
Result := FPrefix + AName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnSwDialogSettings.Load(const ARegistry: TRegistry);
|
||||||
|
begin
|
||||||
|
// Conversion v0.1 -> v0.2
|
||||||
|
if ARegistry.ValueExists('IncludeDataModules') then
|
||||||
|
begin
|
||||||
|
ARegistry.RenameValue('IncludeDataModules', 'UnitsIncludeDataModules');
|
||||||
|
ARegistry.RenameValue('IncludeForms', 'UnitsIncludeForms');
|
||||||
|
ARegistry.RenameValue('IncludeProjectSource', 'UnitsIncludeProjectSource');
|
||||||
|
|
||||||
|
ARegistry.RenameValue('FormsDialogHeight', 'FormsHeight');
|
||||||
|
ARegistry.RenameValue('FormsDialogWidth', 'FormsWidth');
|
||||||
|
|
||||||
|
ARegistry.RenameValue('UnitsDialogHeight', 'UnitsHeight');
|
||||||
|
ARegistry.RenameValue('UnitsDialogWidth', 'UnitsWidth');
|
||||||
|
end;
|
||||||
|
|
||||||
|
ReadBoolDef(ARegistry, FIncludeDataModules, 'IncludeDataModules');
|
||||||
|
ReadBoolDef(ARegistry, FIncludeForms, 'IncludeForms');
|
||||||
|
ReadBoolDef(ARegistry, FIncludeProjectSource, 'IncludeProjectSource');
|
||||||
|
ReadBoolDef(ARegistry, FIncludeUnits, 'IncludeUnits');
|
||||||
|
|
||||||
|
ReadIntegerDef(ARegistry, FWidth, 'Width');
|
||||||
|
ReadIntegerDef(ARegistry, FHeight, 'Height');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnSwDialogSettings.Save(const ARegistry: TRegistry);
|
||||||
|
begin
|
||||||
|
WriteBool(ARegistry, FIncludeDataModules, 'IncludeDataModules');
|
||||||
|
WriteBool(ARegistry, FIncludeForms, 'IncludeForms');
|
||||||
|
WriteBool(ARegistry, FIncludeProjectSource, 'IncludeProjectSource');
|
||||||
|
WriteBool(ARegistry, FIncludeUnits, 'IncludeUnits');
|
||||||
|
|
||||||
|
WriteInteger(ARegistry, FWidth, 'Width');
|
||||||
|
WriteInteger(ARegistry, FHeight, 'Height');
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TUnSwColorSettings }
|
||||||
|
procedure TUnSwColorSettings.Load(const ARegistry: TRegistry);
|
||||||
|
begin
|
||||||
|
ReadBoolDef(ARegistry, FEnabled, 'ColorEnabled');
|
||||||
|
ReadColorDef(ARegistry, FDataModules, 'ColorDataModules');
|
||||||
|
ReadColorDef(ARegistry, FForms, 'ColorForms');
|
||||||
|
ReadColorDef(ARegistry, FProjectSource, 'ColorProjectSource');
|
||||||
|
ReadColorDef(ARegistry, FUnits, 'ColorUnits');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnSwColorSettings.Save(const ARegistry: TRegistry);
|
||||||
|
begin
|
||||||
|
WriteBool(ARegistry, FEnabled, 'ColorEnabled');
|
||||||
|
WriteColor(ARegistry, FDataModules, 'ColorDataModules');
|
||||||
|
WriteColor(ARegistry, FForms, 'ColorForms');
|
||||||
|
WriteColor(ARegistry, FProjectSource, 'ColorProjectSource');
|
||||||
|
WriteColor(ARegistry, FUnits, 'ColorUnits');
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TUnSwSettings }
|
||||||
|
constructor TUnSwSettings.Create();
|
||||||
|
begin
|
||||||
|
inherited Create();
|
||||||
|
|
||||||
|
FRegistryKey := (BorlandIDEServices as IOTAServices).GetBaseRegistryKey() +
|
||||||
|
'\UnitSwitcher';
|
||||||
|
|
||||||
|
FColors := TUnSwColorSettings.Create();
|
||||||
|
FFormsDialog := TUnSwDialogSettings.Create('Forms');
|
||||||
|
FUnitsDialog := TUnSwDialogSettings.Create('Units');
|
||||||
|
ResetDefaults();
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TUnSwSettings.Destroy();
|
||||||
|
begin
|
||||||
|
FreeAndNil(FUnitsDialog);
|
||||||
|
FreeAndNil(FFormsDialog);
|
||||||
|
FreeAndNil(FColors);
|
||||||
|
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TUnSwSettings.ResetDefaults();
|
||||||
|
procedure ResetDialog(const ADialog: TUnSwDialogSettings);
|
||||||
|
begin
|
||||||
|
ADialog.IncludeDataModules := True;
|
||||||
|
ADialog.IncludeForms := True;
|
||||||
|
ADialog.IncludeProjectSource := True;
|
||||||
|
ADialog.IncludeUnits := True;
|
||||||
|
ADialog.Width := 300;
|
||||||
|
ADialog.Height := 425;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
ResetDialog(FFormsDialog);
|
||||||
|
ResetDialog(FUnitsDialog);
|
||||||
|
|
||||||
|
FColors.Enabled := True;
|
||||||
|
FColors.DataModules := RGB( 35, 120, 35); // Green
|
||||||
|
FColors.Forms := RGB( 50, 70, 120); // Blue
|
||||||
|
FColors.ProjectSource := RGB(120, 120, 35); // Yellow
|
||||||
|
FColors.Units := RGB(150, 35, 35); // Red
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnSwSettings.Load();
|
||||||
|
var
|
||||||
|
ideRegistry: TRegistry;
|
||||||
|
|
||||||
|
begin
|
||||||
|
ideRegistry := TRegistry.Create();
|
||||||
|
with ideRegistry do
|
||||||
|
try
|
||||||
|
RootKey := HKEY_CURRENT_USER;
|
||||||
|
if OpenKey(FRegistryKey, False) then
|
||||||
|
begin
|
||||||
|
FColors.Load(ideRegistry);
|
||||||
|
FFormsDialog.Load(ideRegistry);
|
||||||
|
FUnitsDialog.Load(ideRegistry);
|
||||||
|
CloseKey();
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Free();
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnSwSettings.Save();
|
||||||
|
var
|
||||||
|
ideRegistry: TRegistry;
|
||||||
|
|
||||||
|
begin
|
||||||
|
ideRegistry := TRegistry.Create();
|
||||||
|
with ideRegistry do
|
||||||
|
try
|
||||||
|
RootKey := HKEY_CURRENT_USER;
|
||||||
|
if OpenKey(FRegistryKey, True) then
|
||||||
|
begin
|
||||||
|
FColors.Save(ideRegistry);
|
||||||
|
FFormsDialog.Save(ideRegistry);
|
||||||
|
FUnitsDialog.Save(ideRegistry);
|
||||||
|
CloseKey();
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Free();
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
initialization
|
||||||
|
finalization
|
||||||
|
FreeAndNil(GSettings);
|
||||||
|
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user