tvplanit: Extended resource file (vpbasepng.res) intended for three sizes of the internally used images. Update TaskListPainter to use the icon according to the best screen resolution.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5894 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-05-22 17:50:31 +00:00
parent 52d104e593
commit 46888f3207
14 changed files with 141 additions and 74 deletions

View File

@ -7,7 +7,6 @@
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/> <MainUnit Value="0"/>
<Title Value="demo"/> <Title Value="demo"/>
<Scaled Value="True"/>
<ResourceType Value="res"/> <ResourceType Value="res"/>
<UseXPManifest Value="True"/> <UseXPManifest Value="True"/>
<XPManifest> <XPManifest>

View File

@ -13,7 +13,6 @@ uses
{$R *.res} {$R *.res}
begin begin
Application.Scaled := True;
RequireDerivedFormResource := True; RequireDerivedFormResource := True;
Application.Initialize; Application.Initialize;
Application.CreateForm(TDemoDM, DemoDM); Application.CreateForm(TDemoDM, DemoDM);

View File

@ -9,7 +9,7 @@ object MainForm: TMainForm
Menu = MainMenu1 Menu = MainMenu1
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnCreate = FormCreate OnCreate = FormCreate
LCLVersion = '1.9.0.0' LCLVersion = '1.6.4.0'
object Panel1: TPanel object Panel1: TPanel
Left = 125 Left = 125
Height = 576 Height = 576
@ -400,7 +400,7 @@ object MainForm: TMainForm
MaxVisibleTasks = 250 MaxVisibleTasks = 250
TaskHeadAttributes.Color = clSilver TaskHeadAttributes.Color = clSilver
TaskHeadAttributes.Font.Style = [fsItalic] TaskHeadAttributes.Font.Style = [fsItalic]
DrawingStyle = ds3d DrawingStyle = dsFlat
ShowResourceName = True ShowResourceName = True
end end
end end

View File

