tvplanit: Simplify day, week and monthview, as well as contact list hints. Fix crash in Linux when mouse is moved into a hint.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5901 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-05-25 21:24:23 +00:00
parent be4e118c53
commit 590f5139ee
13 changed files with 250 additions and 218 deletions

View File

@ -9,7 +9,7 @@ object MainForm: TMainForm
Menu = MainMenu1
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
LCLVersion = '1.9.0.0'
LCLVersion = '1.6.4.0'
object Panel1: TPanel
Left = 125
Height = 576

View File

@ -514,11 +514,6 @@ begin
CategoryColorMap.Category0.Description := 'Appointment';
//CategoryColorMap.Category0.Bitmap.Transparent := true; // <-- not working
LoadGlyphFromRCDATA(CategoryColorMap.Category0.Bitmap, 'SORTASC');
{
bmp := CreateBitmapFromRCDATA('SORTASC');
CategoryColorMap.Category0.Bitmap.Assign(bmp);
bmp.Free;
}
CategoryColorMap.Category1.BackgroundColor := 13290239;
CategoryColorMap.Category1.Color := clRed;
CategoryColorMap.Category1.Description := 'Urgent';

View File

@ -251,6 +251,16 @@ msgstr "Datei"
msgid "Help"
msgstr "Hilfe"
#: tmainform.menuitem3.caption
msgctxt "tmainform.menuitem3.caption"
msgid "-"
msgstr ""
#: tmainform.menuitem4.caption
msgctxt "tmainform.menuitem4.caption"
msgid "-"
msgstr ""
#: tmainform.mnuabout.caption
msgid "About Visual PlanIt"
msgstr "Über Visual PlanIt"

View File

@ -240,6 +240,16 @@ msgstr "Tiedosto"
msgid "Help"
msgstr "Ohje"
#: tmainform.menuitem3.caption
msgctxt "tmainform.menuitem3.caption"
msgid "-"
msgstr ""
#: tmainform.menuitem4.caption
msgctxt "tmainform.menuitem4.caption"
msgid "-"
msgstr ""
#: tmainform.mnuabout.caption
msgid "About Visual PlanIt"
msgstr "Tietoja Visual PlanIt:stä"

View File

@ -245,6 +245,16 @@ msgstr "Bestand"
msgid "Help"
msgstr "Help"
#: tmainform.menuitem3.caption
msgctxt "tmainform.menuitem3.caption"
msgid "-"
msgstr ""
#: tmainform.menuitem4.caption
msgctxt "tmainform.menuitem4.caption"
msgid "-"
msgstr ""
#: tmainform.mnuabout.caption
msgid "About Visual PlanIt"
msgstr "Over Visual PlanIt"

View File

@ -240,6 +240,16 @@ msgstr ""
msgid "Help"
msgstr ""
#: tmainform.menuitem3.caption
msgctxt "TMAINFORM.MENUITEM3.CAPTION"
msgid "-"
msgstr ""
#: tmainform.menuitem4.caption
msgctxt "tmainform.menuitem4.caption"
msgid "-"
msgstr ""
#: tmainform.mnuabout.caption
msgid "About Visual PlanIt"
msgstr ""

View File

@ -254,6 +254,16 @@ msgstr "Файл"
msgid "Help"
msgstr "Справка"
#: tmainform.menuitem3.caption
msgctxt "tmainform.menuitem3.caption"
msgid "-"
msgstr ""
#: tmainform.menuitem4.caption
msgctxt "tmainform.menuitem4.caption"
msgid "-"
msgstr ""
#: tmainform.mnuabout.caption
msgid "About Visual PlanIt"
msgstr "О Visual PlanIt"

View File

@ -368,6 +368,13 @@ type
property ActiveRange: TVpTimeRange read FActiveRange write FActiveRange;
end;
TVpHintWindow = class(THintWindow)
public
function CalcHintRect(MaxWidth: Integer; const AHint: String;
AData: pointer): TRect; override;
end;
implementation
{$IFDEF NEW_ICONS}
@ -1019,7 +1026,15 @@ begin
Changed;
end;
end;
{=====}
{ TVpHintWindow }
function TVpHintWindow.CalcHintRect(MaxWidth: Integer; const AHint: String;
AData: pointer): TRect;
begin
Result := inherited CalcHintRect(MAX_HINT_WIDTH, AHint, AData);
end;
end.

