From 54dc4477503aa8b96e3634e0748a2029a57d6322 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Thu, 23 Jun 2016 23:16:34 +0000 Subject: [PATCH] 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 --- .../tvplanit/examples/demo/demomain.lfm | 15 ++++++- .../tvplanit/examples/demo/demomain.lrt | 1 + .../tvplanit/examples/demo/demomain.pas | 15 +++++++ components/tvplanit/languages/demo.de.po | 5 +++ components/tvplanit/languages/demo.po | 4 ++ components/tvplanit/source/vpdayview.pas | 42 +++++++++++-------- components/tvplanit/source/vptasklist.pas | 15 +++++-- components/tvplanit/source/vpweekview.pas | 9 +++- 8 files changed, 80 insertions(+), 26 deletions(-) diff --git a/components/tvplanit/examples/demo/demomain.lfm b/components/tvplanit/examples/demo/demomain.lfm index 9807ac550..ea5551372 100644 --- a/components/tvplanit/examples/demo/demomain.lfm +++ b/components/tvplanit/examples/demo/demomain.lfm @@ -25,9 +25,9 @@ object MainForm: TMainForm Height = 532 Top = 48 Width = 780 - ActivePage = TabContacts + ActivePage = TabSettings Align = alClient - TabIndex = 2 + TabIndex = 4 TabOrder = 0 object TabEvents: TTabSheet Caption = 'Events' @@ -420,6 +420,17 @@ object MainForm: TMainForm Style = csDropDownList TabOrder = 2 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 object HeaderPanel: TPanel diff --git a/components/tvplanit/examples/demo/demomain.lrt b/components/tvplanit/examples/demo/demomain.lrt index 12504679a..76e44642d 100644 --- a/components/tvplanit/examples/demo/demomain.lrt +++ b/components/tvplanit/examples/demo/demomain.lrt @@ -15,6 +15,7 @@ TMAINFORM.TABSETTINGS.CAPTION=Settings TMAINFORM.LBLLANGUAGE.CAPTION=Language TMAINFORM.LBLTIMEFORMAT.CAPTION=Time format TMAINFORM.LBLFIRSTDAYOFWEEK.CAPTION=First day of week +TMAINFORM.CBALLOWINPLACEEDITING.CAPTION=Allow inplace editing TMAINFORM.TITLELBL.CAPTION=TitleLbl TMAINFORM.MENUITEM1.CAPTION=File TMAINFORM.MNUQUIT.CAPTION=Quit diff --git a/components/tvplanit/examples/demo/demomain.pas b/components/tvplanit/examples/demo/demomain.pas index 5d8bc851d..6ef1a2633 100644 --- a/components/tvplanit/examples/demo/demomain.pas +++ b/components/tvplanit/examples/demo/demomain.pas @@ -22,6 +22,7 @@ type CbGranularity: TComboBox; CbTimeFormat: TComboBox; CbFirstDayOfWeek: TComboBox; + CbAllowInplaceEditing: TCheckBox; Img: TImage; ImageList1: TImageList; LblFirstDayOfWeek: TLabel; @@ -68,6 +69,7 @@ type procedure BtnDeleteResClick(Sender: TObject); procedure BtnNewResClick(Sender: TObject); procedure BtnEditResClick(Sender: TObject); + procedure CbAllowInplaceEditingChange(Sender: TObject); procedure CbFirstDayOfWeekChange(Sender: TObject); procedure CbGranularityChange(Sender: TObject); procedure CbLanguagesChange(Sender: TObject); @@ -235,6 +237,14 @@ begin VpResourceEditDialog1.AddNewResource; 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); begin VpWeekView1.WeekStartsOn := TVpDayType(CbFirstDayOfWeek.ItemIndex); @@ -428,6 +438,9 @@ begin DaysTrackbar.Position := ini.ReadInteger('Settings', 'VisibleDays', DaysTrackbar.Position); DaysTrackbarChange(nil); + CbAllowInplaceEditing.Checked := ini.ReadBool('Settings', 'AllowInplaceEditing', CbAllowInplaceEditing.Checked); + CbAllowInplaceEditingChange(nil); + finally ini.Free; end; @@ -457,6 +470,7 @@ begin ini.WriteInteger('Settings', 'FirstDayOfWeek', ord(VpWeekView1.WeekStartsOn)); ini.WriteInteger('Settings', 'VisibleDays', VpDayView1.NumDays); ini.WriteBool('Settings', 'AllTasks', VpTaskList1.DisplayOptions.ShowAll); + ini.WriteBool('Settings', 'AllowInplaceEditing', CbAllowInplaceEditing.Checked); finally ini.Free; end; @@ -586,6 +600,7 @@ begin LblTimeFormat.Left := CbTimeFormat.Left - 8 - GetLabelWidth(LblTimeFormat); CbFirstDayOfWeek.Left := CbLanguages.Left; LblFirstDayOfWeek.Left := CbFirstDayOfWeek.Left - 8 - GetLabelWidth(LblFirstDayOfWeek); + CbAllowInplaceEditing.Left := CbLanguages.Left + CbLanguages.Width + 32; RbHideCompletedTasks.Left := RbAllTasks.Left + RbAllTasks.Width + 48; // Next settings work correctly only for Windows. diff --git a/components/tvplanit/languages/demo.de.po b/components/tvplanit/languages/demo.de.po index fa6086de8..4ff365900 100644 --- a/components/tvplanit/languages/demo.de.po +++ b/components/tvplanit/languages/demo.de.po @@ -145,6 +145,10 @@ msgstr "Neu" msgid "Turbo Power VisualPlanIt Demo" msgstr "Turbo Power VisualPlanIt Demo" +#: tmainform.cballowinplaceediting.caption +msgid "Allow inplace editing" +msgstr "" + #: tmainform.cbgranularity.text msgid "30 Min" msgstr "30 Min" @@ -237,3 +241,4 @@ msgstr "Aufgaben" #: tmainform.titlelbl.caption msgid "TitleLbl" msgstr "" + diff --git a/components/tvplanit/languages/demo.po b/components/tvplanit/languages/demo.po index bd708ab01..4deaa6812 100644 --- a/components/tvplanit/languages/demo.po +++ b/components/tvplanit/languages/demo.po @@ -134,6 +134,10 @@ msgstr "" msgid "Turbo Power VisualPlanIt Demo" msgstr "" +#: tmainform.cballowinplaceediting.caption +msgid "Allow inplace editing" +msgstr "" + #: tmainform.cbgranularity.text msgid "30 Min" msgstr "" diff --git a/components/tvplanit/source/vpdayview.pas b/components/tvplanit/source/vpdayview.pas index 40bce9317..df7bcad20 100644 --- a/components/tvplanit/source/vpdayview.pas +++ b/components/tvplanit/source/vpdayview.pas @@ -267,6 +267,7 @@ type FWrapStyle: TVpDVWrapStyle; FDotDotDotColor: TColor; FShowEventTimes: Boolean; + FAllowInplaceEdit: Boolean; { event variables } FOwnerDrawRowHead: TVpOwnerDrawRowEvent; FOwnerDrawCells: TVpOwnerDrawRowEvent; @@ -454,6 +455,7 @@ type property TabOrder; property Font; 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 ShowEventTimes: Boolean read FShowEventTimes write SetShowEventTimes default true; property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle stored True; @@ -758,6 +760,7 @@ begin FWrapStyle := wsIconFlow; FDotDotDotColor := clBlack; FIncludeWeekends := True; + FAllowInplaceEdit := true; { set up fonts and colors } FHeadAttr.Font.Size := 10; @@ -1925,29 +1928,32 @@ var begin if ReadOnly then Exit; - AllowIt := true; + if not FAllowInplaceEdit then + Exit; + { call the user defined BeforeEdit event } + AllowIt := true; if Assigned(FBeforeEdit) then FBeforeEdit(Self, FActiveEvent, AllowIt); + if not AllowIt then + exit; - if AllowIt then begin - { create and spawn the in-place editor } - if dvInPlaceEditor = nil then begin - dvInPlaceEditor := TVpDvInPlaceEdit.Create(Self); - dvInPlaceEditor.Parent := self; - dvInPlaceEditor.OnExit := EndEdit; - end; - dvInPlaceEditor.SetBounds( - dvActiveIconRec.Right + FGutterWidth + TextMargin, - dvActiveEventRec.Top + TextMargin, - dvActiveEventRec.Right, - dvActiveEventRec.Bottom - 1 - ); - dvInPlaceEditor.Show; - dvInPlaceEditor.Text := FActiveEvent.Description; - Invalidate; - dvInPlaceEditor.SetFocus; + { create and spawn the in-place editor } + if dvInPlaceEditor = nil then begin + dvInPlaceEditor := TVpDvInPlaceEdit.Create(Self); + dvInPlaceEditor.Parent := self; + dvInPlaceEditor.OnExit := EndEdit; end; + dvInPlaceEditor.SetBounds( + dvActiveIconRec.Right + FGutterWidth + TextMargin, + dvActiveEventRec.Top + TextMargin, + dvActiveEventRec.Right, + dvActiveEventRec.Bottom - 1 + ); + dvInPlaceEditor.Show; + dvInPlaceEditor.Text := FActiveEvent.Description; + Invalidate; + dvInPlaceEditor.SetFocus; end; {=====} diff --git a/components/tvplanit/source/vptasklist.pas b/components/tvplanit/source/vptasklist.pas index 2bd26cda3..28bc6d331 100644 --- a/components/tvplanit/source/vptasklist.pas +++ b/components/tvplanit/source/vptasklist.pas @@ -149,7 +149,8 @@ type FDrawingStyle : TVpDrawingStyle; FTaskID : Integer; FDefaultPopup : TPopupMenu; - FShowIcon : Boolean; + FShowIcon : Boolean; + FAllowInplaceEdit : Boolean; { task variables } FOwnerDrawTask : TVpOwnerDrawTask; FBeforeEdit : TVpBeforeEditTask; @@ -250,6 +251,8 @@ type property TabOrder; property ReadOnly; + property AllowInplaceEditing: Boolean + read FAllowInplaceEdit write FAllowInplaceEdit default true; property DisplayOptions: TVpTaskDisplayOptions read FDisplayOptions write FDisplayOptions; property LineColor: TColor @@ -262,8 +265,8 @@ type read FDrawingStyle write SetDrawingStyle; property Color: TColor read FColor write SetColor; - property ShowIcon : Boolean read FShowIcon write SetShowIcon - default True; + property ShowIcon : Boolean + read FShowIcon write SetShowIcon default True; property ShowResourceName: Boolean read FShowResourceName write SetShowResourceName; { events } @@ -536,6 +539,7 @@ begin FScrollBars := ssVertical; FTaskIndex := -1; FShowIcon := True; + FAllowInplaceEdit := true; SetLength(tlVisibleTaskArray, MaxVisibleTasks); @@ -1506,6 +1510,9 @@ begin if FActiveTask.Complete then Exit; + if not FAllowInplaceEdit then + exit; + AllowIt := true; VisTask := tlTaskIndexToVisibleTask (TaskIndex); @@ -1528,7 +1535,7 @@ begin tlInPlaceEditor.OnExit := EndEdit; end; 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.Font.Assign(Font); tlInPlaceEditor.SelectAll; diff --git a/components/tvplanit/source/vpweekview.pas b/components/tvplanit/source/vpweekview.pas index 84c68aad4..c89ce3b0a 100644 --- a/components/tvplanit/source/vpweekview.pas +++ b/components/tvplanit/source/vpweekview.pas @@ -137,6 +137,7 @@ type FWeekStartsOn: TVpDayType; FDefaultPopup: TPopupMenu; FAllDayEventAttr: TVpAllDayEventAttributes; + FAllowInplaceEdit: Boolean; { event variables } FBeforeEdit: TVpBeforeEditEvent; FAfterEdit: TVpAfterEditEvent; @@ -233,8 +234,8 @@ type property VisibleLines: Integer read FVisibleLines; published - property AllDayEventAttributes: TVpAllDayEventAttributes - read FAllDayEventAttr write FAllDayEventAttr; + property AllDayEventAttributes: TVpAllDayEventAttributes read FAllDayEventAttr write FAllDayEventAttr; + property AllowInplaceEditing: Boolean read FAllowInplaceEdit write FAllowInplaceEdit default true; property Color: TColor read FColor write SetColor; property DateLabelFormat: string read FDateLabelFormat write SetDateLabelFormat; property DayHeadAttributes: TVpDayHeadAttr read FDayHeadAttributes write FDayHeadAttributes; @@ -425,6 +426,7 @@ begin FTimeFormat := tf12Hour; FDateLabelFormat := 'dddd, mmmm dd, yyyy'; FColumnWidth := 200; + FAllowInplaceEdit := true; { set up fonts and colors } // FDayHeadAttributes.Font.Name := 'Tahoma'; @@ -1178,6 +1180,9 @@ var AllowIt: Boolean; begin if ActiveEvent <> nil then begin + if not FAllowInplaceEdit then + exit; + AllowIt := true; { call the user defined BeforeEdit event } if Assigned(FBeforeEdit) then