jvcllaz: Printing layout improvements in JvTimeFrame demo.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7117 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-08-10 21:57:19 +00:00
parent 3297b8d309
commit d794bb55c2
4 changed files with 62 additions and 60 deletions

View File

@ -56,37 +56,43 @@ object MainForm: TMainForm
TimeBlockProps.SelBlockHdrAttr.FrameColor = clBlack TimeBlockProps.SelBlockHdrAttr.FrameColor = clBlack
ApptAttr.Font.Color = clWindowText ApptAttr.Font.Color = clWindowText
ApptAttr.ParentFont = False ApptAttr.ParentFont = False
ApptAttr.FrameColor = clGray
SelApptAttr.Font.Color = clWindowText SelApptAttr.Font.Color = clWindowText
SelApptAttr.ParentFont = False SelApptAttr.ParentFont = False
SelApptAttr.FrameColor = clGray
HdrAttr.Font.Color = clWindowText HdrAttr.Font.Color = clWindowText
HdrAttr.Font.Style = [fsBold] HdrAttr.Font.Style = [fsBold]
HdrAttr.ParentFont = False HdrAttr.ParentFont = False
HdrAttr.FrameColor = clBlack HdrAttr.Frame3D = False
HdrAttr.FrameColor = clSilver
SelHdrAttr.Font.Color = clBlack SelHdrAttr.Font.Color = clBlack
SelHdrAttr.Font.Style = [fsBold] SelHdrAttr.Font.Style = [fsBold]
SelHdrAttr.ParentFont = False SelHdrAttr.ParentFont = False
SelHdrAttr.FrameColor = clBlack SelHdrAttr.Frame3D = False
SelHdrAttr.FrameColor = clSilver
FancyRowHdrAttr.Hr2400 = False FancyRowHdrAttr.Hr2400 = False
FancyRowHdrAttr.MinorFont.Color = clWindowText FancyRowHdrAttr.MinorFont.Color = clWindowText
FancyRowHdrAttr.MajorFont.Color = clWindowText FancyRowHdrAttr.MajorFont.Color = clWindowText
FancyRowHdrAttr.MajorFont.Height = -21 FancyRowHdrAttr.MajorFont.Height = -21
FancyRowHdrAttr.TickColor = clSilver
SelFancyRowHdrAttr.Hr2400 = True SelFancyRowHdrAttr.Hr2400 = True
SelFancyRowHdrAttr.MinorFont.Color = clBlack SelFancyRowHdrAttr.MinorFont.Color = clBlack
SelFancyRowHdrAttr.MajorFont.Color = clBlack SelFancyRowHdrAttr.MajorFont.Color = clBlack
SelFancyRowHdrAttr.MajorFont.Height = -21 SelFancyRowHdrAttr.MajorFont.Height = -21
SelFancyRowHdrAttr.TickColor = clBlack SelFancyRowHdrAttr.TickColor = clSilver
GridLineColor = clSilver GridLineColor = clSilver
PrimeTime.StartTime = 0.333333333333333 PrimeTime.StartTime = 0.333333333333333
PrimeTime.EndTime = 0.708333333333333 PrimeTime.EndTime = 0.708333333333333
GroupHdrAttr.Color = clWindow
GroupHdrAttr.Font.Color = clWindowText GroupHdrAttr.Font.Color = clWindowText
GroupHdrAttr.Font.Height = -19 GroupHdrAttr.Font.Height = -19
GroupHdrAttr.Font.Style = [fsBold] GroupHdrAttr.Font.Style = [fsBold]
GroupHdrAttr.ParentFont = False GroupHdrAttr.ParentFont = False
GroupHdrAttr.FrameColor = clBlack GroupHdrAttr.Frame3D = False
GroupHdrAttr.FrameColor = clSilver
SelGroupHdrAttr.Font.Color = clBlack SelGroupHdrAttr.Font.Color = clBlack
SelGroupHdrAttr.ParentFont = False SelGroupHdrAttr.ParentFont = False
SelGroupHdrAttr.FrameColor = clBlack SelGroupHdrAttr.FrameColor = clBlack
WeekendColor = 14671839
LeftCol = -1 LeftCol = -1
OnDateChanging = JvTFDays1DateChanging OnDateChanging = JvTFDays1DateChanging
OnDateChanged = JvTFDays1DateChanged OnDateChanged = JvTFDays1DateChanged

View File

