jvcllaz: Remove Windows unit from JvTimeFramework demo. Autosized layout of some forms.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7098 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-08-07 17:29:39 +00:00
parent 408079c041
commit 7e2bd8e653
11 changed files with 132 additions and 130 deletions

View File

@ -56,7 +56,7 @@
<Unit1>
<Filename Value="tfmain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="PhotoOpMain"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="tfMain"/>
@ -72,7 +72,9 @@
<Unit3>
<Filename Value="tfshare.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Share"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="tfShare"/>
</Unit3>
<Unit4>

View File

@ -25,8 +25,7 @@ begin
mtError, [mbOK], 0);
Halt;
end;
Application.CreateForm(TPhotoOpMain, PhotoOpMain);
Application.CreateForm(TMainForm, MainForm);
Application.CreateForm(TVisibleResources, VisibleResources);
Application.CreateForm(TShare, Share);
Application.CreateForm(TApptEdit, ApptEdit);

View File

@ -1,11 +1,11 @@
object ApptEdit: TApptEdit
Left = 218
Height = 210
Height = 189
Top = 152
Width = 350
AutoSize = True
Caption = 'ApptEdit'
ClientHeight = 210
ClientHeight = 189
ClientWidth = 350
Color = clBtnFace
Font.Color = clWindowText
@ -165,16 +165,13 @@ object ApptEdit: TApptEdit
end
object Image2: TImage
AnchorSideLeft.Control = Image1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Bevel2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Image1
AnchorSideRight.Side = asrBottom
Left = 14
Left = 6
Height = 24
Top = 115
Width = 24
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Bottom = 8

View File

@ -26,10 +26,12 @@
unit tfApptEdit;
{$mode objfpc}{$H+}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ComCtrls, JvTFManager, ExtCtrls, ButtonPanel,
DateTimePicker;
@ -97,7 +99,7 @@ var
DaysGrid : TJvTFDays;
begin
// Just a short cut to save typing :)
DaysGrid := PhotoOpMain.JvTFDays1;
DaysGrid := MainForm.JvTFDays1;
If Assigned(Appt) Then
Begin
@ -122,7 +124,7 @@ begin
Begin
// Assume we are adding a new appt
// Request an appt from the server
Appt := PhotoOpMain.JvTFDays1.ScheduleManager.dbNewAppt('');
Appt := MainForm.JvTFDays1.ScheduleManager.dbNewAppt('');
// Right now this appt object is in a state of flux. It is not
// assigned to any schedules and shouldn't be because we're unsure
// of its data. The caching system is programmed to automatically
@ -205,7 +207,7 @@ begin
If AddingAppt Then
Begin
// Just a shortcut to save some typing :-)
DaysGrid := PhotoOpMain.JvTFDays1;
DaysGrid := MainForm.JvTFDays1;
// Add the appt to selected schedule(s)
For I := 0 to DaysGrid.Cols.Count - 1 do

View File

@ -1,4 +1,4 @@
object PhotoOpMain: TPhotoOpMain
object MainForm: TMainForm
Left = 212
Height = 546
Top = 138

View File

