MMBPMPrp.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:7k
- unit MMBPMPrp;
- {$I COMPILER.INC}
- interface
- uses
- {$IFDEF DELPHI6}
- DesignIntf,
- DesignEditors,
- {$ELSE}
- DsgnIntf,
- {$ENDIF}
- Windows,
- SysUtils,
- Classes,
- Controls,
- Graphics,
- TypInfo,
- MMIdxPrp,
- MMTrnPrp,
- MMBMPLst,
- MMBMPDlg,
- MMFill,
- MMCtrl,
- MMBMPLED;
- type
- {-- TMMBitmapBackIndexProperty --------------------------------------------}
- TMMBitmapBackIndexProperty = class(TIntegerProperty)
- public
- procedure Edit; override;
- function GetAttributes: TPropertyAttributes; override;
- end;
- {-- TMMBitmapListComponentEditor --------------------------------------------}
- TMMBitmapListComponentEditor = class(TComponentEditor)
- public
- procedure ExecuteVerb(Index: Integer); override;
- function GetVerb(Index: Integer): string; override;
- function GetVerbCount: Integer; override;
- end;
- {-- TMMBitmapListIndexComponentEditor ---------------------------------------}
- TMMBitmapListIndexComponentEditor = class(TComponentEditor)
- public
- procedure ExecuteVerb(Index: Integer); override;
- function GetVerb(Index: Integer): string; override;
- function GetVerbCount: Integer; override;
- end;
- {-- TMMBitmapThumbIndexProperty ---------------------------------------------}
- TMMBitmapThumbIndexProperty = class(TIntegerProperty)
- public
- procedure Edit; override;
- function GetAttributes: TPropertyAttributes; override;
- end;
- {-- TMMBitmapLEDDigitConnectEditor ----------------------------------------}
- TMMBitmapLEDDigitConnectEditor = class(TComponentProperty)
- public
- procedure GetValues(Proc: TGetStrProc); override;
- end;
- implementation
- {== TMMBitmapBackIndexProperty ================================================}
- procedure TMMBitmapBackIndexProperty.Edit;
- var
- Idx: integer;
- List: TMMBitmapList;
- Comp: TComponent;
- begin
- Comp := (GetComponent(0) as TComponent);
- Idx := (Comp as TMMCustomBitmapListcontrol).BitmapBackIndex;
- List := (Comp as TMMCustomBitmapListcontrol).BitmapList;
- if ExecuteBitmapIndexEditor(List,Idx) then
- SetOrdValue(Idx);
- end;
- {-- TMMBitmapBackIndexProperty ------------------------------------------------}
- function TMMBitmapBackIndexProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := [paMultiSelect, paDialog, paRevertable];
- end;
- {== TMMBitmapListComponentEditor ==============================================}
- procedure TMMBitmapListComponentEditor.ExecuteVerb(Index: Integer);
- begin
- with TMMBitmapListEditor.Create(nil) do
- try
- BitmapList := (Component as TMMBitmapList);
- if (ShowModal = mrOK) and (Self.Designer <> nil) then Self.Designer.Modified;
- finally
- Free;
- end;
- end;
- {-- TMMBitmapListComponentEditor ----------------------------------------------}
- function TMMBitmapListComponentEditor.GetVerb(Index: Integer): string;
- begin
- Result := 'BitmapList-Editor...';
- end;
- {-- TMMBitmapListComponentEditor ----------------------------------------------}
- function TMMBitmapListComponentEditor.GetVerbCount: Integer;
- begin
- Result := 1;
- end;
- {== TMMBitmapListIndexComponentEditor =========================================}
- procedure TMMBitmapListIndexComponentEditor.ExecuteVerb(Index: Integer);
- var
- Clr: TColor;
- Idx: integer;
- List: TMMBitmapList;
- begin
- case Index of
- 0: begin
- if (Component is TMMCustomBitmapListControl) then
- begin
- Idx := (Component as TMMCustomBitmapListControl).BitmapIndex;
- List := (Component as TMMCustomBitmapListControl).BitmapList;
- end
- else if (Component is TMMFormFill) then
- begin
- Idx := (Component as TMMFormFill).BitmapIndex;
- List := (Component as TMMFormFill).BitmapList;
- end
- else if (Component is TMMPanelFill) then
- begin
- Idx := (Component as TMMPanelFill).BitmapIndex;
- List := (Component as TMMPanelFill).BitmapList;
- end
- else exit;
- if ExecuteBitmapIndexEditor(List,Idx) then
- begin
- if (Component is TMMCustomBitmapListControl) then
- begin
- (Component as TMMCustomBitmapListControl).BitmapIndex := Idx;
- end
- else if (Component is TMMFormFill) then
- begin
- (Component as TMMFormFill).BitmapIndex := Idx;
- end
- else if (Component is TMMPanelFill) then
- begin
- (Component as TMMPanelFill).BitmapIndex := Idx;
- end
- else exit;
- if (Self.Designer <> nil) then Self.Designer.Modified;
- end;
- end;
- 1: if ExecuteTransColorEditor(TMMCustomBitmapListControl(Component),Clr) then
- begin
- TMMCustomBitmapListControl(Component).TransparentColor := Clr;
- if (Self.Designer <> nil) then Self.Designer.Modified;
- end;
- end;
- end;
- {-- TMMBitmapListIndexComponentEditor -----------------------------------------}
- function TMMBitmapListIndexComponentEditor.GetVerb(Index: Integer): string;
- begin
- case index of
- 0: Result := 'BitmapIndex-Editor...';
- 1: Result := 'Transparent-Editor...';
- end;
- end;
- {-- TMMBitmapListIndexComponentEditor -----------------------------------------}
- function TMMBitmapListIndexComponentEditor.GetVerbCount: Integer;
- begin
- Result := 1;
- if (Component is TMMCustomBitmapListControl) and
- (GetPropInfo(Component.ClassInfo, 'TransparentColor') <> nil) then
- Result := 2;
- end;
- {== TMMBitmapThumbIndexProperty ===============================================}
- procedure TMMBitmapThumbIndexProperty.Edit;
- var
- Idx: integer;
- List: TMMBitmapList;
- Comp: TComponent;
- begin
- Comp := (GetComponent(0) as TComponent);
- Idx := (Comp as TMMBitmapSlider).BitmapThumbIndex;
- List := (Comp as TMMBitmapSlider).BitmapList;
- if ExecuteBitmapIndexEditor(List,Idx) then
- SetOrdValue(Idx);
- end;
- {-- TMMBitmapThumbIndexProperty -----------------------------------------------}
- function TMMBitmapThumbIndexProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := [paMultiSelect, paDialog, paRevertable];
- end;
- {== TMMBitmapLEDDigitConnectEditor ============================================}
- procedure TMMBitmapLEDDigitConnectEditor.GetValues(Proc: TGetStrProc);
- type
- TGetStrFunc = function(const Value: string): Integer of object;
- var
- i: Integer;
- LED: TMMBitmapLEDDigit;
- Component: TComponent;
- begin
- LED := GetComponent(0) as TMMBitmapLEDDigit;
- {$IFDEF DELPHI6}
- for i := 0 to Designer.Root.ComponentCount-1 do
- {$ELSE}
- for i := 0 to Designer.Form.ComponentCount-1 do
- {$ENDIF}
- begin
- {$IFDEF DELPHI6}
- Component := Designer.Root.Components[i];
- {$ELSE}
- Component := Designer.Form.Components[i];
- {$ENDIF}
- if (Component.Name <> '') then
- if (Component is TMMBitmapLEDDigit) and (Component <> LED) then
- Proc(Component.Name);
- end;
- end;
- end.