Все даже работает в рантайме как надо. Но вот в дизайнере хотелось бы чтобы редактором для ImageIndex выступал список изображений, как в TMenuItem и проч... А сейчас там только пустой список Хееелллпппп
Здравствуйте, AlexEagle, Вы писали:
AE>Создал компонент, добавил два свойства:
AE>- Images: TCustomImageList AE>- ImageIndex: TImageIndex
AE>Все даже работает в рантайме как надо. Но вот в дизайнере хотелось бы чтобы редактором для ImageIndex выступал список изображений, как в TMenuItem и проч... А сейчас там только пустой список Хееелллпппп
Я правда сам не пробовал, но скорее всего нужно реализовать в редакторе интерфейс ICustomPropertyListDrawing.
Здравствуйте, AlexEagle, Вы писали:
AE>Создал компонент, добавил два свойства:
AE>- Images: TCustomImageList AE>- ImageIndex: TImageIndex
AE>Все даже работает в рантайме как надо. Но вот в дизайнере хотелось бы чтобы редактором для ImageIndex выступал список изображений, как в TMenuItem и проч... А сейчас там только пустой список Хееелллпппп
Возми Toolbar2000 с www.jrsoftware.org
Открой файл TB2Reg.pas
Смотри реализацию класса TTBImageIndexPropertyEditor.
Здравствуйте, AlexEagle, Вы писали:
A>>Я правда сам не пробовал, но скорее всего нужно реализовать в редакторе интерфейс ICustomPropertyListDrawing.
AE>тут поиск тоже молчит
Это я что-то не то ляпнул По идее должно отрисовываться. Посмотри как сделано у TToolBar.
Здравствуйте, alive, Вы писали:
A>Здравствуйте, AlexEagle, Вы писали:
A>>>Я правда сам не пробовал, но скорее всего нужно реализовать в редакторе интерфейс ICustomPropertyListDrawing.
AE>>тут поиск тоже молчит
A>Это я что-то не то ляпнул По идее должно отрисовываться. Посмотри как сделано у TToolBar.
перед тем как сюда запостить я попытался посмотреть и у тулбара и у меню
Здравствуйте, AlexEagle, Вы писали:
AE>Здравствуйте, vlad_gri, Вы писали:
_>>Смотри реализацию класса TTBImageIndexPropertyEditor.
AE>Первые строчки уже впечатляют
AE>
AE>{ Unfortunately TComponentImageIndexPropertyEditor seems to be gone in
AE> Delphi 6, so we have to use our own image index property editor class }
AE>
Что-же там такого впечатлительного.
Jordan жалуется что не смог найти в Delphi 6
стандартного TComponentImageIndexPropertyEditor и ему пришлось использовать свой.
Здравствуйте, vlad_gri, Вы писали:
_>Что-же там такого впечатлительного. _>Jordan жалуется что не смог найти в Delphi 6 _>стандартного TComponentImageIndexPropertyEditor и ему пришлось использовать свой.
Об этом и говорю — наткнулся на нужный след... Но лыжи ( надеюсь ) опять стали... Вот наваял:
unit ExPropEditors;
interface
uses classes, types, DesignIntf, DesignEditors, VCLEditors, ImgList, Graphics;
type
TExImageIndexPropertyEditor = class(TIntegerProperty, ICustomPropertyListDrawing )
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
function GetImageListAt(Index: Integer): TCustomImageList; virtual;
// ICustomPropertyListDrawingprocedure ListMeasureHeight(const Value: string; ACanvas: TCanvas;
var AHeight: Integer);
procedure ListMeasureWidth(const Value: string; ACanvas: TCanvas;
var AWidth: Integer);
procedure ListDrawValue(const Value: string; ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean);
end;
TExButtonImageIndexPropertyEditor = class(TExImageIndexPropertyEditor)
public
function GetImageListAt(Index: Integer): TCustomImageList; override;
end;
implementation
uses SysUtils, ExButton;
function TExImageIndexPropertyEditor.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList, paRevertable];
end;
function TExImageIndexPropertyEditor.GetImageListAt(Index: Integer): TCustomImageList;
begin
Result := nil;
end;
procedure TExImageIndexPropertyEditor.GetValues(Proc: TGetStrProc);
var
ImgList: TCustomImageList;
I: Integer;
begin
ImgList := GetImageListAt(0);
if Assigned(ImgList) then
for I := 0 to ImgList.Count-1 do
Proc(IntToStr(I));
end;
procedure TExImageIndexPropertyEditor.ListDrawValue(const Value: string;
ACanvas: TCanvas; const ARect: TRect; ASelected: Boolean);
var
ImgList: TCustomImageList;
X: Integer;
begin
ImgList := GetImageListAt(0);
ACanvas.FillRect(ARect);
X := ARect.Left + 2;
if Assigned(ImgList) then begin
ImgList.Draw(ACanvas, X, ARect.Top + 2, StrToInt(Value));
Inc(X, ImgList.Width);
end;
ACanvas.TextOut(X + 3, ARect.Top + 1, Value);
end;
procedure TExImageIndexPropertyEditor.ListMeasureHeight(const Value: string;
ACanvas: TCanvas; var AHeight: Integer);
var
ImgList: TCustomImageList;
begin
ImgList := GetImageListAt(0);
AHeight := ACanvas.TextHeight(Value) + 2;
if Assigned(ImgList) and (ImgList.Height + 4 > AHeight) then
AHeight := ImgList.Height + 4;
end;
procedure TExImageIndexPropertyEditor.ListMeasureWidth(const Value: string;
ACanvas: TCanvas; var AWidth: Integer);
var
ImgList: TCustomImageList;
begin
ImgList := GetImageListAt(0);
AWidth := ACanvas.TextWidth(Value) + 4;
if Assigned(ImgList) then
Inc(AWidth, ImgList.Width);
end;
function TExButtonImageIndexPropertyEditor.GetImageListAt(Index: Integer): TCustomImageList;
var
C: TPersistent;
Item: TExButton;
begin
Result := nil;
{ ? I'm guessing that the Index parameter is a component index (one that
would be passed to the GetComponent function). }
C := GetComponent(Index);
if C is TExButton then
result := TExButton(C).Images;
end;
end.
Здравствуйте, vlad_gri, Вы писали:
_>Смотри _>GetImageListAt _>Пример реализации в классе TTBItemImageIndexPropertyEditor в этом же файле.
Дык вот он, немного переделанный...
function TExButtonImageIndexPropertyEditor.GetImageListAt(Index: Integer): TCustomImageList;
var
C: TPersistent;
Item: TExButton;
begin
Result := nil;
{ ? I'm guessing that the Index parameter is a component index (one that
would be passed to the GetComponent function). }
C := GetComponent(Index);
if C is TExButton then
result := TExButton(C).Images;
end;
Здравствуйте, vlad_gri, Вы писали:
_>Здравствуйте, AlexEagle, Вы писали:
AE>>Дык вот он, немного переделанный...
_>Так его и используй для регистрации _>