1
0
mirror of synced 2024-11-21 19:03:51 +00:00

Added: license (before Michel starts abusing the source ;))

Fixed: Issue #127
Fixed: Issue #138
Fixed: Issue #140
Fixed: Issue #141
This commit is contained in:
Mark van Renswoude 2006-01-09 19:24:56 +00:00
parent 61a4f9c651
commit 0e475012c8
7 changed files with 165 additions and 55 deletions

View File

@ -168,9 +168,11 @@ end;
procedure TUnitSwitcherHook.NewExecute(Sender: TObject); procedure TUnitSwitcherHook.NewExecute(Sender: TObject);
var var
activeIndex: Integer; activeIndex: Integer;
project: IOTAProject;
moduleIndex: Integer;
activeUnit: TUnSwUnit; activeUnit: TUnSwUnit;
itemIndex: Integer;
moduleIndex: Integer;
project: IOTAProject;
selectedUnits: TUnSwUnitList;
unitList: TUnSwUnitList; unitList: TUnSwUnitList;
begin begin
@ -190,10 +192,15 @@ begin
if activeIndex > -1 then if activeIndex > -1 then
activeUnit := unitList[activeIndex]; activeUnit := unitList[activeIndex];
activeUnit := TfrmUnSwDialog.Execute(unitList, (Sender = FViewFormAction), selectedUnits := TfrmUnSwDialog.Execute(unitList, (Sender = FViewFormAction),
activeUnit); activeUnit);
if Assigned(activeUnit) then if Assigned(selectedUnits) then
activeUnit.Activate((Sender = FViewUnitAction)); try
for itemIndex := 0 to Pred(selectedUnits.Count) do
selectedUnits[itemIndex].Activate((Sender = FViewUnitAction));
finally
FreeAndNil(selectedUnits);
end;
finally finally
FreeAndNil(unitList); FreeAndNil(unitList);
end; end;

View File

@ -27,7 +27,6 @@ object frmUnSwConfiguration: TfrmUnSwConfiguration
ActivePage = tsGeneral ActivePage = tsGeneral
Anchors = [akLeft, akTop, akRight, akBottom] Anchors = [akLeft, akTop, akRight, akBottom]
TabOrder = 0 TabOrder = 0
ExplicitHeight = 299
object tsGeneral: TTabSheet object tsGeneral: TTabSheet
Caption = 'General' Caption = 'General'
object chkCustomColor: TCheckBox object chkCustomColor: TCheckBox
@ -263,17 +262,16 @@ object frmUnSwConfiguration: TfrmUnSwConfiguration
Caption = 'Version 0.2' Caption = 'Version 0.2'
end end
object TLabel object TLabel
Left = 56 Left = 135
Top = 106 Top = 23
Width = 145 Width = 145
Height = 13 Height = 13
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
Caption = 'Copyright '#169' 2006 X'#178'Software' Caption = 'Copyright '#169' 2006 X'#178'Software'
ExplicitTop = 196
end end
object TLabel object TLabel
Left = 56 Left = 56
Top = 130 Top = 90
Width = 225 Width = 225
Height = 41 Height = 41
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
@ -282,20 +280,34 @@ object frmUnSwConfiguration: TfrmUnSwConfiguration
'UnitSwitcher is released as open-source under the zlib/libpng OS' + 'UnitSwitcher is released as open-source under the zlib/libpng OS' +
'I-approved license. See license.txt for details.' 'I-approved license. See license.txt for details.'
WordWrap = True WordWrap = True
ExplicitTop = 220
end end
object TLabel object TLabel
Left = 56 Left = 56
Top = 56 Top = 52
Width = 225 Width = 225
Height = 29 Height = 29
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
AutoSize = False AutoSize = False
Caption = Caption =
'Many thanks to Richard L. for the idea, feedback and beta testin' + 'Many thanks to Richard Lichtendahl for the idea, feedback and be' +
'g.' 'ta testing.'
WordWrap = True WordWrap = True
end end
object lblBugReport: TLabel
Left = 56
Top = 156
Width = 75
Height = 13
Cursor = crHandPoint
Caption = 'Report a bug...'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlue
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = [fsUnderline]
ParentFont = False
OnClick = lblBugReportClick
end
end end
end end
object btnCancel: TButton object btnCancel: TButton
@ -321,7 +333,7 @@ object frmUnSwConfiguration: TfrmUnSwConfiguration
end end
object dlgColor: TColorDialog object dlgColor: TColorDialog
Options = [cdFullOpen] Options = [cdFullOpen]
Left = 8 Left = 12
Top = 216 Top = 176
end end
end end

View File

