|
@@ -10,9 +10,9 @@ uses
|
|
|
|
|
|
type
|
|
|
|
|
|
- { TDemoCombobox }
|
|
|
+ { TCustomDemoCombobox }
|
|
|
|
|
|
- TDemoCombobox = class(TDiv,IFPObserver)
|
|
|
+ TCustomDemoCombobox = class(TDiv,IFPObserver)
|
|
|
private
|
|
|
FItemIndex: integer;
|
|
|
FItems: TStrings;
|
|
@@ -86,32 +86,41 @@ type
|
|
|
procedure UpdateItems; virtual;
|
|
|
procedure UpdateCaption; virtual;
|
|
|
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
|
|
- published
|
|
|
property Items: TStrings read FItems write SetItems;
|
|
|
property ItemIndex: integer read FItemIndex write SetItemIndex;
|
|
|
property Caption: string read GetCaption write SetCaption;
|
|
|
end;
|
|
|
|
|
|
+ { TDemoCombobox }
|
|
|
+
|
|
|
+ TDemoCombobox = class(TCustomDemoCombobox)
|
|
|
+ published
|
|
|
+ property OnChange;
|
|
|
+ property Items;
|
|
|
+ property ItemIndex;
|
|
|
+ property Caption;
|
|
|
+ end;
|
|
|
+
|
|
|
implementation
|
|
|
|
|
|
{$I fresnel.democombobox.inc}
|
|
|
|
|
|
-{ TDemoCombobox }
|
|
|
+{ TCustomDemoCombobox }
|
|
|
|
|
|
-procedure TDemoCombobox.SetItems(const AValue: TStrings);
|
|
|
+procedure TCustomDemoCombobox.SetItems(const AValue: TStrings);
|
|
|
begin
|
|
|
if (FItems=AValue) or FItems.Equals(AValue) then Exit;
|
|
|
- FItems:=AValue;
|
|
|
+ FItems.Assign(AValue);
|
|
|
UpdateItems;
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.DoChange;
|
|
|
+procedure TCustomDemoCombobox.DoChange;
|
|
|
begin
|
|
|
if Assigned(OnChange) then
|
|
|
OnChange(Self);
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.SetName(const NewName: TComponentName);
|
|
|
+procedure TCustomDemoCombobox.SetName(const NewName: TComponentName);
|
|
|
var
|
|
|
WasCaption: Boolean;
|
|
|
begin
|
|
@@ -121,7 +130,7 @@ begin
|
|
|
Caption:=NewName;
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.Notification(AComponent: TComponent; Operation: TOperation);
|
|
|
+procedure TCustomDemoCombobox.Notification(AComponent: TComponent; Operation: TOperation);
|
|
|
begin
|
|
|
inherited Notification(AComponent, Operation);
|
|
|
if Operation=opRemove then
|
|
@@ -139,7 +148,7 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.Loaded;
|
|
|
+procedure TCustomDemoCombobox.Loaded;
|
|
|
begin
|
|
|
inherited Loaded;
|
|
|
if FItemIndex>=Content.NodeCount then
|
|
@@ -150,7 +159,7 @@ begin
|
|
|
UpdateCaption;
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.FPOObservedChanged(ASender: TObject; Operation: TFPObservedOperation;
|
|
|
+procedure TCustomDemoCombobox.FPOObservedChanged(ASender: TObject; Operation: TFPObservedOperation;
|
|
|
Data: Pointer);
|
|
|
begin
|
|
|
if ASender=FItems then
|
|
@@ -159,7 +168,7 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.SetItemIndex(const AValue: integer);
|
|
|
+procedure TCustomDemoCombobox.SetItemIndex(const AValue: integer);
|
|
|
begin
|
|
|
if FItemIndex=AValue then Exit;
|
|
|
if (csDestroying in ComponentState) or (Content=nil) then exit;
|
|
@@ -178,7 +187,7 @@ begin
|
|
|
UpdateCaption;
|
|
|
end;
|
|
|
|
|
|
-function TDemoCombobox.GetCaption: string;
|
|
|
+function TCustomDemoCombobox.GetCaption: string;
|
|
|
begin
|
|
|
if CaptionLabel<>nil then
|
|
|
Result:=CaptionLabel.Caption
|
|
@@ -186,7 +195,7 @@ begin
|
|
|
Result:='';
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.DoItemClick(Event: TAbstractEvent);
|
|
|
+procedure TCustomDemoCombobox.DoItemClick(Event: TAbstractEvent);
|
|
|
var
|
|
|
Item: TFresnelElement;
|
|
|
begin
|
|
@@ -201,7 +210,7 @@ begin
|
|
|
Menu.SetStyleAttr('display','none');
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.DoCaptionDivClick(Event: TAbstractEvent);
|
|
|
+procedure TCustomDemoCombobox.DoCaptionDivClick(Event: TAbstractEvent);
|
|
|
begin
|
|
|
if Event=nil then ;
|
|
|
if Menu.GetStyleAttr('display')='none' then
|
|
@@ -210,13 +219,13 @@ begin
|
|
|
Menu.SetStyleAttr('display','none');
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.SetCaption(const AValue: string);
|
|
|
+procedure TCustomDemoCombobox.SetCaption(const AValue: string);
|
|
|
begin
|
|
|
if CaptionLabel<>nil then
|
|
|
CaptionLabel.Caption:=AValue;
|
|
|
end;
|
|
|
|
|
|
-constructor TDemoCombobox.Create(AOwner: TComponent);
|
|
|
+constructor TCustomDemoCombobox.Create(AOwner: TComponent);
|
|
|
var
|
|
|
aStream: TMemoryStream;
|
|
|
begin
|
|
@@ -275,14 +284,14 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-destructor TDemoCombobox.Destroy;
|
|
|
+destructor TCustomDemoCombobox.Destroy;
|
|
|
begin
|
|
|
FItemIndex:=-1;
|
|
|
FreeAndNil(FItems);
|
|
|
inherited Destroy;
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.Clear;
|
|
|
+procedure TCustomDemoCombobox.Clear;
|
|
|
begin
|
|
|
FItemIndex:=-1;
|
|
|
FItems.Clear;
|
|
@@ -291,12 +300,12 @@ begin
|
|
|
SetCaption(' ');
|
|
|
end;
|
|
|
|
|
|
-class function TDemoCombobox.GetCSSTypeStyle: TCSSString;
|
|
|
+class function TCustomDemoCombobox.GetCSSTypeStyle: TCSSString;
|
|
|
begin
|
|
|
Result:=cStyle;
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.UpdateItems;
|
|
|
+procedure TCustomDemoCombobox.UpdateItems;
|
|
|
var
|
|
|
i: Integer;
|
|
|
ItemCaption: String;
|
|
@@ -338,7 +347,7 @@ begin
|
|
|
UpdateCaption;
|
|
|
end;
|
|
|
|
|
|
-procedure TDemoCombobox.UpdateCaption;
|
|
|
+procedure TCustomDemoCombobox.UpdateCaption;
|
|
|
begin
|
|
|
if (FItemIndex>=0) then
|
|
|
SetCaption(FItems[FItemIndex])
|