@ -26,22 +26,22 @@
unit tfMain;
{$mode objfpc}{$H+}
interface
uses
LCLIntf,
//Windows, Messages,
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, sqldb, sqlite3conn, //DBTables,
ComCtrls, StdCtrls, Buttons, ExtCtrls, ImgList, DateTimePicker, JvTFManager,
JvTFDays, JvTFGlance, JvTFGlanceTextViewer, JvTFMonths, JvTFWeeks,
JvComponent, JvExControls;
JvTFDays, JvTFGlance, JvTFGlanceTextViewer, JvTFMonths, JvTFWeeks;
type
{ TPhotoOpMain }
{ TMainForm }
TPhotoOpMain = class(TForm)
TMainForm = class(TForm)
ImageList: TImageList;
Label1: TLabel;
Label2: TLabel;
@ -127,7 +127,7 @@ type
end;
var
PhotoOpMain: TPhotoOpMain;
MainForm: TMainForm;
implementation
@ -136,7 +136,7 @@ uses
{$R *.lfm}
procedure TPhotoOpMain.utfScheduleManager1PostAppt(Sender: TObject;
procedure TMainForm.utfScheduleManager1PostAppt(Sender: TObject;
Appt: TJvTFAppt);
var
I : Integer;
@ -190,7 +190,7 @@ begin
End;
end;
procedure TPhotoOpMain.utfScheduleManager1DeleteAppt(Sender: TObject;
procedure TMainForm.utfScheduleManager1DeleteAppt(Sender: TObject;
Appt: TJvTFAppt);
begin
// First delete the appointment from the appointment table
@ -208,7 +208,7 @@ begin
End;
end;
procedure TPhotoOpMain.utfScheduleManager1RefreshAppt(Sender: TObject;
procedure TMainForm.utfScheduleManager1RefreshAppt(Sender: TObject;
Appt: TJvTFAppt);
begin
With GetApptQuery do
@ -244,7 +244,7 @@ begin
End;
end;
procedure TPhotoOpMain.ModeComboChange(Sender: TObject);
procedure TMainForm.ModeComboChange(Sender: TObject);
begin
If ModeCombo.ItemIndex = 0 Then
// Single mode
@ -280,12 +280,12 @@ begin
End;
end;
procedure TPhotoOpMain.ViewSchedsButtonClick(Sender: TObject);
procedure TMainForm.ViewSchedsButtonClick(Sender: TObject);
begin
VisibleResources.ShowModal;
end;
procedure TPhotoOpMain.HideSchedButtonClick(Sender: TObject);
procedure TMainForm.HideSchedButtonClick(Sender: TObject);
var
I,
NameIndex : Integer;
@ -316,7 +316,7 @@ begin
End;
end;
procedure TPhotoOpMain.ResourceComboChange(Sender: TObject);
procedure TMainForm.ResourceComboChange(Sender: TObject);
begin
JvTFDays1.Template.LinearName := ResourceCombo.Text;
JvTFWeeks1.SchedNames.Clear;
@ -327,7 +327,7 @@ begin
JvTFMonths1.Refresh;
end;
procedure TPhotoOpMain.DaysComboChange(Sender: TObject);
procedure TMainForm.DaysComboChange(Sender: TObject);
begin
Case DaysCombo.ItemIndex of
0 : JvTFDays1.Template.LinearDayCount := 31;
@ -340,7 +340,7 @@ begin
End;
end;
procedure TPhotoOpMain.ShareButtonClick(Sender: TObject);
procedure TMainForm.ShareButtonClick(Sender: TObject);
begin
If JvTFDays1.SelAppt <> nil Then
Share.ShowModal
@ -348,17 +348,17 @@ begin
MessageDlg('Please select an appointment.', mtInformation, [mbOK], 0);
end;
procedure TPhotoOpMain.PrevDateButtonClick(Sender: TObject);
procedure TMainForm.PrevDateButtonClick(Sender: TObject);
begin
JvTFDays1.PrevDate;
end;
procedure TPhotoOpMain.NextDateButtonClick(Sender: TObject);
procedure TMainForm.NextDateButtonClick(Sender: TObject);
begin
JvTFDays1.NextDate;
end;
procedure TPhotoOpMain.GotoDatePickerChange(Sender: TObject);
procedure TMainForm.GotoDatePickerChange(Sender: TObject);
begin
// GotoDatePicker.OnCloseUp should also point to this handler
JvTFDays1.GotoDate(GotoDatePicker.Date);
@ -366,7 +366,7 @@ begin
JvTFWeeks1.DisplayDate := GotoDatePicker.Date;
end;
procedure TPhotoOpMain.GotoDatePickerUserInput(Sender: TObject;
procedure TMainForm.GotoDatePickerUserInput(Sender: TObject;
const UserString: String; var DateAndTime: TDateTime;
var AllowChange: Boolean);
begin
@ -374,7 +374,7 @@ begin
GotoDatePicker.OnChange(nil);
end;
procedure TPhotoOpMain.TimeIncComboChange(Sender: TObject);
procedure TMainForm.TimeIncComboChange(Sender: TObject);
begin
Case TimeIncCombo.ItemIndex of
0 : JvTFDays1.Granularity := 60;
@ -392,7 +392,7 @@ begin
End;
end;
procedure TPhotoOpMain.NewApptButtonClick(Sender: TObject);
procedure TMainForm.NewApptButtonClick(Sender: TObject);
begin
// Simply open the EditAppt window. The Appt var of the
// EditAppt form will already be nil (which indicates
@ -400,7 +400,7 @@ begin
ApptEdit.ShowModal;
end;
procedure TPhotoOpMain.EditApptButtonClick(Sender: TObject);
procedure TMainForm.EditApptButtonClick(Sender: TObject);
begin
If Assigned(JvTFDays1.SelAppt) Then
Begin
@ -414,7 +414,7 @@ begin
[mbOK], 0);
end;
procedure TPhotoOpMain.DeleteApptButtonClick(Sender: TObject);
procedure TMainForm.DeleteApptButtonClick(Sender: TObject);
var
Appt : TJvTFAppt;
dbDel : Boolean;
@ -471,14 +471,14 @@ begin
mtInformation, [mbOK], 0);
end;
procedure TPhotoOpMain.JvTFDays1DateChanging(Sender: TObject;
procedure TMainForm.JvTFDays1DateChanging(Sender: TObject;
var NewDate: TDate);
begin
// Make sure all appts are posted before moving on.
JvTFDays1.ScheduleManager.PostAppts;
end;
procedure TPhotoOpMain.JvTFDays1DateChanged(Sender: TObject);
procedure TMainForm.JvTFDays1DateChanged(Sender: TObject);
begin
// Synchronize the tool bar
With JvTFDays1.Template do
@ -488,7 +488,7 @@ begin
GotoDatePicker.Date := CompDate;
end;
procedure TPhotoOpMain.JvTFDays1GranularityChanged(Sender: TObject);
procedure TMainForm.JvTFDays1GranularityChanged(Sender: TObject);
begin
// Update the TimeIncCombo when the granularity is changed.
// (This can be done by <Ctrl> + <Insert> and <Ctrl> + <Delete>)
@ -509,7 +509,7 @@ begin
End;
end;
procedure TPhotoOpMain.JvTFDays1DblClick(Sender: TObject);
procedure TMainForm.JvTFDays1DblClick(Sender: TObject);
begin
With JvTFDays1 do
If ValidSelection Then
@ -519,7 +519,7 @@ begin
NewApptButtonClick(nil);
end;
procedure TPhotoOpMain.FormShow(Sender: TObject);
procedure TMainForm.FormShow(Sender: TObject);
var
ResName : String;
begin
@ -574,7 +574,7 @@ begin
TimeIncComboChange(nil);
end;
procedure TPhotoOpMain.PrintButtonClick(Sender: TObject);
procedure TMainForm.PrintButtonClick(Sender: TObject);
begin
(******************** wp: deactivated due to stack overflow ************
With JvTFDaysPrinter1 do
@ -598,7 +598,7 @@ begin
************************)
end;
procedure TPhotoOpMain.JvTFDaysPrinter1ApptProgress(Sender: TObject;
procedure TMainForm.JvTFDaysPrinter1ApptProgress(Sender: TObject;
Current, Total: Integer);
begin
If Current > Total Then
@ -609,7 +609,7 @@ begin
PrintProgress.ProgressBar1.Position := Current;
end;
procedure TPhotoOpMain.JvTFDaysPrinter1AssembleProgress(Sender: TObject;
procedure TMainForm.JvTFDaysPrinter1AssembleProgress(Sender: TObject;
Current, Total: Integer);
begin
PrintProgress.Label2.Caption := 'Assembling page ' + IntToStr(Current) +
@ -618,7 +618,7 @@ begin
PrintProgress.ProgressBar1.Position := Current;
end;
procedure TPhotoOpMain.JvTFDaysPrinter1PrintProgress(Sender: TObject;
procedure TMainForm.JvTFDaysPrinter1PrintProgress(Sender: TObject;
Current, Total: Integer);
begin
PrintProgress.Label2.Caption := 'Printing page ' + IntToStr(Current) +
@ -627,24 +627,24 @@ begin
PrintProgress.ProgressBar1.Position := Current;
end;
procedure TPhotoOpMain.Label2Click(Sender: TObject);
procedure TMainForm.Label2Click(Sender: TObject);
begin
OpenURL('https://icons8.com');
end;
procedure TPhotoOpMain.Label2MouseEnter(Sender: TObject);
procedure TMainForm.Label2MouseEnter(Sender: TObject);
begin
Label2.Font.Style := Label2.Font.Style + [fsUnderline];
Screen.Cursor := crHandPoint;
end;
procedure TPhotoOpMain.Label2MouseLeave(Sender: TObject);
procedure TMainForm.Label2MouseLeave(Sender: TObject);
begin
Label2.Font.Style := Label2.Font.Style - [fsUnderline];
Screen.Cursor := crDefault;
end;
procedure TPhotoOpMain.utfScheduleManager1LoadBatch(Sender: TObject;
procedure TMainForm.utfScheduleManager1LoadBatch(Sender: TObject;
BatchName: String; BatchStartDate, BatchEndDate: TDate);
var
Appt : TJvTFAppt;
@ -699,7 +699,7 @@ begin
End;
end;
procedure TPhotoOpMain.FormCreate(Sender: TObject);
procedure TMainForm.FormCreate(Sender: TObject);
var
fn: String;
begin

View File

@ -26,10 +26,12 @@
unit tfPrintProgress;
{$mode objfpc}{$H+}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ComCtrls;
type
@ -51,7 +53,8 @@ var
implementation
uses tfMain;
uses
tfMain;
{$R *.lfm}

View File

@ -1,44 +1,47 @@
object Share: TShare
Left = 738
Height = 216
Top = 285
Width = 271
Height = 216
AutoSize = True
Caption = 'Share'
ClientHeight = 216
ClientWidth = 271
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
Position = poScreenCenter
Scaled = False
OnClose = FormClose
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 16
Position = poScreenCenter
LCLVersion = '2.1.0.0'
Scaled = False
object ResourcesCheckList: TCheckListBox
Left = 16
Left = 8
Height = 160
Top = 8
Width = 225
Height = 129
ItemHeight = 16
Width = 255
Align = alClient
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Around = 8
Constraints.MinHeight = 140
ItemHeight = 0
TabOrder = 0
end
object OKButton: TBitBtn
Left = 40
Top = 152
Width = 75
Height = 25
object ButtonPanel1: TButtonPanel
Left = 6
Height = 34
Top = 176
Width = 259
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 1
Kind = bkOK
end
object CancelButton: TBitBtn
Left = 152
Top = 152
Width = 75
Height = 25
TabOrder = 2
Kind = bkCancel
ShowButtons = [pbOK, pbCancel]
end
end

View File

@ -26,17 +26,21 @@
unit tfShare;
{$mode objfpc}{$H+}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, checklst;
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, checklst, ButtonPanel;
type
{ TShare }
TShare = class(TForm)
ButtonPanel1: TButtonPanel;
ResourcesCheckList: TCheckListBox;
OKButton: TBitBtn;
CancelButton: TBitBtn;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var TheAction: TCloseAction);
private
@ -61,12 +65,12 @@ var
I : Integer;
begin
// First, get the selected appointment
Appt := PhotoOpMain.JvTFDays1.SelAppt;
Appt := MainForm.JvTFDays1.SelAppt;
// now roll through the resource list and check all resources
// that are found in the appointment's list of schedules.
With ResourcesCheckList do
For I := 0 to Items.Count - 1 do
with ResourcesCheckList do
for I := 0 to Items.Count - 1 do
Checked[I] := Appt.IndexOfSchedule(Items[I]) > -1;
end;
@ -93,13 +97,13 @@ begin
If TempList.Count > 0 Then
// If at least one resource then change the appointment's
// schedule list to match the temp list.
PhotoOpMain.JvTFDays1.SelAppt.AssignSchedules(TempList)
MainForm.JvTFDays1.SelAppt.AssignSchedules(TempList)
Else
If MessageDlg('You have removed this appointment from all schedules.' +
' This will cause the appointment to be deleted.' + #13#10 +
'Are you sure this is what you want to do?',
mtConfirmation, [mbYes, mbNo], 0) = mrYes Then
With PhotoOpMain.JvTFDays1 do
With MainForm.JvTFDays1 do
// Delete the appointment if that is what the user wants to do.
ScheduleManager.dbDeleteAppt(SelAppt)
Else

View File

@ -13,41 +13,30 @@ object VisibleResources: TVisibleResources
LCLVersion = '2.1.0.0'
Scaled = False
object ResourcesCheckList: TCheckListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 16
Height = 129
Top = 16
Width = 239
Left = 8
Height = 149
Top = 8
Width = 255
Align = alClient
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 16
BorderSpacing.Top = 16
BorderSpacing.Right = 16
BorderSpacing.Around = 8
ItemHeight = 0
TabOrder = 0
end
object OKButton: TBitBtn
AnchorSideLeft.Control = ResourcesCheckList
Left = 40
Height = 25
Top = 160
Width = 75
BorderSpacing.Left = 24
Kind = bkOK
object ButtonPanel1: TButtonPanel
Left = 6
Height = 34
Top = 165
Width = 259
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 1
end
object CancelButton: TBitBtn
AnchorSideRight.Control = ResourcesCheckList
AnchorSideRight.Side = asrBottom
Left = 156
Height = 25
Top = 160
Width = 75
Anchors = [akTop, akRight]
BorderSpacing.Right = 24
Kind = bkCancel
TabOrder = 2
ShowButtons = [pbOK, pbCancel]
end
end

View File

@ -31,14 +31,17 @@ unit tfVisibleResources;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, checklst;
//Windows, Messages,
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, checklst, ButtonPanel;
type
{ TVisibleResources }
TVisibleResources = class(TForm)
ButtonPanel1: TButtonPanel;
ResourcesCheckList: TCheckListBox;
OKButton: TBitBtn;
CancelButton: TBitBtn;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var TheAction: TCloseAction);
private
@ -62,7 +65,7 @@ var
begin
// Check the template and check any resources currently
// visible in the grid
With PhotoOpMain.JvTFDays1.Template do
With MainForm.JvTFDays1.Template do
For I := 0 to ResourcesCheckList.Items.Count - 1 do
ResourcesCheckList.Checked[I] :=
CompNames.IndexOf(ResourcesCheckList.Items[I]) > -1;
@ -76,17 +79,17 @@ begin
If ModalResult = mrOK Then
begin
// First, clear the old resources from the template
PhotoOpMain.JvTFDays1.Template.CompNames.Clear;
PhotoOpMain.JvTFWeeks1.SchedNames.Clear;
PhotoOpMain.JvTFMonths1.SchedNames.Clear;
MainForm.JvTFDays1.Template.CompNames.Clear;
MainForm.JvTFWeeks1.SchedNames.Clear;
MainForm.JvTFMonths1.SchedNames.Clear;
// Next, add the new resources to the template
For I := 0 to ResourcesCheckList.Items.Count - 1 do
If ResourcesCheckList.Checked[I] Then
begin
PhotoOpMain.JvTFDays1.Template.CompNames.Add(ResourcesCheckList.Items[I]);
PhotoOpMain.JvTFWeeks1.SchedNames.Add(ResourcesCheckList.Items[I]);
PhotoOpMain.JvTFMonths1.SchedNames.Add(ResourcesCheckList.Items[I]);
MainForm.JvTFDays1.Template.CompNames.Add(ResourcesCheckList.Items[I]);
MainForm.JvTFWeeks1.SchedNames.Add(ResourcesCheckList.Items[I]);
MainForm.JvTFMonths1.SchedNames.Add(ResourcesCheckList.Items[I]);
end;
end;
end;