diff --git a/components/tvplanit/source/vpbase.pas b/components/tvplanit/source/vpbase.pas index c1600ed82..3959c1354 100644 --- a/components/tvplanit/source/vpbase.pas +++ b/components/tvplanit/source/vpbase.pas @@ -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 diff --git a/components/tvplanit/source/vpconst.pas b/components/tvplanit/source/vpconst.pas index 41c5a136e..e62472a76 100644 --- a/components/tvplanit/source/vpconst.pas +++ b/components/tvplanit/source/vpconst.pas @@ -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} ); diff --git a/components/tvplanit/source/vpdata.pas b/components/tvplanit/source/vpdata.pas index 21854aa45..f261fb5a1 100644 --- a/components/tvplanit/source/vpdata.pas +++ b/components/tvplanit/source/vpdata.pas @@ -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 @@ -1638,10 +1657,10 @@ end; procedure TVpEvent.SetAllDayEvent(Value: Boolean); begin if Value <> FAllDayEvent then - begin - FAllDayEvent := Value; - Changed := true; - end; + begin + FAllDayEvent := Value; + Changed := true; + end; end; procedure TVpEvent.SetChanged(Value: Boolean);