@ -28,6 +28,7 @@ type
chkCustomColor: TCheckBox; chkCustomColor: TCheckBox;
dlgColor: TColorDialog; dlgColor: TColorDialog;
imgAbout: TImage; imgAbout: TImage;
lblBugReport: TLabel;
lblDataModuleColor: TLabel; lblDataModuleColor: TLabel;
lblFormColor: TLabel; lblFormColor: TLabel;
lblProjectColor: TLabel; lblProjectColor: TLabel;
@ -37,8 +38,9 @@ type
pnlCustomColor: TPanel; pnlCustomColor: TPanel;
tsAbout: TTabSheet; tsAbout: TTabSheet;
tsGeneral: TTabSheet; tsGeneral: TTabSheet;
procedure chkCustomColorClick(Sender: TObject); procedure chkCustomColorClick(Sender: TObject);
procedure lblBugReportClick(Sender: TObject);
procedure PickColor(Sender: TObject); procedure PickColor(Sender: TObject);
private private
FLabels: array[0..3] of TLabel; FLabels: array[0..3] of TLabel;
@ -53,6 +55,9 @@ type
implementation implementation
uses uses
ShellAPI,
Windows,
UnSwSettings; UnSwSettings;
{$R *.dfm} {$R *.dfm}
@ -86,6 +91,11 @@ begin
end; end;
procedure TfrmUnSwConfiguration.lblBugReportClick(Sender: TObject);
begin
ShellExecute(0, 'open', 'http://projects.kamadev.net/', nil, nil, SW_SHOWNORMAL);
end;
procedure TfrmUnSwConfiguration.LoadSettings(); procedure TfrmUnSwConfiguration.LoadSettings();
begin begin
chkCustomColor.Checked := Settings.Colors.Enabled; chkCustomColor.Checked := Settings.Colors.Enabled;

View File

@ -27,6 +27,7 @@ object frmUnSwDialog: TfrmUnSwDialog
OldCreateOrder = False OldCreateOrder = False
Position = poScreenCenter Position = poScreenCenter
OnResize = FormResize OnResize = FormResize
OnShow = FormShow
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 13 TextHeight = 13
object sbStatus: TStatusBar object sbStatus: TStatusBar
@ -48,8 +49,6 @@ object frmUnSwDialog: TfrmUnSwDialog
BevelOuter = bvNone BevelOuter = bvNone
BorderWidth = 4 BorderWidth = 4
TabOrder = 0 TabOrder = 0
ExplicitWidth = 299
ExplicitHeight = 317
object pnlSearch: TPanel object pnlSearch: TPanel
Left = 4 Left = 4
Top = 4 Top = 4
@ -80,6 +79,7 @@ object frmUnSwDialog: TfrmUnSwDialog
Style = lbVirtualOwnerDraw Style = lbVirtualOwnerDraw
Align = alClient Align = alClient
ItemHeight = 20 ItemHeight = 20
MultiSelect = True
TabOrder = 1 TabOrder = 1
OnData = lstUnitsData OnData = lstUnitsData
OnDblClick = lstUnitsDblClick OnDblClick = lstUnitsDblClick
@ -572,4 +572,13 @@ object frmUnSwDialog: TfrmUnSwDialog
E003E003FFFFF000E007E007FFFFF00000000000000000000000000000000000 E003E003FFFFF000E007E007FFFFF00000000000000000000000000000000000
000000000000} 000000000000}
end end
object alMain: TActionList
Left = 36
Top = 32
object actSelectAll: TAction
Caption = 'Select &All'
ShortCut = 16449
OnExecute = actSelectAllExecute
end
end
end end

View File

