tvplanit: Fix alarm and recurrance icons in DayView.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4830 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2016-06-24 21:41:24 +00:00
parent 31056b3ac8
commit 281124bc97
3 changed files with 78 additions and 69 deletions

View File

@ -112,40 +112,24 @@ object MainForm: TMainForm
RowHeadAttributes.MinuteFont.Height = -12 RowHeadAttributes.MinuteFont.Height = -12
RowHeadAttributes.Color = clBtnFace RowHeadAttributes.Color = clBtnFace
IconAttributes.AlarmBitmap.Data = { IconAttributes.AlarmBitmap.Data = {
36040000424D3604000000000000360000002800000010000000100000000100 F6000000424DF600000000000000760000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF 0400000000008000000000000000000000000000000000000000000000000000
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 80000080000000808000800000008000800080800000C0C0C000808080000000
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00300130000031
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 00333310009090001333330097F0F7900333380970FFF07908333099FF0FFFF9
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 90333090FFF0FF0090333099FFF0FFF99033380970F0FF790833330097F0F790
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF 0333000009999900000307780000008778030777703030777803308770803077
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00000000000000 8033338003303300833333333300033333333333333333333333
0000000000000303030003030300020202000101010401010151000000660000 }
004D0000000001010100010101020101010001010100FFFFFF00000000000000 IconAttributes.RecurringBitmap.Data = {
0000000000000303030003030300030303000202022F2F2F2F96EFDEDEFF0000 F6000000424DF600000000000000760000002800000010000000100000000100
00710000000001010100010101460101012301010100FFFFFF00000000000000 04000000000080000000C40E0000C40E00001000000010000000000000000000
000000000000030303070303031C0303034B2523238A989191E9E4D2D2FF0000 8000008000000080800080000000800080008080000080808000C0C0C0000000
0085000000000101010001010119010101870101011BFFFFFF00000000770000 FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00888888888888
00ED000000ED040404893F3A3A9F7C7272C2CAB9B9F4A49B9BFFCFBDBDFF0808 8888888888888888888888888888888888888888888888888888888888888888
088A0505050001010149010101260101013201010170FFFFFF00000000DB2D2D 8888888078888888888888708888800000888808888888000088880888888880
2DF83C3C3CFFCBB9B9FFC7B5B5FFC2B0B0FFBCAAAAFF9B9292FFBEACACFF1212 0088880888888808008888708888708880888887000078888888888888888888
12860A0A0A0001010119010101800101010D01010187FFFFFF00010101C05C5C 8888888888888888888888888888888888888888888888888888
5CFF4E4E4EFFB1A7A7FFB0A5A5FFAFA3A3FFADA0A0FF9A9393FFB9AAAAFF2020
20812020200001010100010101870101010001010187FFFFFF00010101AE5F5F
5FEA7A7A7AFFCFCFCFFFCCCCCCFFC7C6C6FFC0BEBEFFA9A8A8FFC9C6C6FF2F2F
2F791818180000000015000000700000000B00000075FFFFFF00010101560101
01AB010101AB3E3E3E726C6C6C8C9A9A9AB6CFCFCFF2B6B6B6FFD2D2D2FF3E3E
3E721F1F1F00000000370000001E0000002600000055FFFFFF00010101000101
01000101010048484806484848184B4B4B3E65656578BDBDBDE6E3E3E3FF4B4B
4B6C4B4B4B0000000000000000100000005B00000013FFFFFF00010101000101
01000101010048484800484848004D4D4D00535353297676768BECECECFF5454
546754545400000000000000002B0000001600000000FFFFFF00010101000101
010001010100484848004848480051515100555555045555554D555555665555
554D555555002B2B2B00000000000000000000000000FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
} }
ShowResourceName = True ShowResourceName = True
LineColor = clGray LineColor = clGray
@ -642,6 +626,7 @@ object MainForm: TMainForm
top = 280 top = 280
end end
object VpBufDSDataStore1: TVpBufDSDataStore object VpBufDSDataStore1: TVpBufDSDataStore
CategoryColorMap.Category0.BackgroundColor = clSkyBlue
CategoryColorMap.Category0.Color = clNavy CategoryColorMap.Category0.Color = clNavy
CategoryColorMap.Category0.Description = 'Category 0' CategoryColorMap.Category0.Description = 'Category 0'
CategoryColorMap.Category1.Color = clRed CategoryColorMap.Category1.Color = clRed

