home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 October
/
Chip_2001-10_cd1.bin
/
zkuste
/
delphi
/
nastroje
/
d3456
/
KBMWABD.ZIP
/
WABD_PropEditors.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1999-05-06
|
10KB
|
399 lines
unit WABD_PropEditors;
interface
uses SysUtils, Windows, Dialogs, Classes;
procedure Register;
implementation
uses WABD_About, WABD_Objects, WABD_FormEditor, WABD_FramesetEditor, WABD_TableStrEditor, WABD_TreeEditor,
WABD_HotSpotEditor, DsgnIntf, WABD_StrListEditor;
var
FormEditor : TWABDFormEditor;
FramesetEditor : TWABDFramesetEditor;
HotSpotEditor : THSEditForm;
TreeEditor : TWABDTreeEditor;
type
TWABD_Form_Comp_Editor = class(TComponentEditor)
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
public
procedure DesignForm;
end;
TTable_Strings_Editor = class(TPropertyEditor)
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
TString_List_Editor = class(TPropertyEditor)
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
TWABDEditFormProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
function GetName: string; override;
end;
TWABDEditFramesetProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
function GetName: string; override;
end;
TWABDEditTreeNodes = class(TComponentEditor)
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
public
procedure DesignForm;
end;
TWABDEditTreeProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
function GetName: string; override;
end;
TWABDHotSpotProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
TWABDFileNameProperty = class(TStringProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
TWABDJSFunctionProperty = class(TClassProperty)
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
// ************************************************************************
procedure TWABD_Form_Comp_Editor.DesignForm;
begin
if FormEditor=nil then FormEditor := TWABDFormEditor.Create(nil);
FormEditor.WABDForm := Component as TWABD_Form;
FormEditor.Designer := Designer;
FormEditor.Initialize;
FormEditor.Show;
end;
procedure TWABD_Form_Comp_Editor.ExecuteVerb(Index: Integer);
begin
case Index of
0: DesignForm;
end;
end;
function TWABD_Form_Comp_Editor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := '&Design WABD Form...';
end;
end;
function TWABD_Form_Comp_Editor.GetVerbCount: Integer;
begin
Result := 1;
end;
// ************************************************************************
procedure TTable_Strings_Editor.Edit;
var
d : TTableStrings_Editor;
begin
d := TTableStrings_Editor.Create(nil);
try
d.EditStrings(TWABD_Table_Strings(GetOrdValue));
SetOrdValue(GetOrdValue);
finally
d.Free;
end;
end;
function TTable_Strings_Editor.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TTable_Strings_Editor.GetValue: string;
begin
Result := '(Table Strings)';
end;
// ************************************************************************
procedure TString_List_Editor.Edit;
var
d : TStringList_Editor;
S: TStrings;
n: Integer;
begin
d := TStringList_Editor.Create(nil);
try
S := TStrings(Pointer(GetOrdValue));
D.Caption := 'Edit - '+ GetName;
D.Memo.Lines.Text := S.Text;
D.ShowModal;
for n := 0 to PropCount-1 do begin
S := TStrings(Pointer(GetOrdValueAt(n)));
S.Text := D.Memo.Lines.Text;
end;
try
Modified;
except
end;
finally
d.Free;
end;
end;
function TString_List_Editor.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TString_List_Editor.GetValue: string;
begin
Result := '(Strings)';
end;
// ************************************************************************
function TWABDEditFormProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TWABDEditFormProperty.GetValue: string;
begin
Result := '(Click_Me)';
end;
function TWABDEditFormProperty.GetName: string;
begin
Result := 'Edit Form';
end;
procedure TWABDEditFormProperty.Edit;
begin
if FormEditor=nil then FormEditor := TWABDFormEditor.Create(nil);
FormEditor.WABDForm := TWABDEditForm(GetOrdValue).ParForm;
FormEditor.Designer := Designer;
FormEditor.Initialize;
FormEditor.Show;
end;
// ************************************************************************
function TWABDEditFramesetProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TWABDEditFramesetProperty.GetValue: string;
begin
Result := '(Click_Me)';
end;
function TWABDEditFramesetProperty.GetName: string;
begin
Result := 'Edit Frameset';
end;
procedure TWABDEditFramesetProperty.Edit;
begin
if FramesetEditor=nil then FramesetEditor := TWABDFramesetEditor.Create(nil);
FramesetEditor.WABDFrameset := TWABDEditFrameset(GetOrdValue).ParFrameset;
FramesetEditor.Designer := Designer;
FramesetEditor.Initialize;
FramesetEditor.Show;
end;
// ************************************************************************
procedure TWABDEditTreeNodes.DesignForm;
begin
if TreeEditor=nil then TreeEditor := TWABDTreeEditor.Create(nil);
TreeEditor.ParTree := Component as TWABD_Tree;
TreeEditor.Designer := Designer;
TreeEditor.Init;
TreeEditor.Show;
end;
procedure TWABDEditTreeNodes.ExecuteVerb(Index: Integer);
begin
case Index of
0: DesignForm;
end;
end;
function TWABDEditTreeNodes.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := '&Design WABD Tree structure...';
end;
end;
function TWABDEditTreeNodes.GetVerbCount: Integer;
begin
Result := 1;
end;
// ************************************************************************
function TWABDEditTreeProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TWABDEditTreeProperty.GetValue: string;
begin
Result := '(Click_Me)';
end;
function TWABDEditTreeProperty.GetName: string;
begin
Result := 'Edit Tree';
end;
procedure TWABDEditTreeProperty.Edit;
begin
if TreeEditor=nil then TreeEditor := TWABDTreeEditor.Create(nil);
TreeEditor.Designer := Designer;
TreeEditor.ParTree := TWABDEditTree(GetOrdValue).ParTree;
TreeEditor.Init;
TreeEditor.Show;
end;
// ************************************************************************
procedure TWABDHotSpotProperty.Edit;
begin
if HotSpotEditor=nil then HotSpotEditor := THSEditForm.Create(nil);
HotSpotEditor.Designer := Designer;
HotSpotEditor.ParImage := TWABD_HotSpots(GetOrdValue).ParImage;
HotSpotEditor.Init;
HotSpotEditor.Show;
end;
function TWABDHotSpotProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TWABDHotSpotProperty.GetValue: string;
begin
Result := '(Click_Me)';
end;
// ************************************************************************
function TWABDJSFunctionProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paSubProperties,paReadOnly];
end;
function TWABDJSFunctionProperty.GetValue: string;
var
p:pointer;
f:TWABD_JS_Function;
begin
p:=Pointer(GetOrdValue);
if (p = nil) then Result:=''
else begin
f:=TWABD_JS_Function(p);
Result:=f.Script;
end;
end;
// ************************************************************************
procedure TWABDFileNameProperty.Edit;
var
fo: TOpenDialog;
begin
fo := TOpenDialog.Create(nil);
fo.Filename := GetValue;
fo.Options := [ofPathMustExist,ofFileMustExist];
try
if fo.Execute then SetValue(fo.Filename);
finally
fo.Free;
end;
end;
function TWABDFileNameProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TWABDFileNameProperty.GetValue: string;
begin
Result := GetStrValue;
end;
// ************************************************************************
procedure Register;
begin
RegisterComponentEditor(TWABD_Form, TWABD_Form_Comp_Editor);
RegisterPropertyEditor(TypeInfo(TWABD_Table_Strings), nil, '', TTable_Strings_Editor);
RegisterPropertyEditor(TypeInfo(TStrings), nil, '', TString_List_Editor);
RegisterPropertyEditor(TypeInfo(TWABDAbout), NIL, '', TWABDAboutProperty);
RegisterPropertyEditor(TypeInfo(TWABDEditForm), NIL, '', TWABDEditFormProperty);
RegisterPropertyEditor(TypeInfo(TWABDEditFrameset), NIL, '', TWABDEditFramesetProperty);
RegisterPropertyEditor(TypeInfo(TWABD_HotSpots), NIL, '', TWABDHotSpotProperty);
RegisterPropertyEditor(TypeInfo(TFileName), TWABD_Base_Image, '', TWABDFileNameProperty);
RegisterPropertyEditor(TypeInfo(TWABD_JS_Function), nil, '', TWABDJSFunctionProperty);
RegisterComponentEditor(TWABD_Tree, TWABDEditTreeNodes);
RegisterPropertyEditor(TypeInfo(TWABDEditTree), NIL, '', TWABDEditTreeProperty);
end;
initialization
FormEditor := nil;
FramesetEditor := nil;
HotSpotEditor := nil;
TreeEditor := nil;
finalization
FormEditor.Free;
FramesetEditor.Free;
HotSpotEditor.Free;
TreeEditor.Free;
end.