home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
cb
/
setup
/
cbuilder
/
data.z
/
WIN31REG.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-02-28
|
3KB
|
139 lines
unit Win31Reg;
interface
uses DsgnIntf, Classes, Forms;
type
TTabPageNameProperty = class(TPropertyEditor)
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
function GetValue: string; override;
procedure SetValue(const AValue: string); override;
end;
TTabPageListProperty = class(TPropertyEditor)
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure Edit; override;
end;
TTabbedNotebookEditor = class(TDefaultEditor)
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
procedure Register;
implementation
uses SysUtils, ExtCtrls, Tabs, NoteBReg, TabNotBk, PageEdit, Outline, LibConst;
{ TTabPageNameProperty }
function TTabPageNameProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList];
end;
procedure TTabPageNameProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
Notebook: TTabbedNotebook;
Page: TTabPage;
begin
Notebook := GetComponent(0) as TTabbedNotebook;
for I := 0 to Notebook.Pages.Count - 1 do
begin
Page := Notebook.Pages.Objects[I] as TTabPage;
Proc(Page.Caption);
end;
end;
function TTabPageNameProperty.GetValue: string;
begin
Result := GetStrValue;
end;
procedure TTabPageNameProperty.SetValue(const AValue: string);
begin
SetStrValue(AValue);
end;
{ TTabPageListProperty }
function TTabPageListProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TTabPageListProperty.GetValue: string;
begin
FmtStr(Result, '(%s)', [GetPropType^.Name]);
end;
procedure TTabPageListProperty.Edit;
var
D: TNotebookEditDlg;
begin
D := TNotebookEditDlg.Create(Application);
try
D.SetPageList(TStringList(GetOrdValue));
D.ShowModal;
if D.Modified then Designer.Modified;
finally
D.Free;
end;
end;
{ TNotebookEditor }
const
Verbs: array[0..1] of Word = (SNextPage, SPrevPage);
procedure TTabbedNotebookEditor.ExecuteVerb(Index: Integer);
var
NewPage: Integer;
begin
with TTabbedNotebook(Component) do
begin
NewPage := PageIndex;
if Index = 0 then
Inc(NewPage) else
Dec(NewPage);
if NewPage < 0 then NewPage := Pages.Count
else if NewPage >= Pages.Count then NewPage := 0;
if NewPage <> PageIndex then
begin
PageIndex := NewPage;
Designer.Modified;
end;
end;
end;
function TTabbedNotebookEditor.GetVerb(Index: Integer): string;
begin
Result := LoadStr(Verbs[Index]);
end;
function TTabbedNotebookEditor.GetVerbCount: Integer;
begin
Result := High(Verbs) + 1;
end;
procedure Register;
begin
RegisterComponents(LoadStr(srWin31), [TTabSet, TOutline,
THeader, TTabbedNotebook, TNotebook]);
RegisterComponentEditor(TNotebook, TNotebookEditor);
RegisterComponentEditor(TTabbedNotebook, TTabbedNotebookEditor);
RegisterPropertyEditor(TypeInfo(string), TNotebook, 'ActivePage', TPageNameProperty);
RegisterPropertyEditor(TypeInfo(TStrings), TNotebook, 'Pages', TPageListProperty);
RegisterPropertyEditor(TypeInfo(string), TTabbedNotebook, 'ActivePage', TTabPageNameProperty);
RegisterPropertyEditor(TypeInfo(TStrings), TTabbedNotebook, 'Pages', TTabPageListProperty);
end;
end.