git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.DevExpressVCL@38 05c56307-c608-d34a-929d-697000501d7a
356 lines
12 KiB
ObjectPascal
356 lines
12 KiB
ObjectPascal
|
|
{********************************************************************}
|
|
{ }
|
|
{ Developer Express Visual Component Library }
|
|
{ ExpressStatusBar }
|
|
{ }
|
|
{ Copyright (c) 1998-2009 Developer Express Inc. }
|
|
{ ALL RIGHTS RESERVED }
|
|
{ }
|
|
{ The entire contents of this file is protected by U.S. and }
|
|
{ International Copyright Laws. Unauthorized reproduction, }
|
|
{ reverse-engineering, and distribution of all or any portion of }
|
|
{ the code contained in this file is strictly prohibited and may }
|
|
{ result in severe civil and criminal penalties and will be }
|
|
{ prosecuted to the maximum extent possible under the law. }
|
|
{ }
|
|
{ RESTRICTIONS }
|
|
{ }
|
|
{ THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES }
|
|
{ (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE }
|
|
{ SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS }
|
|
{ LICENSED TO DISTRIBUTE THE EXPRESSSTATUSBAR AND ALL }
|
|
{ ACCOMPANYING VCL CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY. }
|
|
{ }
|
|
{ THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED }
|
|
{ FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE }
|
|
{ COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE }
|
|
{ AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT }
|
|
{ AND PERMISSION FROM DEVELOPER EXPRESS INC. }
|
|
{ }
|
|
{ CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON }
|
|
{ ADDITIONAL RESTRICTIONS. }
|
|
{ }
|
|
{********************************************************************}
|
|
|
|
unit dxStatusBarReg;
|
|
|
|
{$I cxVer.inc}
|
|
|
|
interface
|
|
|
|
procedure Register;
|
|
|
|
implementation
|
|
|
|
uses
|
|
ColnEdit,
|
|
{$IFDEF DELPHI6}
|
|
DesignIntf, DesignEditors, VCLEditors, Types,
|
|
{$ELSE}
|
|
DsgnIntf,
|
|
{$ENDIF}
|
|
Windows, SysUtils, Classes, Controls, Graphics, Forms, ImgList,
|
|
cxClasses, cxPropEditors,
|
|
dxStatusBar, dxStatusIndicatorEditor;
|
|
|
|
const
|
|
dxStatusBarVersion = '5.44';
|
|
|
|
type
|
|
{ TdxStatusBarEditor }
|
|
|
|
TdxStatusBarEditor = class(TComponentEditor)
|
|
public
|
|
procedure ExecuteVerb(Index: Integer); override;
|
|
function GetVerb(Index: Integer): string; override;
|
|
function GetVerbCount: Integer; override;
|
|
end;
|
|
|
|
procedure TdxStatusBarEditor.ExecuteVerb(Index: Integer);
|
|
begin
|
|
case Index of
|
|
0: ShowCollectionEditor(Designer, Component, (Component as TdxStatusBar).Panels, 'Panels');
|
|
end;
|
|
end;
|
|
|
|
function TdxStatusBarEditor.GetVerb(Index: Integer): string;
|
|
begin
|
|
case Index of
|
|
0: Result := 'Panels Editor...';
|
|
1: Result := '-';
|
|
2: Result := 'ExpressBars ' + dxStatusBarVersion;
|
|
3: Result := 'Developer Express Inc.';
|
|
end;
|
|
end;
|
|
|
|
function TdxStatusBarEditor.GetVerbCount: Integer;
|
|
begin
|
|
Result := 4;
|
|
end;
|
|
|
|
{$IFDEF DELPHI6}
|
|
|
|
type
|
|
TdxStatusBarSelectionEditor = class(TSelectionEditor)
|
|
public
|
|
procedure RequiresUnits(Proc: TGetStrProc); override;
|
|
end;
|
|
|
|
procedure TdxStatusBarSelectionEditor.RequiresUnits(Proc: TGetStrProc);
|
|
begin
|
|
Proc('cxGraphics');
|
|
end;
|
|
|
|
{$ENDIF}
|
|
|
|
type
|
|
{ TdxStatusBarPanelStyleProperty }
|
|
|
|
TdxStatusBarPanelStyleProperty = class(TClassProperty)
|
|
protected
|
|
function HasSubProperties: Boolean;
|
|
public
|
|
function GetAttributes: TPropertyAttributes; override;
|
|
function GetValue: string; override;
|
|
procedure GetValues(Proc: TGetStrProc); override;
|
|
procedure SetValue(const Value: string); override;
|
|
end;
|
|
|
|
{ TdxStatusBarPanelStyleEventsProperty }
|
|
|
|
TdxStatusBarPanelStyleEventsProperty = class(TcxNestedEventProperty)
|
|
protected
|
|
function GetInstance: TPersistent; override;
|
|
end;
|
|
|
|
{ TdxStatusBarStateIndicatorsProperty }
|
|
|
|
TdxStatusBarStateIndicatorsProperty = class(TClassProperty)
|
|
public
|
|
procedure Edit; override;
|
|
function GetAttributes: TPropertyAttributes; override;
|
|
end;
|
|
|
|
{$IFDEF DELPHI5}
|
|
{ TdxStatusBarTextPanelImageIndexProperty }
|
|
|
|
TdxStatusBarTextPanelImageIndexProperty = class(TIntegerProperty{$IFDEF DELPHI6}, ICustomPropertyListDrawing{$ENDIF})
|
|
public
|
|
function GetImages: TImageList; virtual;
|
|
function GetAttributes: TPropertyAttributes; override;
|
|
function GetValue: string; override;
|
|
procedure GetValues(Proc: TGetStrProc); override;
|
|
procedure SetValue(const Value: string); override;
|
|
procedure ListMeasureHeight(const Value: string; ACanvas: TCanvas;
|
|
var AHeight: Integer); {$IFDEF DELPHI6}virtual{$ELSE}override{$ENDIF};
|
|
procedure ListMeasureWidth(const Value: string; ACanvas: TCanvas;
|
|
var AWidth: Integer); {$IFDEF DELPHI6}virtual{$ELSE}override{$ENDIF};
|
|
procedure ListDrawValue(const Value: string; ACanvas: TCanvas;
|
|
const ARect: TRect; ASelected: Boolean); {$IFDEF DELPHI6}virtual{$ELSE}override{$ENDIF};
|
|
end;
|
|
{$ENDIF}
|
|
|
|
{ TdxStatusBarPanelStyleProperty }
|
|
|
|
function TdxStatusBarPanelStyleProperty.HasSubProperties: Boolean;
|
|
var
|
|
I: Integer;
|
|
begin
|
|
for I := 0 to PropCount - 1 do
|
|
begin
|
|
Result := TdxStatusBarPanel(GetComponent(I)).PanelStyle <> nil;
|
|
if not Result then Exit;
|
|
end;
|
|
Result := True;
|
|
end;
|
|
|
|
function TdxStatusBarPanelStyleProperty.GetAttributes: TPropertyAttributes;
|
|
begin
|
|
Result := inherited GetAttributes;
|
|
if not HasSubProperties then
|
|
Exclude(Result, paSubProperties);
|
|
Result := Result - [paReadOnly] +
|
|
[paValueList, paSortList, paRevertable{$IFDEF DELPHI6}, paVolatileSubProperties{$ENDIF}];
|
|
end;
|
|
|
|
function TdxStatusBarPanelStyleProperty.GetValue: string;
|
|
begin
|
|
if HasSubProperties then
|
|
Result := GetRegisteredStatusBarPanelStyles.GetDescriptionByClass(TdxStatusBarPanelStyle(GetOrdValue).ClassType)
|
|
else
|
|
Result := '';
|
|
end;
|
|
|
|
procedure TdxStatusBarPanelStyleProperty.GetValues(Proc: TGetStrProc);
|
|
var
|
|
I: Integer;
|
|
begin
|
|
for I := 0 to GetRegisteredStatusBarPanelStyles.Count - 1 do
|
|
Proc(GetRegisteredStatusBarPanelStyles.Descriptions[I]);
|
|
end;
|
|
|
|
procedure TdxStatusBarPanelStyleProperty.SetValue(const Value: string);
|
|
var
|
|
FPanelStyleStyleClass: TdxStatusBarPanelStyleClass;
|
|
I: Integer;
|
|
begin
|
|
FPanelStyleStyleClass := TdxStatusBarPanelStyleClass(
|
|
GetRegisteredStatusBarPanelStyles.FindByClassName(Value));
|
|
if FPanelStyleStyleClass = nil then
|
|
FPanelStyleStyleClass := TdxStatusBarPanelStyleClass(
|
|
GetRegisteredStatusBarPanelStyles.FindByDescription(Value));
|
|
|
|
for I := 0 to PropCount - 1 do
|
|
TdxStatusBarPanel(GetComponent(I)).PanelStyleClass := FPanelStyleStyleClass;
|
|
Modified;
|
|
end;
|
|
|
|
{ TdxStatusBarPanelStyleEventsProperty }
|
|
|
|
function TdxStatusBarPanelStyleEventsProperty.GetInstance: TPersistent;
|
|
begin
|
|
Result := TdxStatusBarPanel(GetComponent(0)).PanelStyle;
|
|
end;
|
|
|
|
{ TdxStatusBarStateIndicatorsProperty }
|
|
|
|
function TdxStatusBarStateIndicatorsProperty.GetAttributes: TPropertyAttributes;
|
|
begin
|
|
Result := [paDialog, paReadOnly];
|
|
end;
|
|
|
|
procedure TdxStatusBarStateIndicatorsProperty.Edit;
|
|
var
|
|
EditorForm: TdxStatusBarIndicatorEditor;
|
|
begin
|
|
EditorForm := TdxStatusBarIndicatorEditor.Create(Application);
|
|
try
|
|
EditorForm.Caption :=
|
|
TdxStatusBarStateIndicatorPanelStyle(GetComponent(0)).StatusBarControl.Name + '.IndicatorPanelStyle';
|
|
EditorForm.Indicators.Assign(TdxStatusBarStateIndicatorPanelStyle(GetComponent(0)).Indicators);
|
|
if EditorForm.ShowModal = mrOK then
|
|
begin
|
|
EditorForm.PrepareIndicators;
|
|
with TdxStatusBarStateIndicatorPanelStyle(GetComponent(0)) do
|
|
begin
|
|
Indicators.BeginUpdate;
|
|
try
|
|
Indicators.Clear;
|
|
Indicators.Assign(EditorForm.Indicators);
|
|
finally
|
|
Indicators.EndUpdate;
|
|
end;
|
|
end;
|
|
Modified;
|
|
end;
|
|
finally
|
|
FreeAndNil(EditorForm);
|
|
end;
|
|
end;
|
|
|
|
{$IFDEF DELPHI5}
|
|
|
|
{ TdxStatusBarTextPanelImageIndexProperty }
|
|
|
|
function TdxStatusBarTextPanelImageIndexProperty.GetAttributes: TPropertyAttributes;
|
|
begin
|
|
Result := [paValueList, paRevertable];
|
|
end;
|
|
|
|
function TdxStatusBarTextPanelImageIndexProperty.GetValue: string;
|
|
begin
|
|
Result := IntToStr(GetOrdValue);
|
|
end;
|
|
|
|
procedure TdxStatusBarTextPanelImageIndexProperty.GetValues(Proc: TGetStrProc);
|
|
var i: Integer;
|
|
begin
|
|
if GetImages <> nil then
|
|
for i := 0 to GetImages.Count-1 do Proc(IntToStr(i));
|
|
end;
|
|
|
|
procedure TdxStatusBarTextPanelImageIndexProperty.ListDrawValue(const Value: string;
|
|
ACanvas: TCanvas; const ARect: TRect; ASelected: Boolean);
|
|
var
|
|
AImageWidth: Integer;
|
|
begin
|
|
with ACanvas do
|
|
begin
|
|
Brush.Style := bsSolid;
|
|
if ASelected then Brush.Color := clHighlight else Brush.Color := clWindow;
|
|
FillRect(ARect);
|
|
if ASelected then DrawFocusRect(ARect);
|
|
if GetImages <> nil then
|
|
AImageWidth := GetImages.Width
|
|
else
|
|
AImageWidth := 0;
|
|
if GetImages <> nil then
|
|
GetImages.Draw(ACanvas, ARect.Left, ARect.Top, StrToInt(value));
|
|
TextOut(ARect.Left + AImageWidth + 2, ARect.Top, Value);
|
|
end;
|
|
end;
|
|
|
|
procedure TdxStatusBarTextPanelImageIndexProperty.ListMeasureHeight(const Value: string;
|
|
ACanvas: TCanvas; var AHeight: Integer);
|
|
var
|
|
AImageHeight, AStringHeight: Integer;
|
|
begin
|
|
AStringHeight := ACanvas.Textheight(Value);
|
|
if GetImages <> nil then
|
|
AImageHeight := GetImages.Height
|
|
else
|
|
AImageheight := 0;
|
|
if AStringHeight > AImageHeight then
|
|
AHeight := AStringHeight + 2
|
|
else
|
|
AHeight := AImageHeight + 2;
|
|
end;
|
|
|
|
procedure TdxStatusBarTextPanelImageIndexProperty.ListMeasureWidth(const Value: string;
|
|
ACanvas: TCanvas; var AWidth: Integer);
|
|
var
|
|
AImageWidth, AStringWidth: Integer;
|
|
begin
|
|
AStringWidth := ACanvas.TextWidth(Value);
|
|
if GetImages <> nil then
|
|
AImageWidth := GetImages.Width
|
|
else
|
|
AImageWidth := 0;
|
|
AWidth := AStringWidth + AImageWidth + 4;
|
|
end;
|
|
|
|
procedure TdxStatusBarTextPanelImageIndexProperty.SetValue(const Value: string);
|
|
begin
|
|
SetOrdValue(StrToInt(Value));
|
|
end;
|
|
|
|
function TdxStatusBarTextPanelImageIndexProperty.GetImages: TImageList;
|
|
begin
|
|
Result := nil;
|
|
if GetComponent(0) is TdxStatusBarTextPanelStyle then
|
|
Result := TImageList(TdxStatusBarTextPanelStyle(GetComponent(0)).StatusBarControl.Images);
|
|
end;
|
|
|
|
{$ENDIF}
|
|
|
|
procedure Register;
|
|
begin
|
|
RegisterComponents('ExpressBars', [TdxStatusBar]);
|
|
RegisterComponentEditor(TdxStatusBar, TdxStatusBarEditor);
|
|
RegisterPropertyEditor(TypeInfo(TdxStatusBarPanelStyle), TdxStatusBarPanel, 'PanelStyle', TdxStatusBarPanelStyleProperty);
|
|
RegisterPropertyEditor(TypeInfo(TNotifyEvent), TdxStatusBarPanel, 'PanelStyleEvents', TdxStatusBarPanelStyleEventsProperty);
|
|
RegisterPropertyEditor(TypeInfo(string), TdxStatusBarPanel, 'PanelStyleClassName', nil);
|
|
RegisterPropertyEditor(TypeInfo(TdxStatusBarContainerControl), TdxStatusBarContainerPanelStyle, 'Container', nil);
|
|
RegisterPropertyEditor(TypeInfo(TdxStatusBarStateIndicators), TdxStatusBarPanelStyle, '',
|
|
TdxStatusBarStateIndicatorsProperty);
|
|
{$IFDEF DELPHI5}
|
|
RegisterPropertyEditor(TypeInfo(TImageIndex), TdxStatusBarTextPanelStyle, 'ImageIndex', TdxStatusBarTextPanelImageIndexProperty);
|
|
{$ENDIF}
|
|
{$IFDEF DELPHI6}
|
|
RegisterSelectionEditor(TdxStatusBar, TdxStatusBarSelectionEditor);
|
|
{$ENDIF}
|
|
end;
|
|
|
|
end.
|