View File

@ -113,6 +113,7 @@ const
VK_2 = Ord('2'); VK_3 = Ord('3'); VK_4 = Ord('4'); VK_5 = Ord('5');
VK_6 = Ord('6'); VK_7 = Ord('7'); VK_8 = Ord('8'); VK_9 = Ord('9');
{------------------- Windows messages -----------------------}
{Not a message code. Value of the first of the message codes used}
Vp_FIRST = $7F00; {***}

View File

@ -110,6 +110,7 @@ type
{ Contact Grid }
TVpContactGrid = class(TVpLinkableControl)
private
FComponentHint: TTranslateString;
FHintMode: TVpHintMode;
protected{ private }
FColumnWidth : Integer;
@ -155,7 +156,6 @@ type
cgColCount : Integer;
cgVScrollDelta : Integer;
FOldCursor : TCursor;
FHintWindow: THintWindow;
FMouseContactIndex: Integer;
{ property methods }
@ -223,6 +223,7 @@ type
function BuildHintString(AContact: TVpContact): String;
procedure ShowHintWindow(APoint: TPoint; AContactIndex: Integer);
procedure HideHintWindow;
procedure SetHint(const AValue: TTranslateString); override;
public
constructor Create(AOwner: TComponent); override;
@ -428,11 +429,14 @@ var
I: Integer;
begin
inherited;
ControlStyle := [csCaptureMouse, csOpaque, csDoubleClicks];
cgGridState := gsNormal;
HintWindowClass := TVpHintWindow;
ControlStyle := [csCaptureMouse, csOpaque, csDoubleClicks];
cgGridState := gsNormal;
{ Create internal classes and stuff }
cgClickTimer := TTimer.Create(self);
FContactHeadAttr := TVpContactHeadAttr.Create(Self);
cgClickTimer := TTimer.Create(self);
FContactHeadAttr := TVpContactHeadAttr.Create(Self);
{ Set styles and initialize internal variables }
{$IFDEF VERSION4}
@ -922,63 +926,41 @@ begin
end;
procedure TVpContactGrid.ShowHintWindow(APoint: TPoint; AContactIndex: Integer);
const
MaxWidth = 400;
var
txt: String;
contact: TVpContact;
R, RHint,RCont, RScr: TRect;
begin
if FHintMode = hmPlannerHint then
begin
if (AContactIndex = -1) or ((Datastore = nil) or (Datastore.Resource = nil)) then
begin
HideHintWindow;
exit;
end;
contact := TVpContact(cgContactArray[AContactIndex].Contact);
txt := BuildHintString(contact);
if (txt <> '') and not (csDesigning in ComponentState) then
begin
// Build and show the hint window
if FHintWindow = nil then
FHintWindow := THintWindow.Create(nil);
RScr := Screen.WorkAreaRect;
RCont.TopLeft := ClientToScreen(cgContactArray[AContactIndex].WholeRect.TopLeft);
RCont.BottomRight := ClientToScreen(cgContactArray[AContactIndex].WholeRect.BottomRight);
RHint := FHintWindow.CalcHintRect(MaxWidth, txt, nil);
R := RHint;
OffsetRect(R, RCont.Left - WidthOf(R), RCont.Top);
if R.Left < RScr.Left then begin
R := RHint;
OffsetRect(R, RCont.Right, RCont.Top);
HideHintWindow;
case FHintMode of
hmPlannerHint:
begin
if (AContactIndex = -1) or (Datastore = nil) or (Datastore.Resource = nil) then
exit;
contact := TVpContact(cgContactArray[AContactIndex].Contact);
txt := BuildHintString(contact);
end;
RHint := R;
if (R.Bottom > RScr.Bottom) then begin
R := RHint;
OffsetRect(R, 0, R.Bottom - RScr.Bottom);
end;
FHintWindow.ActivateHint(R, txt);
end else
// Hide the hint window
HideHintWindow;
end
else
if FHintMode = hmComponentHint then
begin
Application.Hint := Hint;
hmComponentHint:
txt := FComponentHint;
end;
if (txt <> '') and not (csDesigning in ComponentState) and
not ((cgInplaceEditor <> nil) and cgInplaceEditor.Visible)
then begin
Hint := txt;
Application.Hint := txt;
Application.ActivateHint(ClientToScreen(APoint), true);
end;
end;
procedure TVpContactGrid.HideHintWindow;
begin
case FHintMode of
hmPlannerHint : FreeAndNil(FHintWindow);
hmComponentHint : Application.CancelHint;
end;
Application.CancelHint;
end;
procedure TVpContactGrid.SetHint(const AValue: TTranslateString);
begin
inherited;
if FHintMode = hmComponentHint then
FComponentHint := AValue;
end;
procedure TVpContactGrid.MouseEnter;
@ -1058,21 +1040,19 @@ var
begin
if cgGridState = gsNormal then begin
inherited MouseMove(Shift, X, Y);
if ShowHint then
if (cgInPlaceEditor <> nil) and cgInPlaceEditor.Visible then
if ShowHint then begin
idx := GetContactIndexByCoord(Point(X, Y));
if idx = -1 then
HideHintWindow
else begin
idx := GetContactIndexByCoord(Point(X, Y));
if FMouseContactIndex <> idx then begin
ShowHintWindow(Point(X, Y), idx);
FMouseContactIndex := idx;
end;
else
if FMouseContactIndex <> idx then begin
ShowHintWindow(Point(X, Y), idx);
FMouseContactIndex := idx;
end;
end else
end;
end
else
begin
{ Column sizing happens here...}
{ if the in-place editor is active then kill it. }
if Assigned(cgInplaceEditor) and cgInPlaceEditor.Visible then