@ -71,10 +71,8 @@ end;
procedure TSettingsForm.SettingsToControls; procedure TSettingsForm.SettingsToControls;
begin begin
if GlobalSettings.Hr2400 then cbTimeFormat.ItemIndex := ord(not GlobalSettings.Hr2400);
cbTimeFormat.ItemIndex := 0
else
cbTimeFormat.ItemIndex := 1;
cbFirstDayOfWeek.ItemIndex := ord(GlobalSettings.FirstDayOfWeek); cbFirstDayOfWeek.ItemIndex := ord(GlobalSettings.FirstDayOfWeek);
edPrimeTimeStart.Time := GlobalSettings.PrimeTimeStart; edPrimeTimeStart.Time := GlobalSettings.PrimeTimeStart;
edPrimeTimeEnd.Time := GlobalSettings.PrimeTimeEnd; edPrimeTimeEnd.Time := GlobalSettings.PrimeTimeEnd;

View File

@ -69,7 +69,14 @@ const
gcGroupHdr = -2; gcGroupHdr = -2;
gcHdr = -1; gcHdr = -1;
DEFAULT_COL_HDR_HEIGHT = 28;
DEFAULT_DEF_COL_WIDTH = 100;
DEFAULT_GRANULARITY = 30;
DEFAULT_GROUP_HDR_HEIGHT = 28;
DEFAULT_MIN_ROW_HEIGHT = 12;
DEFAULT_PRIMETIME_COLOR = $00C4FFFF; DEFAULT_PRIMETIME_COLOR = $00C4FFFF;
DEFAULT_ROW_HDR_WIDTH = 60;
DEFAULT_ROW_HEIGHT = 20;
type type
EJvTFDaysError = class(Exception); EJvTFDaysError = class(Exception);
@ -1285,22 +1292,22 @@ type
// property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle; // property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle;
// grid layout properties // grid layout properties
property AutoSizeCols: Boolean read FAutoSizeCols write SetAutoSizeCols default True; property AutoSizeCols: Boolean read FAutoSizeCols write SetAutoSizeCols default True;
property Granularity: Integer read FGranularity write SetGranularity default 30; property Granularity: Integer read FGranularity write SetGranularity default DEFAULT_GRANULARITY;
property ColHdrHeight: Integer read FColHdrHeight write SetColHdrHeight default 25; property ColHdrHeight: Integer read FColHdrHeight write SetColHdrHeight default DEFAULT_COL_HDR_HEIGHT;
property Cols: TJvTFDaysCols read FCols write SetCols; property Cols: TJvTFDaysCols read FCols write SetCols;
property DefColWidth: Integer read FDefColWidth write FDefColWidth default 100; property DefColWidth: Integer read FDefColWidth write FDefColWidth default DEFAULT_DEF_COL_WIDTH;
property MinColWidth: Integer read FMinColWidth write SetMinColWidth default AbsMinColWidth; property MinColWidth: Integer read FMinColWidth write SetMinColWidth default AbsMinColWidth;
property MinRowHeight: Integer read FMinRowHeight write SetMinRowHeight default 12; property MinRowHeight: Integer read FMinRowHeight write SetMinRowHeight default DEFAULT_MIN_ROW_HEIGHT;
property Options: TJvTFDaysOptions read FOptions write SetOptions property Options: TJvTFDaysOptions read FOptions write SetOptions
default [agoSizeCols, agoSizeRows, agoSizeColHdr, agoSizeRowHdr, default [agoSizeCols, agoSizeRows, agoSizeColHdr, agoSizeRowHdr,
agoSizeAppt, agoMoveAppt, agoEditing, agoShowPics, agoSizeAppt, agoMoveAppt, agoEditing, agoShowPics,
agoShowText, agoShowApptHints, agoQuickEntry, agoShowSelHint]; agoShowText, agoShowApptHints, agoQuickEntry, agoShowSelHint];
property RowHdrWidth: Integer read FRowHdrWidth write SetRowHdrWidth default 50; property RowHdrWidth: Integer read FRowHdrWidth write SetRowHdrWidth default DEFAULT_ROW_HDR_WIDTH;
property RowHeight: Integer read FRowHeight write SetRowHeight default 19; property RowHeight: Integer read FRowHeight write SetRowHeight default DEFAULT_ROW_HEIGHT;
property ShowFocus:Boolean read FShowFocus write SetShowFocus default True; property ShowFocus:Boolean read FShowFocus write SetShowFocus default True;
property Template: TJvTFDaysTemplate read FTemplate write FTemplate; property Template: TJvTFDaysTemplate read FTemplate write FTemplate;
property Grouping: TJvTFDaysGrouping read FGrouping write SetGrouping; property Grouping: TJvTFDaysGrouping read FGrouping write SetGrouping;
property GroupHdrHeight: Integer read FGroupHdrHeight write SetGroupHdrHeight default 25; property GroupHdrHeight: Integer read FGroupHdrHeight write SetGroupHdrHeight default DEFAULT_GROUP_HDR_HEIGHT;
property GridStartTime: TTime read FGridStartTime write SetGridStartTime; property GridStartTime: TTime read FGridStartTime write SetGridStartTime;
property GridEndTime: TTime read FGridEndTime write SetGridEndTime; property GridEndTime: TTime read FGridEndTime write SetGridEndTime;
@ -1710,8 +1717,8 @@ type
property MinRowHeight: Integer read FMinRowHeight write SetMinRowHeight; property MinRowHeight: Integer read FMinRowHeight write SetMinRowHeight;
property PrimeTime: TJvTFDaysPrimeTime read FPrimeTime write SetPrimeTime; property PrimeTime: TJvTFDaysPrimeTime read FPrimeTime write SetPrimeTime;
property RowHdrType: TJvTFRowHdrType read FRowHdrType write SetTFRowHdrType; property RowHdrType: TJvTFRowHdrType read FRowHdrType write SetTFRowHdrType;
property RowHdrWidth: Integer read FRowHdrWidth write SetRowHdrWidth; property RowHdrWidth: Integer read FRowHdrWidth write SetRowHdrWidth default 0;
property RowHeight: Integer read FRowHeight write SetRowHeight; property RowHeight: Integer read FRowHeight write SetRowHeight default 0;
property ShowPics: Boolean read FShowPics write SetShowPics; property ShowPics: Boolean read FShowPics write SetShowPics;
property ShowText: Boolean read FShowText write SetShowText; property ShowText: Boolean read FShowText write SetShowText;
property Thresholds: TJvTFDaysThresholds read FThresholds property Thresholds: TJvTFDaysThresholds read FThresholds
@ -4067,20 +4074,20 @@ begin
//set property defaults //set property defaults
// FBorderStyle := bsSingle; // FBorderStyle := bsSingle;
FColHdrHeight := 30; FColHdrHeight := DEFAULT_COL_HDR_HEIGHT;
FGroupHdrHeight := 25; FGroupHdrHeight := DEFAULT_GROUP_HDR_HEIGHT;
FRowHdrWidth := 50; FRowHdrWidth := DEFAULT_ROW_HDR_WIDTH;
FRowHeight := 19; FRowHeight := DEFAULT_ROW_HEIGHT;
FGranularity := 30; FGranularity := DEFAULT_GRANULARITY;
FTopRow := 0; FTopRow := 0;
FFocusedRow := -1; FFocusedRow := -1;
FMinColWidth := AbsMinColWidth; FMinColWidth := AbsMinColWidth;
FLeftCol := -1; FLeftCol := -1;
FFocusedCol := -1; FFocusedCol := -1;
FDefColWidth := 100; FDefColWidth := DEFAULT_DEF_COL_WIDTH;
FVisibleScrollBars := []; FVisibleScrollBars := [];
FAutoSizeCols := True; FAutoSizeCols := True;
FMinRowHeight := 12; FMinRowHeight := DEFAULT_MIN_ROW_HEIGHT;
ParentColor := False; ParentColor := False;
Color := clSilver; Color := clSilver;
FOptions := [agoSizeCols, agoSizeRows, agoSizeColHdr, agoSizeRowHdr, FOptions := [agoSizeCols, agoSizeRows, agoSizeColHdr, agoSizeRowHdr,
@ -6606,13 +6613,11 @@ begin
Lbl := IntToStr(PrevHour - 12) Lbl := IntToStr(PrevHour - 12)
else else
Lbl := IntToStr(PrevHour); Lbl := IntToStr(PrevHour);
if (PrevHour = 0) or (PrevHour = 12) then
{ if FirstMajor or (PrevHour = 0) or (PrevHour = 12) then
if PrevHour < 12 then if PrevHour < 12 then
Lbl := Lbl + 'a' Lbl := Lbl + 'a'
else else
Lbl := Lbl + 'p'; Lbl := Lbl + 'p';
}
end; end;
if PrevHrSel then if PrevHrSel then
@ -6647,7 +6652,7 @@ begin
ACanvas.FillRect(ARect); ACanvas.FillRect(ARect);
MinorRect := ARect; MinorRect := ARect;
MinorRect.Left := (MinorRect.Right - GetMinorTickLength) div 2; MinorRect.Left := MinorRect.Right - GetMinorTickLength;
if Selected then if Selected then
begin begin
@ -6681,10 +6686,12 @@ begin
ACanvas.Font.Assign(Attr.MinorFont); ACanvas.Font.Assign(Attr.MinorFont);
// draw the focus rect if needed // draw the focus rect if needed
if (RowNum = FocusedRow) and Focused and ShowFocus then if (RowNum = FocusedRow) and Focused and ShowFocus and (LabelStr <> '') then
begin begin
InflateRect(MinorRect, -2, -2); MinorRect := TxtRect;
MinorRect.Left := MinorRect.Right - ACanvas.TextWidth(LabelStr) - 2; InflateRect(MinorRect, 0, -1);
inc(MinorRect.Right, 2);
MinorRect.Left := TxtRect.Right - ACanvas.TextWidth(LabelStr) - 2;
ManualFocusRect(ACanvas, MinorRect); ManualFocusRect(ACanvas, MinorRect);
end; end;
@ -6699,7 +6706,7 @@ function TJvTFDays.GetMinorLabel(RowNum: Integer): string;
const const
Full24 = 'h:nn'; Full24 = 'h:nn';
FullAP = 'h:nna/p'; FullAP = 'h:nna/p';
MinOnly = ':nn'; MinOnly = 'nn';
var var
FirstHourRow: Integer; FirstHourRow: Integer;
TimeFmt: string; TimeFmt: string;
@ -6707,9 +6714,12 @@ var
// LastFullRow, LastHourStart: Integer; // LastFullRow, LastHourStart: Integer;
// LastHour: Word; // LastHour: Word;
begin begin
if Granularity = 60 then if Granularity = 60 then begin
if FancyRowHdrAttr.Hr2400 then
TimeFmt := Full24 TimeFmt := Full24
else else
TimeFmt := FullAP
end else
TimeFmt := MinOnly; TimeFmt := MinOnly;
// else // else
// if (RowNum = TopRow) and (not RowStartsHour(RowNum) or (PossVisibleRows = 1)) then // if (RowNum = TopRow) and (not RowStartsHour(RowNum) or (PossVisibleRows = 1)) then
@ -6727,9 +6737,6 @@ begin
// TimeFmt := MinOnly; // TimeFmt := MinOnly;
// end; // end;
if (TimeFmt = Full24) and not FancyRowHdrAttr.Hr2400 then
TimeFmt := FullAP;
// Get the Row Time // Get the Row Time
RowTime := RowToTime(RowNum); RowTime := RowToTime(RowNum);
@ -6773,7 +6780,7 @@ begin
try try
TempFont.Assign(Canvas.Font); TempFont.Assign(Canvas.Font);
Canvas.Font.Assign(FancyRowHdrAttr.MinorFont); Canvas.Font.Assign(FancyRowHdrAttr.MinorFont);
Result := Canvas.TextWidth('22:22a') - 10; Result := Canvas.TextWidth('00') + 6;
Canvas.Font.Assign(TempFont); Canvas.Font.Assign(TempFont);
finally finally
TempFont.Free; TempFont.Free;
@ -13004,8 +13011,9 @@ begin
begin begin
if I <> PageInfo.StartRow + 1 then if I <> PageInfo.StartRow + 1 then
begin begin
ARect.Left := 1; // Allow for a small margin on ARect.Left side ARect.Left := ScreenToPrinter(2, true); // Allow for a small margin on ARect.Left side
ARect.Right := RowHdrWidth; // No "cutting" before the end of the cell. ARect.Right := RowHdrWidth - MinorTickLength;
// ARect.Right := RowHdrWidth; // No "cutting" before the end of the cell.
ARect.Top := CellRect(-1, HourStartRow(PrevHour), PageInfo).Top; ARect.Top := CellRect(-1, HourStartRow(PrevHour), PageInfo).Top;
//group if ARect.Top < ColHdrHeight then //group if ARect.Top < ColHdrHeight then
@ -13043,7 +13051,7 @@ begin
ACanvas.Brush.Style := bsClear; ACanvas.Brush.Style := bsClear;
DrawText(ACanvas.Handle, PChar(Lbl), -1, ARect, DrawText(ACanvas.Handle, PChar(Lbl), -1, ARect,
DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER); DT_NOPREFIX or DT_SINGLELINE or DT_CENTER or DT_VCENTER);
if Assigned(FOnDrawMajorRowHdr) then if Assigned(FOnDrawMajorRowHdr) then
FOnDrawMajorRowHdr(Self, ACanvas, ARect, I - 1, False); FOnDrawMajorRowHdr(Self, ACanvas, ARect, I - 1, False);
@ -13145,8 +13153,8 @@ begin
// set up a 2 pel margin on the right and bottom sides // set up a 2 pel margin on the right and bottom sides
TxtRect := ARect; TxtRect := ARect;
TxtRect.Right := TxtRect.Right - 2; TxtRect.Right := TxtRect.Right - ScreenToPrinter(2, true);
TxtRect.Bottom := TxtRect.Bottom - 2; TxtRect.Bottom := TxtRect.Bottom - ScreenToPrinter(2, true);
// now draw the LabelStr right aligned // now draw the LabelStr right aligned
ACanvas.Font.Assign(FancyRowHdrAttr.MinorFont); ACanvas.Font.Assign(FancyRowHdrAttr.MinorFont);
@ -13381,7 +13389,7 @@ function TJvTFDaysPrinter.GetMinorLabel(RowNum: Integer;
const const
Full24 = 'h:nn'; Full24 = 'h:nn';
FullAP = 'h:nna/p'; FullAP = 'h:nna/p';
MinOnly = ':nn'; MinOnly = 'nn';
var var
TimeFmt: string; TimeFmt: string;
LastFullRow, LastHourStart: Integer; LastFullRow, LastHourStart: Integer;
@ -13419,7 +13427,8 @@ begin
try try
TempFont.Assign(ACanvas.Font); TempFont.Assign(ACanvas.Font);
ACanvas.Font.Assign(FancyRowHdrAttr.MinorFont); ACanvas.Font.Assign(FancyRowHdrAttr.MinorFont);
Result := ACanvas.TextWidth('22:22a'); Result := ACanvas.TextWidth('00') + ScreenToPrinter(6, true);
// Result := ACanvas.TextWidth('22:22a');
ACanvas.Font.Assign(TempFont); ACanvas.Font.Assign(TempFont);
finally finally
TempFont.Free; TempFont.Free;

View File

@ -4340,15 +4340,6 @@ const
var var
PPI: Integer; PPI: Integer;
begin begin
(**************** DONE
PPI := 300; // wp -- just a workaround for next commented lines...
{ wp --- to do
if Horizontal then
PPI := Windows.GetDeviceCaps(Printer.Handle, LOGPIXELSX)
else
PPI := Windows.GetDeviceCaps(Printer.Handle, LOGPIXELSY);
}
******************)
if Horizontal then if Horizontal then
PPI := Printer.XDPI PPI := Printer.XDPI
else else
@ -4711,11 +4702,9 @@ begin
} }
LCLIntf.SetViewportOrgEx(aCanvas.Handle, BodyLeft, BodyTop, nil); LCLIntf.SetViewportOrgEx(aCanvas.Handle, BodyLeft, BodyTop, nil);
// Windows.SetViewPortOrgEx(aCanvas.Handle, BodyLeft, BodyTop, nil);
DrawBody(aCanvas, Rect(BodyLeft, BodyTop, BodyWidth - BodyLeft, DrawBody(aCanvas, Rect(BodyLeft, BodyTop, BodyWidth - BodyLeft,
BodyHeight - BodyTop), FPages.Count); BodyHeight - BodyTop), FPages.Count);
LCLIntf.SetViewPortOrgEx(aCanvas.Handle, 0, 0, nil); LCLIntf.SetViewPortOrgEx(aCanvas.Handle, 0, 0, nil);
// Windows.SetViewPortOrgEx(aCanvas.Handle, 0, 0, nil);
if DirectPrint then if DirectPrint then
begin begin
GetHeaderFooterRects(HeaderRect, FooterRect); GetHeaderFooterRects(HeaderRect, FooterRect);
@ -4742,7 +4731,7 @@ begin
Printer.Title := Title; Printer.Title := Title;
Printer.BeginDoc; Printer.BeginDoc;
{ wp --- to do ...
if not Printer.Aborted then if not Printer.Aborted then
Printer.Canvas.Draw(0, 0, Pages[0]); Printer.Canvas.Draw(0, 0, Pages[0]);
@ -4762,7 +4751,7 @@ begin
FOnPrintProgress(Self, I, PageCount); FOnPrintProgress(Self, I, PageCount);
Application.ProcessMessages; Application.ProcessMessages;
end; end;
}
if not Printer.Aborted then if not Printer.Aborted then
Printer.EndDoc; Printer.EndDoc;
end; end;