View File

@ -190,7 +190,7 @@ type
property Color: TColor read FColor write SetColor; property Color: TColor read FColor write SetColor;
end; end;
TVpDayViewIconAttributes = class (TPersistent) TVpDayViewIconAttributes = class(TPersistent)
private private
FShowAlarmBitmap: Boolean; FShowAlarmBitmap: Boolean;
FShowCategoryBitmap: Boolean; FShowCategoryBitmap: Boolean;
@ -681,12 +681,12 @@ begin
ControlStyle := [csCaptureMouse, csOpaque, csDoubleClicks]; ControlStyle := [csCaptureMouse, csOpaque, csDoubleClicks];
{ Create internal classes and stuff } { Create internal classes and stuff }
FTimeSlotColors := TVpTimeSlotColor.Create (self); FTimeSlotColors := TVpTimeSlotColor.Create(self);
FHeadAttr := TVpCHAttributes.Create (self); FHeadAttr := TVpCHAttributes.Create(self);
FRowHeadAttr := TVpRHAttributes.Create (self); FRowHeadAttr := TVpRHAttributes.Create(self);
FAllDayEventAttr := TVpAllDayEventAttributes.Create(self); FAllDayEventAttr := TVpAllDayEventAttributes.Create(self);
dvClickTimer := TTimer.Create (self); dvClickTimer := TTimer.Create (self);
FIconAttributes := TVpDayViewIconAttributes.Create (Self); FIconAttributes := TVpDayViewIconAttributes.Create(Self);
{ create Nav buttons } { create Nav buttons }
dvDayUpBtn := TSpeedButton.Create(self); dvDayUpBtn := TSpeedButton.Create(self);
@ -712,11 +712,11 @@ begin
dvDayUpBtn.Transparent := true; dvDayUpBtn.Transparent := true;
dvWeekUpBtn.Transparent := true; dvWeekUpBtn.Transparent := true;
{ load their images } { load their images }
dvDayUpBtn.Glyph.LoadFromResourceName(HINSTANCE,'VPRIGHTARROW'); dvDayUpBtn.Glyph.LoadFromResourceName(HINSTANCE, 'VPRIGHTARROW');
dvDayDownBtn.Glyph.LoadFromResourceName(HINSTANCE,'VPLEFTARROW'); dvDayDownBtn.Glyph.LoadFromResourceName(HINSTANCE, 'VPLEFTARROW');
dvTodayBtn.Glyph.LoadFromResourceName(HINSTANCE,'VPTODAY'); dvTodayBtn.Glyph.LoadFromResourceName(HINSTANCE, 'VPTODAY');
dvWeekUpBtn.Glyph.LoadFromResourceName(HINSTANCE,'VPRIGHTARROWS'); dvWeekUpBtn.Glyph.LoadFromResourceName(HINSTANCE, 'VPRIGHTARROWS');
dvWeekDownBtn.Glyph.LoadFromResourceName(HINSTANCE,'VPLEFTARROWS'); dvWeekDownBtn.Glyph.LoadFromResourceName(HINSTANCE, 'VPLEFTARROWS');
{ set their OnClick handler } { set their OnClick handler }
dvDayUpBtn.OnClick := dvNavButtonsClick; dvDayUpBtn.OnClick := dvNavButtonsClick;
dvDayDownBtn.OnClick := dvNavButtonsClick; dvDayDownBtn.OnClick := dvNavButtonsClick;
@ -1945,9 +1945,9 @@ begin
dvInPlaceEditor.OnExit := EndEdit; dvInPlaceEditor.OnExit := EndEdit;
end; end;
dvInPlaceEditor.SetBounds( dvInPlaceEditor.SetBounds(
dvActiveIconRec.Left + FGutterWidth + TextMargin, dvActiveIconRec.Right + TextMargin,
dvActiveEventRec.Top + TextMargin, dvActiveEventRec.Top + TextMargin,
dvActiveEventRec.Right - dvActiveIconRec.Left - FGutterWidth - TextMargin, dvActiveEventRec.Right - dvActiveIconRec.Right - TextMargin,
dvActiveEventRec.Bottom - dvActiveEventRec.Top - TextMargin dvActiveEventRec.Bottom - dvActiveEventRec.Top - TextMargin
); );
dvInPlaceEditor.Show; dvInPlaceEditor.Show;