@ -8,6 +8,7 @@ unit UnSwDialog;
interface interface
uses uses
ActnList,
Classes, Classes,
ComCtrls, ComCtrls,
Controls, Controls,
@ -49,6 +50,10 @@ type
pnlMain: TPanel; pnlMain: TPanel;
pnlSearch: TPanel; pnlSearch: TPanel;
sbStatus: TStatusBar; sbStatus: TStatusBar;
alMain: TActionList;
actSelectAll: TAction;
procedure FormShow(Sender: TObject);
procedure actSelectAllExecute(Sender: TObject);
procedure FormResize(Sender: TObject); procedure FormResize(Sender: TObject);
procedure btnConfigurationClick(Sender: TObject); procedure btnConfigurationClick(Sender: TObject);
@ -72,18 +77,18 @@ type
FStyleVisitor: TUnSwStyleVisitor; FStyleVisitor: TUnSwStyleVisitor;
function InternalExecute(): TUnSwUnit; function InternalExecute(): TUnSwUnitList;
procedure UpdateTypeFilter(); procedure UpdateTypeFilter();
procedure UpdateList(); procedure UpdateList();
function GetActiveUnit(): TUnSwUnit; function GetActiveUnits(): TUnSwUnitList;
procedure LoadSettings(); procedure LoadSettings();
procedure SaveSettings(); procedure SaveSettings();
public public
class function Execute(const AUnits: TUnSwUnitList; class function Execute(const AUnits: TUnSwUnitList;
const AFormsOnly: Boolean; const AFormsOnly: Boolean;
const AActive: TUnSwUnit = nil): TUnSwUnit; const AActive: TUnSwUnit = nil): TUnSwUnitList;
end; end;
implementation implementation
@ -133,7 +138,7 @@ end;
{ TfrmUnSwDialog } { TfrmUnSwDialog }
class function TfrmUnSwDialog.Execute(const AUnits: TUnSwUnitList; class function TfrmUnSwDialog.Execute(const AUnits: TUnSwUnitList;
const AFormsOnly: Boolean; const AFormsOnly: Boolean;
const AActive: TUnSwUnit): TUnSwUnit; const AActive: TUnSwUnit): TUnSwUnitList;
begin begin
with Self.Create(nil) do with Self.Create(nil) do
try try
@ -151,12 +156,18 @@ begin
lstUnits.Invalidate(); lstUnits.Invalidate();
end; end;
procedure TfrmUnSwDialog.FormShow(Sender: TObject);
begin
// Setting ListBox.Selected[x] won't work before OnShow...
UpdateTypeFilter();
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)
end; end;
function TfrmUnSwDialog.InternalExecute(): TUnSwUnit; function TfrmUnSwDialog.InternalExecute(): TUnSwUnitList;
begin begin
Result := nil; Result := nil;
FTypeFilteredList := TUnSwUnitList.Create(); FTypeFilteredList := TUnSwUnitList.Create();
@ -177,12 +188,10 @@ begin
end else end else
Self.Caption := 'UnitSwitcher - View Unit'; Self.Caption := 'UnitSwitcher - View Unit';
UpdateTypeFilter();
FStyleVisitor := TUnSwStyleVisitor.Create(); FStyleVisitor := TUnSwStyleVisitor.Create();
try try
if Self.ShowModal() = mrOk then if Self.ShowModal() = mrOk then
Result := GetActiveUnit(); Result := GetActiveUnits();
SaveSettings(); SaveSettings();
finally finally
@ -199,9 +208,12 @@ end;
procedure TfrmUnSwDialog.UpdateList(); procedure TfrmUnSwDialog.UpdateList();
var var
activeUnit: TUnSwUnit; activeUnit: TUnSwUnit;
activeUnits: TUnSwUnitList;
itemIndex: Integer;
listIndex: Integer;
begin begin
activeUnit := GetActiveUnit(); activeUnits := GetActiveUnits();
FInputFilteredList.Clone(FTypeFilteredList); FInputFilteredList.Clone(FTypeFilteredList);
FInputFilteredList.AcceptVisitor(FInputFilter); FInputFilteredList.AcceptVisitor(FInputFilter);
@ -209,11 +221,21 @@ begin
lstUnits.Count := FInputFilteredList.Count; lstUnits.Count := FInputFilteredList.Count;
if FInputFilteredList.Count > 0 then if FInputFilteredList.Count > 0 then
begin begin
if Assigned(activeUnit) then lstUnits.ClearSelection();
lstUnits.ItemIndex := FInputFilteredList.IndexOf(activeUnit);
if lstUnits.ItemIndex = -1 then if Assigned(activeUnits) then
lstUnits.ItemIndex := 0; try
for itemIndex := 0 to Pred(activeUnits.Count) do
begin
activeUnit := activeUnits[itemIndex];
listIndex := FInputFilteredList.IndexOf(activeUnit);
if listIndex > -1 then
lstUnits.Selected[listIndex] := True;
end;
finally
FreeAndNil(activeUnits);
end else
lstUnits.Selected[0] := True;
end; end;
end; end;
@ -230,15 +252,27 @@ begin
UpdateList(); UpdateList();
end; end;
function TfrmUnSwDialog.GetActiveUnit(): TUnSwUnit; function TfrmUnSwDialog.GetActiveUnits(): TUnSwUnitList;
var
itemIndex: Integer;
begin begin
Result := FActiveUnit; Result := nil;
if not Assigned(Result) then
if Assigned(FActiveUnit) then
begin begin
if lstUnits.ItemIndex > -1 then Result := TUnSwUnitList.Create();
Result := FInputFilteredList[lstUnits.ItemIndex]; Result.OwnsObjects := False;
end else Result.Add(FActiveUnit);
FActiveUnit := nil; FActiveUnit := nil;
end else if lstUnits.SelCount > 0 then
begin
Result := TUnSwUnitList.Create();
Result.OwnsObjects := False;
for itemIndex := 0 to Pred(lstUnits.Items.Count) do
if lstUnits.Selected[itemIndex] then
Result.Add(FInputFilteredList[itemIndex]);
end;
end; end;
@ -286,6 +320,11 @@ begin
end; end;
procedure TfrmUnSwDialog.actSelectAllExecute(Sender: TObject);
begin
lstUnits.SelectAll();
end;
procedure TfrmUnSwDialog.btnConfigurationClick(Sender: TObject); procedure TfrmUnSwDialog.btnConfigurationClick(Sender: TObject);
begin begin
if TfrmUnSwConfiguration.Execute() then if TfrmUnSwConfiguration.Execute() then
@ -301,7 +340,9 @@ end;
procedure TfrmUnSwDialog.edtSearchKeyDown(Sender: TObject; var Key: Word; procedure TfrmUnSwDialog.edtSearchKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState); Shift: TShiftState);
begin begin
if (Shift = []) and (Key in [VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT]) then if ((Shift = []) and (Key in [VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT])) or
((Shift = [ssCtrl]) and (Key in [VK_UP, VK_DOWN, VK_HOME, VK_END])) or
((Shift = [ssShift]) and (Key in [VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT])) then
lstUnits.Perform(WM_KEYDOWN, Key, 0); lstUnits.Perform(WM_KEYDOWN, Key, 0);
end; end;

