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
|
private
|
||||||
FOwner: TComponent; // This is the DataStore.
|
FOwner: TComponent; // This is the DataStore.
|
||||||
FCategoryIndex: Integer;
|
FCategoryIndex: Integer;
|
||||||
|
function IsStoredColor: Boolean;
|
||||||
protected
|
protected
|
||||||
FBackgroundColor: TColor;
|
FBackgroundColor: TColor;
|
||||||
FColor: TColor;
|
FColor: TColor;
|
||||||
@ -261,7 +262,7 @@ type
|
|||||||
property BackgroundColor: TColor
|
property BackgroundColor: TColor
|
||||||
read FBackgroundColor write SetBackgroundColor default clWindow;
|
read FBackgroundColor write SetBackgroundColor default clWindow;
|
||||||
property Bitmap: TBitmap read FBitmap write SetBitmap;
|
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 Description: string read FDescription write SetDescription;
|
||||||
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
|
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
|
||||||
property CategoryIndex: Integer read FCategoryIndex;
|
property CategoryIndex: Integer read FCategoryIndex;
|
||||||
@ -276,6 +277,7 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent);
|
constructor Create(AOwner: TComponent);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
function GetBackgroundColor(AIndex: Integer): TColor;
|
||||||
function GetColor(AIndex: Integer): TColor;
|
function GetColor(AIndex: Integer): TColor;
|
||||||
function GetName(AIndex: Integer):string;
|
function GetName(AIndex: Integer):string;
|
||||||
function GetCategory(AIndex: Integer): TVpCategoryInfo;
|
function GetCategory(AIndex: Integer): TVpCategoryInfo;
|
||||||
@ -752,10 +754,6 @@ end;
|
|||||||
{ TVpCategoryColorMap }
|
{ TVpCategoryColorMap }
|
||||||
|
|
||||||
constructor TVpCategoryColorMap.Create(AOwner: TComponent);
|
constructor TVpCategoryColorMap.Create(AOwner: TComponent);
|
||||||
const
|
|
||||||
CAT_COLORS: Array[0..9] of TColor = (
|
|
||||||
clNavy, clRed, clYellow, clLime, clPurple, clTeal, clFuchsia, clOlive, clAqua, clMaroon
|
|
||||||
);
|
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
@ -765,7 +763,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
FCat[i] := TVpCategoryInfo.Create(FOwner);
|
FCat[i] := TVpCategoryInfo.Create(FOwner);
|
||||||
FCat[i].FIndex := i;
|
FCat[i].FIndex := i;
|
||||||
FCat[i].Color := CAT_COLORS[i];
|
FCat[i].Color := CATEGORY_COLORS[i];
|
||||||
FCat[i].Description := Format(RSCategoryDesc, [i]);
|
FCat[i].Description := Format(RSCategoryDesc, [i]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -812,6 +810,14 @@ begin
|
|||||||
Result := -1;
|
Result := -1;
|
||||||
end;
|
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;
|
function TVpCategoryColorMap.GetColor(AIndex: Integer): TColor;
|
||||||
begin
|
begin
|
||||||
if (AIndex >= Low(FCat)) and (AIndex <= High(FCat)) then
|
if (AIndex >= Low(FCat)) and (AIndex <= High(FCat)) then
|
||||||
@ -848,6 +854,7 @@ begin
|
|||||||
FOwner := AOwner;
|
FOwner := AOwner;
|
||||||
FBitmap := TBitmap.Create;
|
FBitmap := TBitmap.Create;
|
||||||
FBackgroundColor := clWindow;
|
FBackgroundColor := clWindow;
|
||||||
|
FColor := clNavy;
|
||||||
FImageIndex := -1;
|
FImageIndex := -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -857,6 +864,11 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TVpCategoryInfo.IsStoredColor: Boolean;
|
||||||
|
begin
|
||||||
|
Result := FColor <> CATEGORY_COLORS[FIndex];
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpCategoryInfo.SetBackgroundColor(const v: TColor);
|
procedure TVpCategoryInfo.SetBackgroundColor(const v: TColor);
|
||||||
begin
|
begin
|
||||||
if v <> FBackgroundColor then
|
if v <> FBackgroundColor then
|
||||||
|
@ -53,6 +53,10 @@ const
|
|||||||
|
|
||||||
BorderStyles: array[TBorderStyle] of LongInt = (0, WS_BORDER);
|
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 = (
|
ScrollBarStyles: array[TScrollStyle] of LongInt = (
|
||||||
0, WS_HSCROLL, WS_VSCROLL, WS_HSCROLL or WS_VSCROLL{$IFDEF LCL},0,0,0{$ENDIF}
|
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;
|
function CreateICalEvent(ACalendar: TVpICalendar): TVpICalEvent;
|
||||||
class procedure GetAlarmParams(ATrigger: TDateTime; out AdvTime: Integer;
|
class procedure GetAlarmParams(ATrigger: TDateTime; out AdvTime: Integer;
|
||||||
out AdvTimeUnits: TVpAlarmAdvType);
|
out AdvTimeUnits: TVpAlarmAdvType);
|
||||||
|
function GetCategoryName: String;
|
||||||
function GetResource: TVpResource;
|
function GetResource: TVpResource;
|
||||||
function IsOverlayed: Boolean;
|
function IsOverlayed: Boolean;
|
||||||
procedure LoadFromICalendar(AEntry: TVpICalEvent);
|
procedure LoadFromICalendar(AEntry: TVpICalEvent);
|
||||||
@ -1433,6 +1434,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
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. }
|
{ Returns the resource to which the event belongs. }
|
||||||
function TVpEvent.GetResource: TVpResource;
|
function TVpEvent.GetResource: TVpResource;
|
||||||
begin
|
begin
|
||||||
@ -1638,10 +1657,10 @@ end;
|
|||||||
procedure TVpEvent.SetAllDayEvent(Value: Boolean);
|
procedure TVpEvent.SetAllDayEvent(Value: Boolean);
|
||||||
begin
|
begin
|
||||||
if Value <> FAllDayEvent then
|
if Value <> FAllDayEvent then
|
||||||
begin
|
begin
|
||||||
FAllDayEvent := Value;
|
FAllDayEvent := Value;
|
||||||
Changed := true;
|
Changed := true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpEvent.SetChanged(Value: Boolean);
|
procedure TVpEvent.SetChanged(Value: Boolean);
|
||||||
|
Reference in New Issue
Block a user