View File

@ -759,12 +759,13 @@ var
end; end;
var var
OKToDrawEditFrame : Boolean; OKToDrawEditFrame: Boolean;
TextRegion : HRGN; TextRegion : HRGN;
WorkRegion1: HRGN; WorkRegion1: HRGN;
WorkRegion2: HRGN; WorkRegion2: HRGN;
CW: Integer; CW: Integer;
EventIsEditing: Boolean; EventIsEditing: Boolean;
EventCategory: TVpCategoryInfo;
OldPen: TPen; OldPen: TPen;
OldBrush: TBrush; OldBrush: TBrush;
OldFont: TFont; OldFont: TFont;
@ -896,8 +897,8 @@ begin
{ amount of time represented by one line, divided by the height of } { amount of time represented by one line, divided by the height of }
{ a line in pixels. } { a line in pixels. }
with TVpDayViewOpener(FDayView) do with TVpDayViewOpener(FDayView) do
if (dvLineMatrix[Col, StartLine].Rec.Bottom - dvLineMatrix[Col, StartLine].Rec.Top) > 0 then if HeightOf(dvLineMatrix[Col, StartLine].Rec) > 0 then
PixelDuration := (LineDuration / (dvLineMatrix[Col, StartLine].Rec.Bottom - dvLineMatrix[Col, StartLine].Rec.Top)) PixelDuration := LineDuration / HeightOf(dvLineMatrix[Col, StartLine].Rec)
else else
PixelDuration := 0; PixelDuration := 0;
@ -909,6 +910,17 @@ begin
{ if we have hit the end of the events, then bail out } { if we have hit the end of the events, then bail out }
if Event = nil then if Event = nil then
Break; Break;
{ Collect useful information needed later }
EventCategory := FDayView.Datastore.CategoryColorMap.GetCategory(Event.Category);
EventIsEditing := false;
if (TVpDayViewOpener(FDayView).dvInPlaceEditor <> nil) and
TVpDayViewOpener(FDayView).dvInplaceEditor.Visible and
(FDayView.ActiveEvent = Event)
then
EventIsEditing := true;
(* -- original (* -- original
{ remove the date portion from the start and end times } { remove the date portion from the start and end times }
EventSTime := Event.StartTime; EventSTime := Event.StartTime;
@ -929,13 +941,13 @@ begin
{ remove the date portion from the start and end times } { remove the date portion from the start and end times }
EventSTime := Event.StartTime; EventSTime := Event.StartTime;
EventETime := Event.EndTime; EventETime := Event.EndTime;
if (EventSTime < trunc(ARenderDate)) and (Event.RepeatCode=rtNone) then //First Event if (EventSTime < trunc(ARenderDate)) and (Event.RepeatCode = rtNone) then // First Event
EventSTime := trunc(ARenderDate) EventSTime := trunc(ARenderDate)
else if (Event.RepeatCode <> rtNone) then else if (Event.RepeatCode <> rtNone) then
EventSTime := frac(EventSTime) + trunc(ARenderDate); EventSTime := frac(EventSTime) + trunc(ARenderDate);
if (trunc(EventETime) > trunc(ARenderDate)) and (Event.RepeatCode = rtNone) then //First Event if (trunc(EventETime) > trunc(ARenderDate)) and (Event.RepeatCode = rtNone) then // First Event
EventETime := 0.999+trunc(ARenderDate) EventETime := 0.999 + trunc(ARenderDate)
else if (Event.RepeatCode<>rtNone) then else if (Event.RepeatCode <> rtNone) then
EventETime := frac(EventETime) + trunc(ARenderDate); EventETime := frac(EventETime) + trunc(ARenderDate);
EventSTime := EventSTime - trunc(ARenderDate); EventSTime := EventSTime - trunc(ARenderDate);
EventETime := EventETime - trunc(ARenderDate); EventETime := EventETime - trunc(ARenderDate);
@ -963,22 +975,24 @@ begin
EventRect.Bottom := TVpDayViewOpener(FDayView).dvLineMatrix[Col, EventELine].Rec.Bottom; EventRect.Bottom := TVpDayViewOpener(FDayView).dvLineMatrix[Col, EventELine].Rec.Bottom;
if EventRect.Bottom < VisibleRect.Top then if EventRect.Bottom < VisibleRect.Top then
EventRect.Bottom := VisibleRect.Bottom; EventRect.Bottom := VisibleRect.Bottom;
EventWidth := (VisibleRect.Right - VisibleRect.Left) div EventArray[I].WidthDivisor; EventWidth := WidthOf(VisibleRect) div EventArray[I].WidthDivisor;
{ Slide the rect over to correspond with the level } { Slide the rect over to correspond with the level }
if EventArray[I].Level > 0 then if EventArray[I].Level > 0 then
EventRect.Left := EventRect.Left + (EventWidth * EventArray[I].Level) EventRect.Left := EventRect.Left + EventWidth * EventArray[I].Level
{ added because level 0 events were one pixel too far to the right } { added because level 0 events were one pixel too far to the right }
else else
EventRect.Left := EventRect.Left - 1; EventRect.Left := EventRect.Left - 1;
EventRect.Right := EventRect.Left + EventWidth - FDayView.GutterWidth; EventRect.Right := EventRect.Left + EventWidth - FDayView.GutterWidth;
{ Draw the event rectangle } { Draw the event rectangle }
{ paint Event text area clWindow } { paint Event text area clWindow }
if Assigned(FDayView.DataStore) then if Assigned(FDayView.DataStore) then begin
RenderCanvas.Brush.Color := FDayView.Datastore.CategoryColorMap.GetCategory(Event.Category).BackgroundColor if EventIsEditing then
RenderCanvas.Brush.Color := clWindow
else else
RenderCanvas.Brush.Color := EventCategory.BackgroundColor
end else
RenderCanvas.Brush.Color := WindowColor; RenderCanvas.Brush.Color := WindowColor;
TPSFillRect(RenderCanvas, Angle, RenderIn, EventRect); TPSFillRect(RenderCanvas, Angle, RenderIn, EventRect);
@ -986,7 +1000,7 @@ begin
{ corresponding to the event's category } { corresponding to the event's category }
{ These colors are used even when printing } { These colors are used even when printing }
if Assigned(FDayView.DataStore) then if Assigned(FDayView.DataStore) then
RenderCanvas.Brush.Color := FDayView.DataStore.CategoryColorMap.GetColor(Event.Category); RenderCanvas.Brush.Color := EventCategory.Color; //FDayView.DataStore.CategoryColorMap.GetColor(Event.Category);
{ find the pixel offset to use for determining where to start and } { find the pixel offset to use for determining where to start and }
{ stop drawing colored area according to the start time and end time of the event. } { stop drawing colored area according to the start time and end time of the event. }
@ -1018,10 +1032,10 @@ begin
{ Paint the gutter inside the EventRect all events } { Paint the gutter inside the EventRect all events }
if (EventArray[I].Level = 0) then if (EventArray[I].Level = 0) then
GutterRect.Left := EventRect.Left - Trunc (FDayView.GutterWidth * Scale) GutterRect.Left := EventRect.Left - Trunc(FDayView.GutterWidth * Scale)
else else
GutterRect.Left := EventRect.Left; GutterRect.Left := EventRect.Left;
GutterRect.Right := GutterRect.Left + Round (FDayView.GutterWidth * Scale); GutterRect.Right := GutterRect.Left + Round(FDayView.GutterWidth * Scale);
GutterRect.Top := EventRect.Top + StartPixelOffset; GutterRect.Top := EventRect.Top + StartPixelOffset;
GutterRect.Bottom := EventRect.Bottom - EndPixelOffset; GutterRect.Bottom := EventRect.Bottom - EndPixelOffset;
@ -1029,7 +1043,7 @@ begin
RenderCanvas.Brush.Color := WindowColor; RenderCanvas.Brush.Color := WindowColor;
if (TVpDayViewOpener(FDayView).dvInPlaceEditor <> nil) and { if (TVpDayViewOpener(FDayView).dvInPlaceEditor <> nil) and
TVpDayViewOpener(FDayView).dvInplaceEditor.Visible then TVpDayViewOpener(FDayView).dvInplaceEditor.Visible then
begin begin
if FDayView.ActiveEvent = Event then if FDayView.ActiveEvent = Event then
@ -1038,7 +1052,7 @@ begin
EventIsEditing := False; EventIsEditing := False;
end else end else
EventIsEditing := False; EventIsEditing := False;
}
{ build the event string } { build the event string }
IconRect.Left := EventRect.Left; IconRect.Left := EventRect.Left;
IconRect.Top := EventRect.Top; IconRect.Top := EventRect.Top;
@ -1095,7 +1109,6 @@ begin
if FDayView.WrapStyle = wsNone then begin if FDayView.WrapStyle = wsNone then begin
{ if the string is longer than the availble space then chop } { if the string is longer than the availble space then chop }
{ off the and and place those little '...'s at the end } { off the and and place those little '...'s at the end }
if RenderCanvas.TextWidth(EventString) > EventRect.Right - IconRect.Right - Round(FDayView.GutterWidth * Scale) - TextMargin if RenderCanvas.TextWidth(EventString) > EventRect.Right - IconRect.Right - Round(FDayView.GutterWidth * Scale) - TextMargin
then then
EventString := GetDisplayString( EventString := GetDisplayString(
@ -1242,14 +1255,22 @@ var
DrawPos: Integer; DrawPos: Integer;
procedure DrawIcon(bmp: TBitmap; w, h: Integer; IncDrawPos: Boolean = false); procedure DrawIcon(bmp: TBitmap; w, h: Integer; IncDrawPos: Boolean = false);
var
R: TRect;
begin begin
if (bmp.Width <> 0) and (bmp.Height <> 0) then if (bmp.Width <> 0) and (bmp.Height <> 0) then
begin begin
bmp.Transparent := True;
R := Rect(0, 0, w, h);
OffsetRect(R, AIconRect.Left + 1, AIconRect.Top + 1);
RenderCanvas.StretchDraw(R, bmp);
{
RenderCanvas.CopyRect( // wp: was FDayview.Canvas -- does not look correct... RenderCanvas.CopyRect( // wp: was FDayview.Canvas -- does not look correct...
Rect(AIconRect.Left + 1, AIconRect.Top +1, AIconRect.Left + w + 1, AIconRect.Top + h + 1), Rect(AIconRect.Left + 1, AIconRect.Top + 1, AIconRect.Left + w + 1, AIconRect.Top + h + 1),
bmp.Canvas, bmp.Canvas,
Rect(0, 0, bmp.Width, bmp.Height) Rect(0, 0, bmp.Width, bmp.Height)
); );
}
if IncDrawPos then if IncDrawPos then
inc(DrawPos, w); inc(DrawPos, w);
end; end;
@ -1412,13 +1433,16 @@ begin
ShowCategory := False; ShowCategory := False;
ShowCustom := False; ShowCustom := False;
// FDayView.IconAttributes.AlarmBitmap.SaveToFile('d:\test.bmp');
if Event.AlarmSet then begin if Event.AlarmSet then begin
dvBmpAlarm.Assign(FDayView.IconAttributes.AlarmBitmap); dvBmpAlarm.Assign(FDayView.IconAttributes.AlarmBitmap);
ShowAlarm := (dvBmpAlarm.Width <> 0) and (dvBmpAlarm.Height <> 0); ShowAlarm := (dvBmpAlarm.Width <> 0) and (dvBmpAlarm.Height <> 0);
end; end;
if Event.RepeatCode <> rtNone then begin if Event.RepeatCode <> rtNone then begin
dvBmpRecurring.Assign (FDayView.IconAttributes.RecurringBitmap); dvBmpRecurring.Assign(FDayView.IconAttributes.RecurringBitmap);
ShowRecurring := (dvBmpRecurring.Width <> 0) and (dvBmpRecurring.Height <> 0); ShowRecurring := (dvBmpRecurring.Width <> 0) and (dvBmpRecurring.Height <> 0);
end; end;