You've already forked lazarus-ccr
tvplanit: Add property GetCategoryName to TVpEvent. Improved handling of default colors of TVpColorInfo.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8402 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -240,6 +240,7 @@ type
|
||||
private
|
||||
FOwner: TComponent; // This is the DataStore.
|
||||
FCategoryIndex: Integer;
|
||||
function IsStoredColor: Boolean;
|
||||
protected
|
||||
FBackgroundColor: TColor;
|
||||
FColor: TColor;
|
||||
@ -261,7 +262,7 @@ type
|
||||
property BackgroundColor: TColor
|
||||
read FBackgroundColor write SetBackgroundColor default clWindow;
|
||||
property Bitmap: TBitmap read FBitmap write SetBitmap;
|
||||
property Color: TColor read FColor write SetColor;
|
||||
property Color: TColor read FColor write SetColor stored IsStoredColor;
|
||||
property Description: string read FDescription write SetDescription;
|
||||
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
|
||||
property CategoryIndex: Integer read FCategoryIndex;
|
||||
@ -276,6 +277,7 @@ type
|
||||
public
|
||||
constructor Create(AOwner: TComponent);
|
||||
destructor Destroy; override;
|
||||
function GetBackgroundColor(AIndex: Integer): TColor;
|
||||
function GetColor(AIndex: Integer): TColor;
|
||||
function GetName(AIndex: Integer):string;
|
||||
function GetCategory(AIndex: Integer): TVpCategoryInfo;
|
||||
@ -752,10 +754,6 @@ end;
|
||||
{ TVpCategoryColorMap }
|
||||
|
||||
constructor TVpCategoryColorMap.Create(AOwner: TComponent);
|
||||
const
|
||||
CAT_COLORS: Array[0..9] of TColor = (
|
||||
clNavy, clRed, clYellow, clLime, clPurple, clTeal, clFuchsia, clOlive, clAqua, clMaroon
|
||||
);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
@ -765,7 +763,7 @@ begin
|
||||
begin
|
||||
FCat[i] := TVpCategoryInfo.Create(FOwner);
|
||||
FCat[i].FIndex := i;
|
||||
FCat[i].Color := CAT_COLORS[i];
|
||||
FCat[i].Color := CATEGORY_COLORS[i];
|
||||
FCat[i].Description := Format(RSCategoryDesc, [i]);
|
||||
end;
|
||||
end;
|
||||
@ -812,6 +810,14 @@ begin
|
||||
Result := -1;
|
||||
end;
|
||||
|
||||
function TVpCategoryColorMap.GetBackgroundColor(AIndex: Integer): TColor;
|
||||
begin
|
||||
if (AIndex >= Low(FCat)) and (AIndex <= High(FCat)) then
|
||||
Result := FCat[AIndex].BackgroundColor
|
||||
else
|
||||
Result := clWindow;
|
||||
end;
|
||||
|
||||
function TVpCategoryColorMap.GetColor(AIndex: Integer): TColor;
|
||||
begin
|
||||
if (AIndex >= Low(FCat)) and (AIndex <= High(FCat)) then
|
||||
@ -848,6 +854,7 @@ begin
|
||||
FOwner := AOwner;
|
||||
FBitmap := TBitmap.Create;
|
||||
FBackgroundColor := clWindow;
|
||||
FColor := clNavy;
|
||||
FImageIndex := -1;
|
||||
end;
|
||||
|
||||
@ -857,6 +864,11 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TVpCategoryInfo.IsStoredColor: Boolean;
|
||||
begin
|
||||
Result := FColor <> CATEGORY_COLORS[FIndex];
|
||||
end;
|
||||
|
||||
procedure TVpCategoryInfo.SetBackgroundColor(const v: TColor);
|
||||
begin
|
||||
if v <> FBackgroundColor then
|
||||
|
@ -53,6 +53,10 @@ const
|
||||
|
||||
BorderStyles: array[TBorderStyle] of LongInt = (0, WS_BORDER);
|
||||
|
||||
CATEGORY_COLORS: Array[0..9] of TColor = (
|
||||
clNavy, clRed, clYellow, clLime, clPurple, clTeal, clFuchsia, clOlive, clAqua, clMaroon
|
||||
);
|
||||
|
||||
ScrollBarStyles: array[TScrollStyle] of LongInt = (
|
||||
0, WS_HSCROLL, WS_VSCROLL, WS_HSCROLL or WS_VSCROLL{$IFDEF LCL},0,0,0{$ENDIF}
|
||||
);
|
||||
|
@ -316,6 +316,7 @@ type
|
||||
function CreateICalEvent(ACalendar: TVpICalendar): TVpICalEvent;
|
||||
class procedure GetAlarmParams(ATrigger: TDateTime; out AdvTime: Integer;
|
||||
out AdvTimeUnits: TVpAlarmAdvType);
|
||||
function GetCategoryName: String;
|
||||
function GetResource: TVpResource;
|
||||
function IsOverlayed: Boolean;
|
||||
procedure LoadFromICalendar(AEntry: TVpICalEvent);
|
||||
@ -1433,6 +1434,24 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Returns the Description of the categoy associated with the event. }
|
||||
function TVpEvent.GetCategoryName: String;
|
||||
var
|
||||
res: TVpResource;
|
||||
store: TVpCustomDatastore;
|
||||
begin
|
||||
Result := '';
|
||||
if (FCategory < 0) or (FCategory > 9) then
|
||||
exit;
|
||||
res := GetResource;
|
||||
if res = nil then
|
||||
exit;
|
||||
store := TVpCustomDatastore(res.Owner.Owner);
|
||||
if store = nil then
|
||||
exit;
|
||||
Result := store.CategoryColorMap.GetCategoryName(FCategory);
|
||||
end;
|
||||
|
||||
{ Returns the resource to which the event belongs. }
|
||||
function TVpEvent.GetResource: TVpResource;
|
||||
begin
|
||||
|
Reference in New Issue
Block a user