View File

@ -222,8 +222,8 @@ type
TVpDayView = class(TVpLinkableControl)
private
FComponentHint: TTranslateString;
FHintMode: TVpHintMode;
FHintWindow: THintWindow;
FMouseEvent: TVpEvent;
FOnHoliday: TVpHolidayEvent;
@ -339,6 +339,8 @@ type
{ Hints }
procedure ShowHintWindow(APoint: TPoint; AEvent: TVpEvent);
procedure HideHintWindow;
procedure SetHint(const AValue: TTranslateString); override;
procedure SetHintMode(const AValue: TVpHintMode);
{ internal methods }
function dvCalcRowHeight(Scale: Extended; UseGran: TVpGranularity): Integer;
@ -478,7 +480,7 @@ type
property IncludeWeekends: Boolean read FIncludeWeekends write SetIncludeWeekends default True;
property NumDays: Integer read FNumDays write SetNumDays default 1;
property WrapStyle: TVpDVWrapStyle read FWrapStyle Write SetWrapStyle default wsIconFlow;
property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint;
property HintMode: TVpHintMode read FHintMode write SetHintMode default hmPlannerHint;
{events}
property AfterEdit: TVpAfterEditEvent read FAfterEdit write FAfterEdit;
property BeforeEdit: TVpBeforeEditEvent read FBeforeEdit write FBeforeEdit;
@ -688,6 +690,7 @@ constructor TVpDayView.Create(AOwner: TComponent);
begin
inherited;
ControlStyle := [csCaptureMouse, csOpaque, csDoubleClicks];
HintWindowClass := TVpHintWindow;
{ Create internal classes and stuff }
FTimeSlotColors := TVpTimeSlotColor.Create(self);
@ -822,7 +825,6 @@ end;
destructor TVpDayView.Destroy;
begin
FreeAndNil(dvInplaceEditor);
FreeAndNil(FHintWindow);
FTimeSlotColors.Free;
FHeadAttr.Free;
@ -1021,38 +1023,22 @@ end;
procedure TVpDayView.ShowHintWindow(APoint: TPoint; AEvent: TVpEvent);
var
txt: String;
R, eventR: TRect;
begin
if FHintMode = hmPlannerHint then
begin
if (AEvent = nil) or
((Datastore = nil) or (Datastore.Resource = nil)) then
begin
HideHintWindow;
exit;
end;
txt := BuildEventString(AEvent, true);
if (txt <> '') and
not ((dvInPlaceEditor <> nil) and dvInplaceEditor.Visible) and
not (csDesigning in ComponentState) then
begin
if FHintWindow = nil then
FHintWindow := THintWindow.Create(nil);
eventR := GetEventRect(AEvent);
eventR.TopLeft := ClientToScreen(eventR.TopLeft);
eventR.BottomRight := ClientToScreen(eventR.BottomRight);
APoint := ClientToScreen(APoint);
R := FHintWindow.CalcHintRect(MAX_HINT_WIDTH, txt, nil);
OffsetRect(R, APoint.X - WidthOf(R), eventR.Bottom);
FHintWindow.ActivateHint(R, txt);
end else
HideHintWindow;
end
else
if FHintMode = hmComponentHint then
HideHintWindow;
case FHintMode of
hmPlannerHint:
begin
if (AEvent = nil) or (Datastore = nil) or (Datastore.Resource = nil) then
exit;
txt := BuildEventString(AEvent, true);
end;
hmComponentHint:
txt := FComponentHint;
end;
if (txt <> '') and not (csDesigning in ComponentState) and
not ((dvInplaceEditor <> nil) and dvInplaceEditor.Visible) then
begin
Hint := txt;
Application.Hint := Hint;
Application.ActivateHint(ClientToScreen(APoint), true);
end;
@ -1060,12 +1046,7 @@ end;
procedure TVpDayView.HideHintWindow;
begin
case FHintMode of
hmPlannerHint:
FreeAndNil(FHintWindow);
hmComponentHint:
Application.CancelHint;
end;
Application.CancelHint;
end;
@ -1878,8 +1859,11 @@ begin
if ShowHint then
begin
event := GetEventAtCoord(Point(X, Y));
if event = nil then
HideHintWindow
else
if FMouseEvent <> event then begin
Application.CancelHint;
// HideHintWindow;
ShowHintWindow(Point(X, Y), event);
FMouseEvent := event;
end;
@ -2469,6 +2453,23 @@ begin
Invalidate;
end;
end;
procedure TVpDayView.SetHint(const AValue: TTranslateString);
begin
inherited;
if FHintMode = hmComponentHint then
FComponentHint := AValue;
end;
procedure TVpDayView.SetHintMode(const AValue: TVpHintMode);
begin
if AValue = FHintMode then
exit;
FHintMode := AValue;
if FHintMode = hmPlannerHint then
FComponentHint := Hint;
end;
{=====}
procedure TVpDayView.dvSetActiveRowByCoord(Pnt: TPoint; Sloppy: Boolean);

