tvplanit: Add new property "AllowInplaceEditing" for DayView, WeekView and TaskList.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4814 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-06-23 23:16:34 +00:00
parent 66bddaf5e0
commit 54dc447750
8 changed files with 80 additions and 26 deletions

View File

@ -25,9 +25,9 @@ object MainForm: TMainForm
Height = 532 Height = 532
Top = 48 Top = 48
Width = 780 Width = 780
ActivePage = TabContacts ActivePage = TabSettings
Align = alClient Align = alClient
TabIndex = 2 TabIndex = 4
TabOrder = 0 TabOrder = 0
object TabEvents: TTabSheet object TabEvents: TTabSheet
Caption = 'Events' Caption = 'Events'
@ -420,6 +420,17 @@ object MainForm: TMainForm
Style = csDropDownList Style = csDropDownList
TabOrder = 2 TabOrder = 2
end end
object CbAllowInplaceEditing: TCheckBox
Left = 349
Height = 19
Top = 28
Width = 131
Caption = 'Allow inplace editing'
Checked = True
OnChange = CbAllowInplaceEditingChange
State = cbChecked
TabOrder = 3
end
end end
end end
object HeaderPanel: TPanel object HeaderPanel: TPanel

View File

@ -15,6 +15,7 @@ TMAINFORM.TABSETTINGS.CAPTION=Settings
TMAINFORM.LBLLANGUAGE.CAPTION=Language TMAINFORM.LBLLANGUAGE.CAPTION=Language
TMAINFORM.LBLTIMEFORMAT.CAPTION=Time format TMAINFORM.LBLTIMEFORMAT.CAPTION=Time format
TMAINFORM.LBLFIRSTDAYOFWEEK.CAPTION=First day of week TMAINFORM.LBLFIRSTDAYOFWEEK.CAPTION=First day of week
TMAINFORM.CBALLOWINPLACEEDITING.CAPTION=Allow inplace editing
TMAINFORM.TITLELBL.CAPTION=TitleLbl TMAINFORM.TITLELBL.CAPTION=TitleLbl
TMAINFORM.MENUITEM1.CAPTION=File TMAINFORM.MENUITEM1.CAPTION=File
TMAINFORM.MNUQUIT.CAPTION=Quit TMAINFORM.MNUQUIT.CAPTION=Quit

View File