@ -766,6 +766,7 @@ var
lang: String; lang: String;
L,T, W,H: Integer; L,T, W,H: Integer;
R: TRect; R: TRect;
n: Integer;
begin begin
ini := TMemIniFile.Create(ChangeFileExt(Application.ExeName, '.ini')); ini := TMemIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
try try
@ -822,8 +823,9 @@ begin
CbAddressBuilder.ItemIndex := 0 else CbAddressBuilder.ItemIndex := 0 else
CbAddressBuilder.ItemIndex := CbAddressBuilder.Items.Indexof(VpControlLink1.CityStateZipFormat); CbAddressBuilder.ItemIndex := CbAddressBuilder.Items.Indexof(VpControlLink1.CityStateZipFormat);
CbDrawingStyle.ItemIndex := ini.ReadInteger('Settings', 'DrawingStyle', n := ini.ReadInteger('Settings', 'DrawingStyle', ord(dsFlat));
ord(dsFlat)); if (n <= 0) or (n >= ord(High(TVpDrawingStyle))) then n := 0;
CbDrawingStyle.ItemIndex := n;
CbDrawingStyleChange(nil); CbDrawingStyleChange(nil);
CbAllowInplaceEditing.Checked := ini.ReadBool('Settings', 'AllowInplaceEditing', CbAllowInplaceEditing.Checked := ini.ReadBool('Settings', 'AllowInplaceEditing',

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -132,7 +132,7 @@ steps:
4.4 Current development version (1.07) 4.4 Current development version (1.07)
- ... - Improved integration of the LCL scaling of Lazarus 1.8
============================================== ==============================================

View File

@ -371,6 +371,7 @@ type
implementation implementation
{$R vpbase.res} {$R vpbase.res}
{$R vpbasepng.res}
uses uses
{$IFNDEF LCL} {$IFNDEF LCL}

Binary file not shown.

View File

@ -161,8 +161,6 @@ function GranularityToStr(Gran: TVpGranularity): string;
function TaskPriorityToStr(APriority: TVpTaskPriority): String; function TaskPriorityToStr(APriority: TVpTaskPriority): String;
//function AutoHeight(ARadioGroup: TRadioGroup): Integer;
//function GetButtonWidth(AButton: TButton): Integer;
function GetLabelWidth(ALabel: TLabel): Integer; function GetLabelWidth(ALabel: TLabel): Integer;
function GetRealFontHeight(AFont: TFont): Integer; function GetRealFontHeight(AFont: TFont): Integer;
@ -174,6 +172,9 @@ procedure AddResourceGroupMenu(AMenu: TMenuItem; AResource: TVpResource;
AEventHandler: TNotifyEvent); AEventHandler: TNotifyEvent);
function OverlayPatternToBrushStyle(APattern: TVpOverlayPattern): TBrushStyle; function OverlayPatternToBrushStyle(APattern: TVpOverlayPattern): TBrushStyle;
function CreatePngFromResourceName(AResName: String): TPortableNetworkGraphic;
{ Load a png picture from a resource (Note: OS resource, not vp resource! }
procedure Unused(const A1); overload; procedure Unused(const A1); overload;
procedure Unused(const A1, A2); overload; procedure Unused(const A1, A2); overload;
procedure Unused(const A1, A2, A3); overload; procedure Unused(const A1, A2, A3); overload;
@ -793,19 +794,6 @@ begin
end; end;
end; end;
(*
function AutoHeight(ARadioGroup: TRadioGroup): Integer;
var
w: Integer;
begin
w := ARadioGroup.Width;
ARadioGroup.AutoSize := true;
Result := ARadioGroup.Height;
ARadioGroup.AutoSize := false;
ARadioGroup.Width := w;
end;
*)
function GetLabelWidth(ALabel: TLabel): Integer; function GetLabelWidth(ALabel: TLabel): Integer;
var var
canvas: TControlCanvas; canvas: TControlCanvas;
@ -817,20 +805,6 @@ begin
canvas.Free; canvas.Free;
end; end;
(*
function GetButtonWidth(AButton: TButton): Integer;
const
MARGIN = 24;
var
canvas: TControlCanvas;
begin
canvas := TControlCanvas.Create;
canvas.Control := AButton;
canvas.Font.Assign(AButton.Font);
Result := canvas.TextWidth(AButton.Caption) + MARGIN * Screen.PixelsPerInch div DesignTimeDPI;
canvas.Free;
end;
*)
function GetRealFontHeight(AFont: TFont): Integer; function GetRealFontHeight(AFont: TFont): Integer;
begin begin
if AFont.Size = 0 then if AFont.Size = 0 then
@ -943,6 +917,23 @@ begin
Result := TBrushStyle(APattern); Result := TBrushStyle(APattern);
end; end;
function CreatePngFromResourceName(AResName: String): TPortableNetworkGraphic;
var
stream: TResourceStream;
begin
Result := TPortableNetworkGraphic.Create;
try
stream := TResourceStream.Create(HINSTANCE, AResName, RT_RCDATA);
try
Result.LoadFromStream(stream);
finally
stream.Free;
end;
except
FreeAndNil(Result);
end;
end;
{$PUSH}{$HINTS OFF} {$PUSH}{$HINTS OFF}
procedure Unused(const A1); procedure Unused(const A1);
begin begin

View File

@ -5,7 +5,7 @@ unit VpTasklistPainter;
interface interface
uses uses
SysUtils, LCLType, LCLIntf, LCLVersion, SysUtils, LCLType, LCLIntf,
Classes, Graphics, Types, Classes, Graphics, Types,
VpConst, VpBase, VpTaskList, VpBasePainter; VpConst, VpBase, VpTaskList, VpBasePainter;
@ -16,7 +16,6 @@ type
// local parameters of the old TVpTaskList method // local parameters of the old TVpTaskList method
HeadRect: TRect; HeadRect: TRect;
Bmp: Graphics.TBitmap;
RowHeight: Integer; RowHeight: Integer;
RealColor: TColor; RealColor: TColor;
BackgroundSelHighlight: TColor; BackgroundSelHighlight: TColor;
@ -55,6 +54,7 @@ type
implementation implementation
uses uses
Forms,
VpData, VpMisc, VpCanvasUtils, VpSR; VpData, VpMisc, VpCanvasUtils, VpSR;
type type
@ -90,16 +90,23 @@ var
dx, dy: Integer; dx, dy: Integer;
tm: Integer; // Scaled text margin; tm: Integer; // Scaled text margin;
d2: Integer; // 2*Scale d2: Integer; // 2*Scale
d1px, d2px, d3px: Integer;
begin begin
tm := Round(Textmargin * Scale); if Scale > 1 then
tm := Round(TextMargin * Scale) else
tm := ScaleY(Textmargin, DesigntimeDPI);
d1px := ScaleY(1, DesigntimeDPI);
d2px := ScaleY(2, DesigntimeDPI);
d3px := ScaleY(3, DesigntimeDPI);
X := Rec.Left + tm; X := Rec.Left + tm;
Y := Rec.Top + tm; Y := Rec.Top + tm;
W := RowHeight - tm * 2; // correct: The checkbox is square, its width is determined by the row height W := RowHeight - tm * 2;
// correct: The checkbox is square, its width is determined by the row height
{ draw check box } { draw check box }
case FTaskList.DrawingStyle of case FTaskList.DrawingStyle of
dsFlat: dsFlat, dsNoBorder:
begin begin
RenderCanvas.Brush.Color := RealCheckBgColor; RenderCanvas.Brush.Color := RealCheckBgColor;
RenderCanvas.Pen.Color := RealCheckBoxColor; RenderCanvas.Pen.Color := RealCheckBoxColor;
@ -136,11 +143,11 @@ begin
end; end;
{ build check rect } { build check rect }
d2 := Round(2*Scale); if Scale > 1 then begin
if Scale > 1 then d2 := Round(2*Scale);
CR := Rect(X + d2, Y + d2, X + W - d2, Y + W - d2) CR := Rect(X + d2, Y + d2, X + W - d2, Y + W - d2)
else end else
CR := Rect(X + 3, Y + 3, X + W - 3, Y + W - 3); CR := Rect(X + d3px, Y + d3px, X + W - d3px, Y + W - d3px);
if Checked then begin if Checked then begin
RenderCanvas.Pen.Color := RealCheckColor; RenderCanvas.Pen.Color := RealCheckColor;
// Instead of using Pen.Width = 3 we paint 3x - looks better // Instead of using Pen.Width = 3 we paint 3x - looks better
@ -171,13 +178,23 @@ begin
TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Left+dx, CR.Bottom); TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Left+dx, CR.Bottom);
TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Right, CR.Top-1); TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Right, CR.Top-1);
TPSMoveTo(RenderCanvas, Angle, RenderIn, CR.Left+1, CR.Bottom-dy); TPSMoveTo(RenderCanvas, Angle, RenderIn, CR.Left+1, CR.Bottom-dy);
TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Left+ dx, CR.Bottom-1); TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Left+dx, CR.Bottom-1);
TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Right-1, CR.Top-1); TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Right-1, CR.Top-1);
TPSMoveTo(RenderCanvas, Angle, RenderIn, CR.Left, CR.Bottom-dy+1); TPSMoveTo(RenderCanvas, Angle, RenderIn, CR.Left, CR.Bottom-dy+1);
TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Left+dx, CR.Bottom+1); TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Left+dx, CR.Bottom+1);
TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Right, CR.Top); TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Right, CR.Top);
if Screen.PixelsPerInch > 120 then begin
TPSMoveTo(RenderCanvas, Angle, RenderIn, CR.Left+2, CR.Bottom-dy);
TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Left+dx, CR.Bottom-2);
TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Right-2, CR.Top-1);
TPSMoveTo(RenderCanvas, Angle, RenderIn, CR.Left, CR.Bottom-dy+2);
TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Left+dx, CR.Bottom+2);
TPSLineTo(RenderCanvas, Angle, RenderIn, CR.Right, CR.Top);
end;
end; end;
end; end;
end; end;
@ -213,7 +230,9 @@ var
GlyphRect: TRect; GlyphRect: TRect;
HeadStr: string; HeadStr: string;
delta: Integer; delta: Integer;
w, h: Integer; w, h, h0: Integer;
bmp: TBitmap;
png: TPortableNetworkGraphic;
begin begin
RenderCanvas.Brush.Color := TaskHeadAttrColor; RenderCanvas.Brush.Color := TaskHeadAttrColor;
RenderCanvas.Font.Assign(FTaskList.TaskHeadAttributes.Font); RenderCanvas.Font.Assign(FTaskList.TaskHeadAttributes.Font);
@ -246,39 +265,45 @@ begin
end; end;
end; end;
{ Draw the glyph }
if FTaskList.ShowIcon then begin if FTaskList.ShowIcon then begin
{ Draw the glyph } h0 := HeightOf(HeadRect) - 2;
Bmp := Graphics.TBitmap.Create; if h0 >= 32 then
png := CreatePngFromResourceName('VPCHECKPAD32')
else if h0 >= 24 then
png := CreatePngFromResourceName('VPCHECKPAD24')
else
png := CreatePngFromResourceName('VPCHECKPAD16');
try try
Bmp.LoadFromResourceName(HINSTANCE, 'VPCHECKPAD'); //soner changed: Bmp.Handle := LoadBaseBitmap('VPCHECKPAD'); if png.Height > 0 then begin
if Bmp.Height > 0 then begin bmp := TBitmap.Create;
w := Round(Bmp.Width * Scale); try
h := Round(Bmp.Height * Scale); bmp.PixelFormat := pf32Bit;
bmp.Width := png.Width;
bmp.Height := png.Height;
bmp.Canvas.Brush.color := clWhite;
bmp.Canvas.FillRect(Rect(0, 0, bmp.Width, bmp.Height));
bmp.Canvas.Draw(0, 0, png);
GlyphRect.TopLeft := Point(HeadRect.Left + TextMargin, HeadRect.Top + TextMargin); w := Round(bmp.Width * Scale);
GlyphRect.BottomRight := Point(GlyphRect.Left + w, GlyphRect.Top + h); h := Round(bmp.Height * Scale);
{$IFDEF FPC} GlyphRect.TopLeft := Point(HeadRect.Left + TextMargin, (Headrect.Top + HeadRect.Bottom - h) div 2);
RotateBitmap(Bmp, Angle); GlyphRect.BottomRight := Point(GlyphRect.Left + w, GlyphRect.Top + h);
{$ENDIF}
TPSStretchDraw(RenderCanvas, Angle, RenderIn, GlyphRect, Bmp); {$IFDEF FPC}
{ RotateBitmap(Bmp, Angle);
RenderCanvas.BrushCopy( {$ENDIF}
TPSRotateRectangle(Angle, RenderIn, GlyphRect),
Bmp, TPSStretchDraw(RenderCanvas, Angle, RenderIn, GlyphRect, Bmp);
Rect(0, 0, Bmp.Width, Bmp.Height),
Bmp.Canvas.Pixels[0, Bmp.Height-1] HeadRect.Left := HeadRect.Left + w + TextMargin;
); finally
} bmp.Free;
//TODO: RenderCanvas.BrushCopy (TPSRotateRectangle (Angle, RenderIn, GlyphRect), end;
// Bmp, Rect(0, 0, Bmp.Width, Bmp.Height),
// Bmp.Canvas.Pixels[0, Bmp.Height - 1]);
// RenderCanvas.Draw(GlyphRect.TopLeft.x, GlyphRect.TopLeft.y, Bmp); //soner added
HeadRect.Left := HeadRect.Left + w + TextMargin;
end; end;
finally finally
Bmp.Free; png.Free;
end; end;
end; end;