View File

@ -137,6 +137,7 @@ type
TVpMonthView = class(TVpLinkableControl)
private
FComponentHint: TTranslateString;
FHintMode: TVpHintMode;
FOnHoliday: TVpHolidayEvent;
protected{ private }
@ -168,7 +169,6 @@ type
FDate: TDateTime;
FDefaultPopup: TPopupMenu;
FRightClickChangeDate: Boolean;
FHintWindow: THintWindow;
FMouseDate: TDateTime;
{ event variables }
@ -245,6 +245,7 @@ type
{ Hints }
procedure ShowHintWindow(APoint: TPoint; ADate: TDateTime);
procedure HideHintWindow;
procedure SetHint(const AValue: TTranslateString); override;
{ Popup menu }
procedure InitializeDefaultPopup;
@ -407,6 +408,7 @@ constructor TVpMonthView.Create(AOwner: TComponent);
begin
inherited;
ControlStyle := [csCaptureMouse, csOpaque, csDoubleClicks];
HintWindowClass := TVpHintWindow;
{ Create internal classes and stuff }
FHeadAttr := TVpMonthViewAttr.Create(self);
@ -486,7 +488,6 @@ end;
destructor TVpMonthView.Destroy;
begin
FreeAndNil(FHintWindow);
FHeadAttr.Free;
FHolidayAttr.Free;
FTodayAttr.Free;
@ -940,77 +941,74 @@ var
holiday: String = '';
todayDate: TDate;
begin
if FHintMode = hmPlannerHint then
begin
if (ADate = 0) or ((Datastore = nil) or (Datastore.Resource = nil)) then
begin
HideHintWindow;
exit;
end;
HideHintWindow;
// If the date is a holiday we put the holidayname at the top
IsHoliday(ADate, holiday);
if (csDesigning in ComponentState) then
exit;
// Collect all events of this day and add them separated by line feeds to
// the hint string (txt).
list := TList.Create;
txt := '';
try
Datastore.Resource.Schedule.EventsByDate(ADate, List);
for i:=0 to list.Count-1 do begin
event := TVpEvent(list[i]);
s := BuildEventString(event, true, false);
txt := IfThen(txt = '', s, txt + LineEnding + s);
case FHintMode of
hmPlannerHint:
begin
if (ADate = 0) or (Datastore = nil) or (Datastore.Resource = nil) then
exit;
txt := '';
// If the date is a holiday we put the holidayname at the top
IsHoliday(ADate, holiday);
// Collect all events of this day and add them separated by line feeds to
// the hint string (txt).
list := TList.Create;
try
Datastore.Resource.Schedule.EventsByDate(ADate, List);
for i:=0 to list.Count-1 do begin
event := TVpEvent(list[i]);
s := BuildEventString(event, true, false);
txt := IfThen(txt = '', s, txt + LineEnding + s);
end;
finally
list.Free;
end;
// If we have any events then we put the current date at the top.
todayDate := SysUtils.Date();
if (txt = '') and (holiday = '') and (ADate = todayDate) then
txt := RSToday + LineEnding + FormatDateTime('ddddd', ADate)
else
if (txt <> '') or (holiday <> '') then begin
if (txt = '') and (holiday <> '') then
txt := FormatDateTime('ddddd', ADate) + LineEnding + holiday
else begin
txt := LineEnding + txt;
if holiday <> '' then
txt := holiday + LineEnding + txt;
txt := FormatDateTime('ddddd', ADate) + LineEnding + txt;
if ADate = todayDate then
txt := RSToday + LineEnding + txt;
end;
end;
end;
finally
list.Free;
end;
// If we have any events then we put the current date at the top.
todayDate := SysUtils.Date();
if (txt = '') and (holiday = '') and (ADate = todayDate) then
txt := RSToday + LineEnding + FormatDateTime('ddddd', ADate)
else
if (txt <> '') or (holiday <> '') then begin
if (txt = '') and (holiday <> '') then
txt := FormatDateTime('ddddd', ADate) + LineEnding + holiday
else begin
txt := LineEnding + txt;
if holiday <> '' then
txt := holiday + LineEnding + txt;
txt := FormatDateTime('ddddd', ADate) + LineEnding + txt;
if ADate = todayDate then
txt := RSToday + LineEnding + txt;
end;
end;
if (txt <> '') and not (csDesigning in ComponentState) then
begin
// Build and show the hint window
if FHintWindow = nil then
FHintWindow := THintWindow.Create(nil);
APoint := ClientToScreen(APoint);
R := FHintWindow.CalcHintRect(MaxWidth, txt, nil);
OffsetRect(R, APoint.X - WidthOf(R), APoint.Y);
FHintWindow.ActivateHint(R, txt);
end else
// Hide the hint window
HideHintWindow;
end
else
if FHintMode = hmComponentHint then
begin
Application.Hint := Hint;
Application.ActivateHint(ClientToScreen(APoint), true);
hmComponentHint:
txt := FComponentHint;
end;
if (txt <> '') then begin
Hint := txt;
Application.Hint := txt;
Application.ActivateHint(ScreenToClient(APoint), true);
end else
if FHintMode = hmPlannerHint then begin
Hint := '';
Application.Hint := '';
end;
end;
procedure TVpMonthView.HideHintWindow;
begin
case FHintMode of
hmPlannerHint: FreeAndNil(FHintWindow);
hmComponentHint: Application.CancelHint;
end;
Application.CancelHint;
end;
procedure TVpMonthView.SetHint(const AValue: TTranslateString);
begin
inherited;
if FHintMode = hmComponentHint then
FComponentHint := AValue;
end;
procedure TVpMonthView.InitializeDefaultPopup;
@ -1244,9 +1242,11 @@ begin
if ShowHint then
begin
day := GetDateAtCoord(Point(X, Y));
if FMouseDate <> day then begin
ShowHintWindow(Point(X, Y), day);
if day = 0 then
HideHintWindow
else if FMouseDate <> day then begin
FMouseDate := day;
ShowHintWindow(Point(X, Y), day);
end;
end;
end;
@ -1256,7 +1256,7 @@ begin
if v <> FRightClickChangeDate then
FRightClickChangeDate := v;
end;
{=====}
procedure TVpMonthView.SetWeekStartsOn(Value: TVpDayType);
begin
if Value <> FWeekStartsOn then begin