@ -22,6 +22,7 @@ type
CbGranularity: TComboBox; CbGranularity: TComboBox;
CbTimeFormat: TComboBox; CbTimeFormat: TComboBox;
CbFirstDayOfWeek: TComboBox; CbFirstDayOfWeek: TComboBox;
CbAllowInplaceEditing: TCheckBox;
Img: TImage; Img: TImage;
ImageList1: TImageList; ImageList1: TImageList;
LblFirstDayOfWeek: TLabel; LblFirstDayOfWeek: TLabel;
@ -68,6 +69,7 @@ type
procedure BtnDeleteResClick(Sender: TObject); procedure BtnDeleteResClick(Sender: TObject);
procedure BtnNewResClick(Sender: TObject); procedure BtnNewResClick(Sender: TObject);
procedure BtnEditResClick(Sender: TObject); procedure BtnEditResClick(Sender: TObject);
procedure CbAllowInplaceEditingChange(Sender: TObject);
procedure CbFirstDayOfWeekChange(Sender: TObject); procedure CbFirstDayOfWeekChange(Sender: TObject);
procedure CbGranularityChange(Sender: TObject); procedure CbGranularityChange(Sender: TObject);
procedure CbLanguagesChange(Sender: TObject); procedure CbLanguagesChange(Sender: TObject);
@ -235,6 +237,14 @@ begin
VpResourceEditDialog1.AddNewResource; VpResourceEditDialog1.AddNewResource;
end; end;
procedure TMainForm.CbAllowInplaceEditingChange(Sender: TObject);
begin
VpContactGrid1.AllowInplaceEditing := CbAllowInplaceEditing.Checked;
VpDayView1.AllowInplaceEditing := CbAllowInplaceEditing.Checked;
VpWeekView1.AllowInplaceEditing := CbAllowInplaceEditing.Checked;
VpTaskList1.AllowInplaceEditing := CbAllowInplaceEditing.Checked;
end;
procedure TMainForm.CbFirstDayOfWeekChange(Sender: TObject); procedure TMainForm.CbFirstDayOfWeekChange(Sender: TObject);
begin begin
VpWeekView1.WeekStartsOn := TVpDayType(CbFirstDayOfWeek.ItemIndex); VpWeekView1.WeekStartsOn := TVpDayType(CbFirstDayOfWeek.ItemIndex);
@ -428,6 +438,9 @@ begin
DaysTrackbar.Position := ini.ReadInteger('Settings', 'VisibleDays', DaysTrackbar.Position); DaysTrackbar.Position := ini.ReadInteger('Settings', 'VisibleDays', DaysTrackbar.Position);
DaysTrackbarChange(nil); DaysTrackbarChange(nil);
CbAllowInplaceEditing.Checked := ini.ReadBool('Settings', 'AllowInplaceEditing', CbAllowInplaceEditing.Checked);
CbAllowInplaceEditingChange(nil);
finally finally
ini.Free; ini.Free;
end; end;
@ -457,6 +470,7 @@ begin
ini.WriteInteger('Settings', 'FirstDayOfWeek', ord(VpWeekView1.WeekStartsOn)); ini.WriteInteger('Settings', 'FirstDayOfWeek', ord(VpWeekView1.WeekStartsOn));
ini.WriteInteger('Settings', 'VisibleDays', VpDayView1.NumDays); ini.WriteInteger('Settings', 'VisibleDays', VpDayView1.NumDays);
ini.WriteBool('Settings', 'AllTasks', VpTaskList1.DisplayOptions.ShowAll); ini.WriteBool('Settings', 'AllTasks', VpTaskList1.DisplayOptions.ShowAll);
ini.WriteBool('Settings', 'AllowInplaceEditing', CbAllowInplaceEditing.Checked);
finally finally
ini.Free; ini.Free;
end; end;
@ -586,6 +600,7 @@ begin
LblTimeFormat.Left := CbTimeFormat.Left - 8 - GetLabelWidth(LblTimeFormat); LblTimeFormat.Left := CbTimeFormat.Left - 8 - GetLabelWidth(LblTimeFormat);
CbFirstDayOfWeek.Left := CbLanguages.Left; CbFirstDayOfWeek.Left := CbLanguages.Left;
LblFirstDayOfWeek.Left := CbFirstDayOfWeek.Left - 8 - GetLabelWidth(LblFirstDayOfWeek); LblFirstDayOfWeek.Left := CbFirstDayOfWeek.Left - 8 - GetLabelWidth(LblFirstDayOfWeek);
CbAllowInplaceEditing.Left := CbLanguages.Left + CbLanguages.Width + 32;
RbHideCompletedTasks.Left := RbAllTasks.Left + RbAllTasks.Width + 48; RbHideCompletedTasks.Left := RbAllTasks.Left + RbAllTasks.Width + 48;
// Next settings work correctly only for Windows. // Next settings work correctly only for Windows.

View File

@ -145,6 +145,10 @@ msgstr "Neu"
msgid "Turbo Power VisualPlanIt Demo" msgid "Turbo Power VisualPlanIt Demo"
msgstr "Turbo Power VisualPlanIt Demo" msgstr "Turbo Power VisualPlanIt Demo"
#: tmainform.cballowinplaceediting.caption
msgid "Allow inplace editing"
msgstr ""
#: tmainform.cbgranularity.text #: tmainform.cbgranularity.text
msgid "30 Min" msgid "30 Min"
msgstr "30 Min" msgstr "30 Min"
@ -237,3 +241,4 @@ msgstr "Aufgaben"
#: tmainform.titlelbl.caption #: tmainform.titlelbl.caption
msgid "TitleLbl" msgid "TitleLbl"
msgstr "" msgstr ""

View File

@ -134,6 +134,10 @@ msgstr ""
msgid "Turbo Power VisualPlanIt Demo" msgid "Turbo Power VisualPlanIt Demo"
msgstr "" msgstr ""
#: tmainform.cballowinplaceediting.caption
msgid "Allow inplace editing"
msgstr ""
#: tmainform.cbgranularity.text #: tmainform.cbgranularity.text
msgid "30 Min" msgid "30 Min"
msgstr "" msgstr ""

View File