View File

@ -115,6 +115,9 @@ type
private private
FItems: TObjectList; FItems: TObjectList;
function GetOwnsObjects(): Boolean;
procedure SetOwnsObjects(const Value: Boolean);
function GetCount(): Integer; function GetCount(): Integer;
function GetItem(Index: Integer): TUnSwUnit; function GetItem(Index: Integer): TUnSwUnit;
procedure SetItem(Index: Integer; Value: TUnSwUnit); procedure SetItem(Index: Integer; Value: TUnSwUnit);
@ -136,6 +139,8 @@ type
property Count: Integer read GetCount; property Count: Integer read GetCount;
property Items[Index: Integer]: TUnSwUnit read GetItem property Items[Index: Integer]: TUnSwUnit read GetItem
write SetItem; default; write SetItem; default;
property OwnsObjects: Boolean read GetOwnsObjects
write SetOwnsObjects;
end; end;
implementation implementation
@ -179,35 +184,28 @@ end;
procedure TUnSwUnit.OpenModule(const AModule: IOTAModule; const ASource: Boolean); procedure TUnSwUnit.OpenModule(const AModule: IOTAModule; const ASource: Boolean);
{$IFDEF DELPHI7}
var var
editor: IOTAEditor; editor: IOTAEditor;
formEditor: IOTAFormEditor; formEditor: IOTAFormEditor;
isForm: Boolean;
moduleIndex: Integer; moduleIndex: Integer;
{$ENDIF}
begin begin
{$IFDEF DELPHI7} formEditor := nil;
for moduleIndex := 0 to Pred(AModule.ModuleFileCount) do for moduleIndex := 0 to Pred(AModule.ModuleFileCount) do
begin begin
editor := AModule.ModuleFileEditors[moduleIndex]; editor := AModule.ModuleFileEditors[moduleIndex];
isForm := Supports(editor, IOTAFormEditor);
if not ASource then if (not ASource) and (isForm) and (not Assigned(formEditor)) then
begin formEditor := (editor as IOTAFormEditor);
if not Assigned(formEditor) then
Supports(editor, IOTAFormEditor, formEditor); if not isForm then
end else
editor.Show(); editor.Show();
end; end;
if Assigned(formEditor) then if Assigned(formEditor) then
formEditor.Show(); formEditor.Show();
{$ELSE}
if ASource then
AModule.ShowFilename(AModule.FileName)
else
AModule.Show();
{$ENDIF}
end; end;
@ -411,4 +409,14 @@ begin
FItems[Index] := Value; FItems[Index] := Value;
end; end;
function TUnSwUnitList.GetOwnsObjects(): Boolean;
begin
Result := FItems.OwnsObjects;
end;
procedure TUnSwUnitList.SetOwnsObjects(const Value: Boolean);
begin
FItems.OwnsObjects := Value;
end;
end. end.

23
license.txt Normal file
View File

@ -0,0 +1,23 @@
UnitSwitcher is released under the zlib/libpng OSI-approved license.
For more information: http://www.opensource.org/
Copyright (c) 2006 X2Software
http://www.x2software.net/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from
the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software in a
product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.