View File

@ -119,9 +119,9 @@ type
TVpWeekView = class(TVpLinkableControl)
private
FComponentHint: TTranslateString;
FHintMode: TVpHintMode;
FMouseEvent: TVpEvent;
FHintWindow: THintWindow;
FLayout: TVpWeekviewLayout;
FOnHoliday: TVpHolidayEvent;
procedure SetActiveEvent(AValue: TVpEvent);
@ -232,6 +232,7 @@ type
{ hints }
procedure ShowHintWindow(APoint: TPoint; AEvent: TVpEvent);
procedure HideHintWindow;
procedure SetHint(const AValue: TTranslateString); override;
{ message handlers }
{$IFNDEF LCL}
@ -435,6 +436,7 @@ constructor TVpWeekView.Create(AOwner: TComponent);
begin
inherited;
ControlStyle := [csCaptureMouse, csOpaque, csDoubleClicks];
HintWindowClass := TVpHintWindow;
{ Create internal classes and stuff }
FDayHeadAttributes := TVpDayHeadAttr.Create(self);
@ -508,7 +510,6 @@ end;
destructor TVpWeekView.Destroy;
begin
FreeAndNil(FHintWindow);
FreeAndNil(wvInplaceEditor);
FDayHeadAttributes.Free;
FAllDayEventAttr.Free;
@ -1043,49 +1044,36 @@ var
txt: String;
R, eventR: TRect;
begin
if FHintMode = hmPlannerHint then
HideHintWindow;
case FHintMode of
hmPlannerHint:
begin
if (AEvent = nil) or (Datastore = nil) or (Datastore.Resource = nil) then
exit;
txt := BuildEventString(AEvent, AEvent.StartTime, AEvent.EndTime, true);
end;
hmComponentHint:
txt := FComponentHint;
end;
if (txt <> '') and not ((wvInplaceEditor <> nil) and wvInplaceEditor.Visible)
and not (csDesigning in ComponentState) then
begin
if (AEvent = nil) or
((Datastore = nil) or (Datastore.Resource = nil)) then
begin
HideHintWindow;
exit;
end;
txt := BuildEventString(AEvent, AEvent.StartTime, AEvent.EndTime, true);
if (txt <> '') and
not ((wvInPlaceEditor <> nil) and wvInplaceEditor.Visible) and
not (csDesigning in ComponentState) then
begin
if FHintWindow = nil then
FHintWindow := THintWindow.Create(nil);
eventR := GetEventRect(AEvent);
eventR.TopLeft := ClientToScreen(eventR.TopLeft);
eventR.BottomRight := ClientToScreen(eventR.BottomRight);
APoint := ClientToScreen(APoint);
R := FHintWindow.CalcHintRect(MAX_HINT_WIDTH, txt, nil);
OffsetRect(R, APoint.X - WidthOf(R), eventR.Bottom);
FHintWindow.ActivateHint(R, txt);
end else
HideHintWindow;
end
else
if FHintMode = hmComponentHint then
begin
Application.Hint := Hint;
Hint := txt;
Application.Hint := txt;
Application.ActivateHint(ClientToScreen(APoint), true);
end;
end;
procedure TVpWeekView.HideHintWindow;
begin
case FHintMode of
hmPlannerHint:
FreeAndNil(FHintWindow);
hmComponentHint:
Application.CancelHint;
end;
Application.CancelHint;
end;
procedure TVpWeekView.SetHint(const AValue: TTranslateString);
begin
inherited;
if FHintMode = hmComponentHint then
FComponentHint := AValue;
end;
@ -1721,8 +1709,10 @@ begin
if ShowHint then
begin
event := GetEventAtCoord(Point(X, Y));
if FMouseEvent <> event then begin
Application.CancelHint;
if event = nil then
HideHintWindow
else if FMouseEvent <> event then begin
HideHintWindow;
ShowHintWindow(Point(X, Y), event);
FMouseEvent := event;
end;