@ -267,6 +267,7 @@ type
FWrapStyle: TVpDVWrapStyle; FWrapStyle: TVpDVWrapStyle;
FDotDotDotColor: TColor; FDotDotDotColor: TColor;
FShowEventTimes: Boolean; FShowEventTimes: Boolean;
FAllowInplaceEdit: Boolean;
{ event variables } { event variables }
FOwnerDrawRowHead: TVpOwnerDrawRowEvent; FOwnerDrawRowHead: TVpOwnerDrawRowEvent;
FOwnerDrawCells: TVpOwnerDrawRowEvent; FOwnerDrawCells: TVpOwnerDrawRowEvent;
@ -454,6 +455,7 @@ type
property TabOrder; property TabOrder;
property Font; property Font;
property AllDayEventAttributes: TVpAllDayEventAttributes read FAllDayEventAttr write FAllDayEventAttr; property AllDayEventAttributes: TVpAllDayEventAttributes read FAllDayEventAttr write FAllDayEventAttr;
property AllowInplaceEditing: Boolean read FAllowInplaceEdit write FAllowInplaceEdit default true;
property DotDotDotColor: TColor read FDotDotDotColor write SetDotDotDotColor default clBlack; property DotDotDotColor: TColor read FDotDotDotColor write SetDotDotDotColor default clBlack;
property ShowEventTimes: Boolean read FShowEventTimes write SetShowEventTimes default true; property ShowEventTimes: Boolean read FShowEventTimes write SetShowEventTimes default true;
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle stored True; property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle stored True;
@ -758,6 +760,7 @@ begin
FWrapStyle := wsIconFlow; FWrapStyle := wsIconFlow;
FDotDotDotColor := clBlack; FDotDotDotColor := clBlack;
FIncludeWeekends := True; FIncludeWeekends := True;
FAllowInplaceEdit := true;
{ set up fonts and colors } { set up fonts and colors }
FHeadAttr.Font.Size := 10; FHeadAttr.Font.Size := 10;
@ -1925,12 +1928,16 @@ var
begin begin
if ReadOnly then if ReadOnly then
Exit; Exit;
AllowIt := true; if not FAllowInplaceEdit then
Exit;
{ call the user defined BeforeEdit event } { call the user defined BeforeEdit event }
AllowIt := true;
if Assigned(FBeforeEdit) then if Assigned(FBeforeEdit) then
FBeforeEdit(Self, FActiveEvent, AllowIt); FBeforeEdit(Self, FActiveEvent, AllowIt);
if not AllowIt then
exit;
if AllowIt then begin
{ create and spawn the in-place editor } { create and spawn the in-place editor }
if dvInPlaceEditor = nil then begin if dvInPlaceEditor = nil then begin
dvInPlaceEditor := TVpDvInPlaceEdit.Create(Self); dvInPlaceEditor := TVpDvInPlaceEdit.Create(Self);
@ -1948,7 +1955,6 @@ begin
Invalidate; Invalidate;
dvInPlaceEditor.SetFocus; dvInPlaceEditor.SetFocus;
end; end;
end;
{=====} {=====}
procedure TVpDayView.EndEdit(Sender: TObject); procedure TVpDayView.EndEdit(Sender: TObject);

View File

@ -150,6 +150,7 @@ type
FTaskID : Integer; FTaskID : Integer;
FDefaultPopup : TPopupMenu; FDefaultPopup : TPopupMenu;
FShowIcon : Boolean; FShowIcon : Boolean;
FAllowInplaceEdit : Boolean;
{ task variables } { task variables }
FOwnerDrawTask : TVpOwnerDrawTask; FOwnerDrawTask : TVpOwnerDrawTask;
FBeforeEdit : TVpBeforeEditTask; FBeforeEdit : TVpBeforeEditTask;
@ -250,6 +251,8 @@ type
property TabOrder; property TabOrder;
property ReadOnly; property ReadOnly;
property AllowInplaceEditing: Boolean
read FAllowInplaceEdit write FAllowInplaceEdit default true;
property DisplayOptions: TVpTaskDisplayOptions property DisplayOptions: TVpTaskDisplayOptions
read FDisplayOptions write FDisplayOptions; read FDisplayOptions write FDisplayOptions;
property LineColor: TColor property LineColor: TColor
@ -262,8 +265,8 @@ type
read FDrawingStyle write SetDrawingStyle; read FDrawingStyle write SetDrawingStyle;
property Color: TColor property Color: TColor
read FColor write SetColor; read FColor write SetColor;
property ShowIcon : Boolean read FShowIcon write SetShowIcon property ShowIcon : Boolean
default True; read FShowIcon write SetShowIcon default True;
property ShowResourceName: Boolean property ShowResourceName: Boolean
read FShowResourceName write SetShowResourceName; read FShowResourceName write SetShowResourceName;
{ events } { events }
@ -536,6 +539,7 @@ begin
FScrollBars := ssVertical; FScrollBars := ssVertical;
FTaskIndex := -1; FTaskIndex := -1;
FShowIcon := True; FShowIcon := True;
FAllowInplaceEdit := true;
SetLength(tlVisibleTaskArray, MaxVisibleTasks); SetLength(tlVisibleTaskArray, MaxVisibleTasks);
@ -1506,6 +1510,9 @@ begin
if FActiveTask.Complete then if FActiveTask.Complete then
Exit; Exit;
if not FAllowInplaceEdit then
exit;
AllowIt := true; AllowIt := true;
VisTask := tlTaskIndexToVisibleTask (TaskIndex); VisTask := tlTaskIndexToVisibleTask (TaskIndex);
@ -1528,7 +1535,7 @@ begin
tlInPlaceEditor.OnExit := EndEdit; tlInPlaceEditor.OnExit := EndEdit;
end; end;
tlInplaceEditor.Show; tlInplaceEditor.Show;
tlInPlaceEditor.SetBounds(R.Left, R.Top, R.Right-R.Left, R.Bottom-R.Top); //Move(R, true); tlInPlaceEditor.SetBounds(R.Left, R.Top, WidthOf(R), HeightOf(R));
tlInPlaceEditor.Text := FActiveTask.Description; tlInPlaceEditor.Text := FActiveTask.Description;
tlInPlaceEditor.Font.Assign(Font); tlInPlaceEditor.Font.Assign(Font);
tlInPlaceEditor.SelectAll; tlInPlaceEditor.SelectAll;

View File

@ -137,6 +137,7 @@ type
FWeekStartsOn: TVpDayType; FWeekStartsOn: TVpDayType;
FDefaultPopup: TPopupMenu; FDefaultPopup: TPopupMenu;
FAllDayEventAttr: TVpAllDayEventAttributes; FAllDayEventAttr: TVpAllDayEventAttributes;
FAllowInplaceEdit: Boolean;
{ event variables } { event variables }
FBeforeEdit: TVpBeforeEditEvent; FBeforeEdit: TVpBeforeEditEvent;
FAfterEdit: TVpAfterEditEvent; FAfterEdit: TVpAfterEditEvent;
@ -233,8 +234,8 @@ type
property VisibleLines: Integer read FVisibleLines; property VisibleLines: Integer read FVisibleLines;
published published
property AllDayEventAttributes: TVpAllDayEventAttributes property AllDayEventAttributes: TVpAllDayEventAttributes read FAllDayEventAttr write FAllDayEventAttr;
read FAllDayEventAttr write FAllDayEventAttr; property AllowInplaceEditing: Boolean read FAllowInplaceEdit write FAllowInplaceEdit default true;
property Color: TColor read FColor write SetColor; property Color: TColor read FColor write SetColor;
property DateLabelFormat: string read FDateLabelFormat write SetDateLabelFormat; property DateLabelFormat: string read FDateLabelFormat write SetDateLabelFormat;
property DayHeadAttributes: TVpDayHeadAttr read FDayHeadAttributes write FDayHeadAttributes; property DayHeadAttributes: TVpDayHeadAttr read FDayHeadAttributes write FDayHeadAttributes;
@ -425,6 +426,7 @@ begin
FTimeFormat := tf12Hour; FTimeFormat := tf12Hour;
FDateLabelFormat := 'dddd, mmmm dd, yyyy'; FDateLabelFormat := 'dddd, mmmm dd, yyyy';
FColumnWidth := 200; FColumnWidth := 200;
FAllowInplaceEdit := true;
{ set up fonts and colors } { set up fonts and colors }
// FDayHeadAttributes.Font.Name := 'Tahoma'; // FDayHeadAttributes.Font.Name := 'Tahoma';
@ -1178,6 +1180,9 @@ var
AllowIt: Boolean; AllowIt: Boolean;
begin begin
if ActiveEvent <> nil then begin if ActiveEvent <> nil then begin
if not FAllowInplaceEdit then
exit;
AllowIt := true; AllowIt := true;
{ call the user defined BeforeEdit event } { call the user defined BeforeEdit event }
if Assigned(FBeforeEdit) then if Assigned(FBeforeEdit) then