Skip to content

Commit be8eb71

Browse files
committedMar 1, 2016
Version 1.01
1 parent db47e23 commit be8eb71

35 files changed

+5904
-743
lines changed
 

‎README.md

+25-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ while being compatible with - a part of - the LCL/VCL. It may
1010
concern for instance: small installation or configuration
1111
programs, simple tools, test programs, ... Typically, the size
1212
is about 1/10th with Free Pascal/Lazarus and 1/5th with Delphi
13-
for simple small programs.
13+
for small and simple programs.
1414

1515
It's not a specific graphical library, or another widgetset.
1616
It's an emulation of a small subset of the standard LCL/VCL,
@@ -30,7 +30,7 @@ configuration to modify: just indicate a valid path for the
3030
Light LCL files into your project options, and that's it !
3131

3232
It's available only for Windows (32 and 64 bits). It has
33-
been tested with FPC 2.6.x/3.x + Lazarus 1.2.x/1.4.x/1.5 and
33+
been tested with FPC 2.6.x/3.x + Lazarus 1.4.x/1.6 and
3434
Delphi 7.
3535

3636
See "README.txt" for more pieces of information.
@@ -44,6 +44,29 @@ version 2.0. See "LICENSE.txt".
4444

4545
## LLCL ChangeLog
4646

47+
* [Version 1.01] (https://github.com/FChrisF/LLCL/releases/tag/v1.0.1):
48+
Main changes and additions:
49+
- TStringGrid control added (Grids.pas),
50+
- TIniFile class added (IniFiles.pas),
51+
- TClipboard class added for text data (ClipBrd.pas),
52+
- PNG images support (not enabled by default),
53+
- transparent bitmaps support (not enabled by default),
54+
- forms double buffering support (not enabled by default),
55+
- TSelectDirectoryDialog control added (Dialog.pas) for
56+
FPC/Lazarus (not enabled by default) and SelectDirectory
57+
function (Dialog.pas or FileCtrl.pas),
58+
- ANSI LLCL option (i.e. no UTF8 at all) added for
59+
FPC/Lazarus (see in LLCLFPCInc.inc),
60+
- design time only properties for controls are now
61+
accessible for dynamic creation purposes. Run time
62+
modifications are still not supported for them, but they
63+
can now be set at run time before the corresponding
64+
control is dynamically created,
65+
- a few bug fixes and some minor additions/modifications.
66+
Note: controls and functionalities not enabled by default
67+
can be activated by defining the corresponding option(s) in
68+
the option files LLCLOptions.inc.
69+
4770
* [Version 1.00] (https://github.com/FChrisF/LLCL/releases/tag/v1.0.0):
4871
- Initial public release.
4972

‎README.txt

+231-63
Large diffs are not rendered by default.

‎demo/Delphi/LLCLTest.dof

+2-6
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ UnitOutputDir=
9595
PackageDLLOutputDir=
9696
PackageDCPOutputDir=
9797
SearchPath=..\..\sources
98-
Packages=vcl;rtl;vclx;VclSmp;vclshlctrls;IndyCore70;IndySystem70;IndyProtocols70
98+
Packages=vcl;rtl;vclx;VclSmp;vclshlctrls
9999
Conditionals=
100100
DebugSourceDirs=
101101
UsePackages=0
@@ -130,13 +130,9 @@ OriginalFilename=
130130
ProductName=
131131
ProductVersion=1.0.0.0
132132
Comments=
133-
[Excluded Packages]
134-
C:\WINDOWS\system32\IndyCore70.bpl=Indy 10 Core
135-
C:\WINDOWS\system32\IndySystem70.bpl=Indy 10 System
136133
[HistoryLists\hlUnitAliases]
137134
Count=1
138135
Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
139136
[HistoryLists\hlSearchPath]
140-
Count=2
137+
Count=1
141138
Item0=..\..\sources
142-
Item1=.\LLCLUnits

‎demo/Delphi/Unit1.pas

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
{$mode objfpc}{$H+}
1010
// {$mode delphi}
1111
// {$mode objfpc}{$modeswitch unicodestrings}{$H+} // Requires FPC 2.7.1+
12-
// {$mode delphiunicode} // (See LLCL README.txt)
12+
// {$mode delphiunicode}{$codepage UTF8} // (See LLCL README.txt)
1313
{$ENDIF}
1414
{$IFDEF FPC_OBJFPC} {$DEFINE IS_FPC_OBJFPC_MODE} {$ENDIF}
1515

1616
interface
1717

1818
uses
19-
SysUtils, {$IFDEF FPC}FileUtil, LCLType,{$ELSE} Variants, XPMan,{$ENDIF}
19+
SysUtils, {$IFDEF FPC}LazUTF8, LCLType,{$ELSE} Variants, XPMan,{$ENDIF}
2020
Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
2121
ComCtrls, Menus;
2222

@@ -146,9 +146,9 @@ procedure MemoAddLineFmt(MemoCtrl: TMemo; const s: string; const Args: array of
146146
procedure TForm1.CreateParams(var Params : TCreateParams);
147147
begin
148148
inherited;
149-
Form1.CheckBox1.InitialAlignment := taLeftJustify; // Note: TCheckBox has an alignment
150-
Form1.CheckBox3.InitialAlignment := taLeftJustify; // property since Lazarus 1.4
151-
Form1.RadioButton2.InitialAlignment := taLeftJustify;
149+
Form1.CheckBox1.Alignment := taLeftJustify; // Note: TCheckBox has an alignment
150+
Form1.CheckBox3.Alignment := taLeftJustify; // property since Lazarus 1.4
151+
Form1.RadioButton2.Alignment := taLeftJustify;
152152
end;
153153
{$IFEND}
154154
{$ENDIF}
@@ -324,7 +324,6 @@ procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
324324
// (Because Form1 has KeyPreview=True property)
325325
// Only the character code is present here (see FormKeyDown, FormKeyUp)
326326
MemoAddLineFmt(Memo1,'FormKeyPress #%d ''%s''', [Ord(Key),
327-
// (Note: warning for SysToUTF8 with Lazarus 1.5+ and standard LCL)
328327
{$if Defined(FPC) and not Defined(UNICODE)}SysToUTF8(Key){$else}Key{$ifend}]); // Char type is not UTF8
329328
end;
330329

‎demo/FPC/unit1.lfm

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object Form1: TForm1
1414
OnKeyUp = FormKeyUp
1515
OnMouseDown = FormMouseDown
1616
OnMouseUp = FormMouseUp
17-
LCLVersion = '1.4.2.0'
17+
LCLVersion = '1.4.4.0'
1818
object GroupBox1: TGroupBox
1919
Left = 8
2020
Height = 65

‎demo/FPC/unit1.pas

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
{$mode objfpc}{$H+}
1010
// {$mode delphi}
1111
// {$mode objfpc}{$modeswitch unicodestrings}{$H+} // Requires FPC 2.7.1+
12-
// {$mode delphiunicode} // (See LLCL README.txt)
12+
// {$mode delphiunicode}{$codepage UTF8} // (See LLCL README.txt)
1313
{$ENDIF}
1414
{$IFDEF FPC_OBJFPC} {$DEFINE IS_FPC_OBJFPC_MODE} {$ENDIF}
1515

1616
interface
1717

1818
uses
19-
SysUtils, {$IFDEF FPC}FileUtil, LCLType,{$ELSE} Variants, XPMan,{$ENDIF}
19+
SysUtils, {$IFDEF FPC}LazUTF8, LCLType,{$ELSE} Variants, XPMan,{$ENDIF}
2020
Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
2121
ComCtrls, Menus;
2222

@@ -146,9 +146,9 @@ procedure MemoAddLineFmt(MemoCtrl: TMemo; const s: string; const Args: array of
146146
procedure TForm1.CreateParams(var Params : TCreateParams);
147147
begin
148148
inherited;
149-
Form1.CheckBox1.InitialAlignment := taLeftJustify; // Note: TCheckBox has an alignment
150-
Form1.CheckBox3.InitialAlignment := taLeftJustify; // property since Lazarus 1.4
151-
Form1.RadioButton2.InitialAlignment := taLeftJustify;
149+
Form1.CheckBox1.Alignment := taLeftJustify; // Note: TCheckBox has an alignment
150+
Form1.CheckBox3.Alignment := taLeftJustify; // property since Lazarus 1.4
151+
Form1.RadioButton2.Alignment := taLeftJustify;
152152
end;
153153
{$IFEND}
154154
{$ENDIF}
@@ -324,7 +324,6 @@ procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
324324
// (Because Form1 has KeyPreview=True property)
325325
// Only the character code is present here (see FormKeyDown, FormKeyUp)
326326
MemoAddLineFmt(Memo1,'FormKeyPress #%d ''%s''', [Ord(Key),
327-
// (Note: warning for SysToUTF8 with Lazarus 1.5+ and standard LCL)
328327
{$if Defined(FPC) and not Defined(UNICODE)}SysToUTF8(Key){$else}Key{$ifend}]); // Char type is not UTF8
329328
end;
330329

‎sources/Classes.pas

+75-48
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
25+
* TReader: ReadStringInts (and StringIntProperty), ReadIntArray added
2426
Version 1.00:
2527
* Rect, EStreamError moved from SysUtils to Classes
2628
* TList reviewed (List, Capacity, ...)
@@ -317,6 +319,7 @@ TReader = class
317319
function BooleanProperty(): boolean;
318320
function IntegerProperty(): integer;
319321
function StringProperty(): string;
322+
function StringIntProperty(): string;
320323
function ColorProperty(): integer;
321324
function BinaryProperty(var Size: integer): pointer;
322325
procedure IdentProperty(var aValue; aTypeInfo: pointer);
@@ -329,10 +332,12 @@ TReader = class
329332
function ReadUTF8String(): string;
330333
function ReadWString(): string;
331334
procedure ReadPrefix(var Flags: TFilerFlags; var AChildPos: integer);
335+
procedure AnyProperty;
332336
procedure ReadList;
333337
procedure ReadSet;
334338
procedure ReadStrings(Strings: TStrings);
335-
procedure AnyProperty;
339+
procedure ReadStringInts(Strings: TStrings);
340+
procedure ReadIntArray(var IntArray: array of integer); // Read an array of integers
336341
property Size: integer read fSize;
337342
property Position: integer read fPosition write SetPosition;
338343
end;
@@ -514,6 +519,7 @@ TTypeInfo = record
514519
function GetTypeData(ptrTypeInfo: PTypeInfo) : PTypeData; forward;
515520
function GetEnumNameValue(ptrTypeInfo: PTypeInfo; const Name: string): integer; forward;
516521
function GetColorFromIdent(Ident: PChar): integer; forward;
522+
function ClassSameText(const S1, S2: string): boolean; forward;
517523

518524
{$ifdef MSWindows}
519525
var
@@ -526,8 +532,7 @@ function CreateComponent(const AClassName: shortstring; AOwner: TComponent): TCo
526532
{$define Def_FPC_StdSys}
527533
{$ifend}
528534
{$ifdef Def_FPC_StdSys}
529-
function Class_CompareText(const S1, S2: string): integer; forward;
530-
function Class_SameText(const S1, S2: string): boolean; forward;
535+
function Class_IntToStr(Value: integer): string; forward;
531536
{$endif}
532537

533538

@@ -550,9 +555,9 @@ function GetEnumNameValue(ptrTypeInfo: PTypeInfo; const Name: string): integer;
550555
case ptrTypeInfo^.Kind of
551556
tkBool:
552557
begin
553-
if {$ifdef Def_FPC_StdSys}Class_CompareText{$else}CompareText{$endif}(BooleanIdents[false],Name)=0 then
558+
if ClassSameText(BooleanIdents[false], Name) then
554559
result := 0
555-
else if {$ifdef Def_FPC_StdSys}Class_CompareText{$else}CompareText{$endif}(BooleanIdents[true],Name)=0 then
560+
else if ClassSameText(BooleanIdents[true], Name) then
556561
result := 1;
557562
end;
558563
tkEnumeration:
@@ -562,7 +567,7 @@ function GetEnumNameValue(ptrTypeInfo: PTypeInfo; const Name: string): integer;
562567
PS := @PT^.NameList;
563568
while PByte(PS)^<>0 do
564569
begin
565-
if {$ifdef Def_FPC_StdSys}Class_CompareText{$else}CompareText{$endif}(string(PS^), Name) = 0 then
570+
if ClassSameText(string(PS^), Name) then
566571
begin
567572
result := Count+PT^.MinValue;
568573
break;
@@ -690,40 +695,17 @@ function GetColorFromIdent(Ident: PChar): integer;
690695
result := clNone;
691696
end;
692697

693-
{$ifdef Def_FPC_StdSys}
694-
function Class_CompareText(const S1, S2: string): integer;
695-
var i, count, count1, count2: integer;
696-
var ch1, ch2: integer;
697-
begin
698-
count1 := length(S1);
699-
count2 := length(S2);
700-
if count1 > count2 then
701-
count := count2
702-
else
703-
count := count1;
704-
for i:=1 to count do
705-
begin
706-
ch1 := ord(S1[i]);
707-
ch2 := ord(S2[i]);
708-
if ch1 <> ch2 then
709-
begin
710-
if ch1 in [ord('a')..ord('z')] then Dec(ch1, 32);
711-
if ch2 in [ord('a')..ord('z')] then Dec(ch2, 32);
712-
if ch1 <> ch2 then
713-
begin
714-
result := ch1 - ch2;
715-
exit;
716-
end;
717-
end;
718-
end;
719-
result := count1 - count2;
698+
function ClassSameText(const S1, S2: string): boolean;
699+
begin
700+
result := (LLCLS_CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, S1, S2)=CSTR_EQUAL);
720701
end;
721702

722-
function Class_SameText(const S1, S2: string): boolean;
703+
{$ifdef Def_FPC_StdSys}
704+
function Class_IntToStr(Value: integer): string;
723705
begin
724-
result := (Class_CompareText(S1, S2)=0);
706+
Str(Value, result);
725707
end;
726-
{$endif}
708+
{$endif Def_FPC_StdSys}
727709

728710
{ TList }
729711

@@ -964,7 +946,7 @@ function TStringList.IndexOf(const s: string): integer;
964946
if fCaseSensitive then
965947
begin if fListStr[i]=s then begin result := i; exit; end; end
966948
else
967-
begin if {$ifdef Def_FPC_StdSys}Class_SameText{$else}SameText{$endif}(fListStr[i], s) then begin result := i; exit; end; end;
949+
begin if ClassSameText(fListStr[i], s) then begin result := i; exit; end; end;
968950
end;
969951

970952
function TStringList.IndexOfObject(item: pointer): integer;
@@ -989,7 +971,7 @@ function TStringList.IndexOfName(const ObjName: string; const Separator: string=
989971
begin
990972
Tmp := ObjName + Separator;
991973
for i := 0 to fCount-1 do
992-
if {$ifdef Def_FPC_StdSys}Class_CompareText{$else}CompareText{$endif}(Copy(fListStr[i], 1, length(Tmp)), Tmp) = 0 then
974+
if ClassSameText(Copy(fListStr[i], 1, length(Tmp)), Tmp) then
993975
begin
994976
result := i;
995977
exit;
@@ -1182,7 +1164,7 @@ function TStream.CopyFrom(Source: TStream; Count: integer): integer;
11821164
Dec(Count, N);
11831165
end;
11841166
finally
1185-
FreeMem(Buffer, BufSize);
1167+
FreeMem(Buffer);
11861168
end;
11871169
end;
11881170

@@ -1441,6 +1423,23 @@ function TReader.StringProperty(): string;
14411423
end;
14421424
end;
14431425

1426+
function TReader.StringIntProperty(): string;
1427+
var ValueType: TValueType;
1428+
begin
1429+
result := '';
1430+
ValueType := ReadValueType();
1431+
case ValueType of
1432+
vaIdent,
1433+
vaString: result := ReadString();
1434+
vaUTF8String: result := ReadUTF8String();
1435+
vaWString: result := ReadWString();
1436+
vaInt8 : result := {$ifdef Def_FPC_StdSys}Class_IntToStr{$else}IntToStr{$endif}(ShortInt(ReadByte()));
1437+
vaInt16 : result := {$ifdef Def_FPC_StdSys}Class_IntToStr{$else}IntToStr{$endif}(ReadWord());
1438+
vaInt32 : result := {$ifdef Def_FPC_StdSys}Class_IntToStr{$else}IntToStr{$endif}(ReadInteger());
1439+
else raise EClassesError.CreateFmt(LLCL_STR_CLAS_STRING, [integer(ValueType)]);
1440+
end;
1441+
end;
1442+
14441443
function TReader.ColorProperty(): integer;
14451444
var ValueType: TValueType;
14461445
begin
@@ -1631,6 +1630,35 @@ procedure TReader.ReadStrings(Strings: TStrings);
16311630
else Error(LLCL_STR_CLAS_LIST);
16321631
end;
16331632

1633+
// Read strings and integers (hack: integers are stored as strings)
1634+
procedure TReader.ReadStringInts(Strings: TStrings);
1635+
var ValueType: TValueType;
1636+
s: string;
1637+
begin
1638+
ValueType := ReadValueType();
1639+
if ValueType=vaList then
1640+
repeat
1641+
s := StringIntProperty();
1642+
Strings.Add(s);
1643+
until EndOfList()
1644+
else Error(LLCL_STR_CLAS_LIST);
1645+
end;
1646+
1647+
// Read array of integers (array must wide enough)
1648+
procedure TReader.ReadIntArray(var IntArray: array of integer);
1649+
var ValueType: TValueType;
1650+
i: integer;
1651+
begin
1652+
i := 0;
1653+
ValueType := ReadValueType();
1654+
if ValueType=vaList then
1655+
repeat
1656+
IntArray[i ] := IntegerProperty();
1657+
Inc(i);
1658+
until EndOfList()
1659+
else Error(LLCL_STR_CLAS_LIST);
1660+
end;
1661+
16341662
{ TPersistent }
16351663

16361664
function TPersistent.SubProperty(const SubPropName: string): TPersistent;
@@ -1659,21 +1687,21 @@ procedure TPersistent.ReadProperty(const PropName: string; Reader: TReader);
16591687
{$ifdef debug}
16601688
ValueType := ReadValueType();
16611689
case ValueType of
1662-
vaInt8 : Value := IntToStr(ReadByte());
1663-
vaInt16 : Value := IntToStr(ReadWord());
1690+
vaInt8 : Value := {$ifdef Def_FPC_StdSys}Class_IntToStr{$else}IntToStr{$endif}(ReadByte());
1691+
vaInt16 : Value := {$ifdef Def_FPC_StdSys}Class_IntToStr{$else}IntToStr{$endif}(ReadWord());
16641692
vaIdent : Value := '"'+ReadString()+'"';
16651693
vaString : Value := ReadString();
16661694
vaUTF8String: Value := ReadUTF8String();
16671695
vaWString: Value := ReadWString();
16681696
vaFalse : Value := '"FALSE"';
16691697
vaTrue : Value := '"TRUE"';
16701698
vaBinary : begin
1671-
i := ReadInteger(); Value := '('+IntToStr(i)+LLCL_STR_CLAS_BYTES;
1699+
i := ReadInteger(); Value := '('+{$ifdef Def_FPC_StdSys}Class_IntToStr{$else}IntToStr{$endif}(i)+LLCL_STR_CLAS_BYTES;
16721700
Inc(fPointer,i); Inc(fPosition,i);
16731701
end;
16741702
vaList: ReadList;
16751703
vaSet: ReadSet;
1676-
else OutputDebugString(pointer(LLCL_STR_CLAS_BADVALUETYPE+IntToStr(ord(ValueType))));
1704+
else OutputDebugString(pointer(LLCL_STR_CLAS_BADVALUETYPE+{$ifdef Def_FPC_StdSys}Class_IntToStr{$else}IntToStr{$endif}(ord(ValueType))));
16771705
end;
16781706
Oem := LLCLS_StringToOem(Value);
16791707
writeln(self.ClassName+' '+TComponent(self).Name+'.'+PropName+'='+Oem);
@@ -1874,7 +1902,7 @@ function TComponent.FindComponent(const CompName: string): TComponent;
18741902
result := nil;
18751903
if fComponents<>nil then
18761904
for i := 0 to fComponents.Count-1 do
1877-
if {$ifdef Def_FPC_StdSys}Class_SameText{$else}SameText{$endif}(TComponent(fComponents[i]).Name, CompName) then
1905+
if ClassSameText(TComponent(fComponents[i]).Name, CompName) then
18781906
begin
18791907
result := TComponent(fComponents[i]);
18801908
break;
@@ -1906,8 +1934,7 @@ procedure TMemoryStream.SetSize(Value: integer);
19061934

19071935
destructor TMemoryStream.Destroy;
19081936
begin
1909-
if Memory<>nil then
1910-
Freemem(Memory);
1937+
LLCLS_FreeMemAndNil(fMemory);
19111938
inherited;
19121939
end;
19131940

‎sources/ClipBrd.pas

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
unit ClipBrd;
2+
3+
{
4+
LLCL - FPC/Lazarus Light LCL
5+
based upon
6+
LVCL - Very LIGHT VCL
7+
----------------------------
8+
9+
This file is a part of the Light LCL (LLCL).
10+
11+
This Source Code Form is subject to the terms of the Mozilla Public
12+
License, v. 2.0. If a copy of the MPL was not distributed with this
13+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
14+
15+
This Source Code Form is "Incompatible With Secondary Licenses",
16+
as defined by the Mozilla Public License, v. 2.0.
17+
18+
Copyright (c) 2015-2016 ChrisF
19+
20+
Based upon the Very LIGHT VCL (LVCL):
21+
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
22+
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
23+
24+
Version 1.01:
25+
* File creation.
26+
* TClipboard/Clipboard implemented (only for text)
27+
}
28+
29+
{$IFDEF FPC}
30+
{$define LLCL_FPC_MODESECTION}
31+
{$I LLCLFPCInc.inc} // For mode
32+
{$undef LLCL_FPC_MODESECTION}
33+
{$ENDIF}
34+
35+
{$I LLCLOptions.inc} // Options
36+
37+
//------------------------------------------------------------------------------
38+
39+
interface
40+
41+
uses
42+
Classes;
43+
44+
type
45+
TClipboard = class(TPersistent)
46+
private
47+
fOwnerHandle: THandle;
48+
function OpenClipBrd(): boolean;
49+
procedure CloseClipBrd;
50+
function GetAsText(): string;
51+
procedure SetAsText(const Value: string);
52+
procedure SetBuffer(Format: cardinal; Buffer: pointer; Size: integer);
53+
public
54+
procedure Open;
55+
procedure Close;
56+
procedure Clear;
57+
function HasFormat(Format: cardinal): boolean;
58+
function GetAsHandle(Format: cardinal): THandle;
59+
procedure SetAsHandle(Format: cardinal; Value: THandle);
60+
property AsText: string read GetAsText write SetAsText;
61+
end;
62+
63+
{$IFDEF FPC}
64+
const
65+
CF_TEXT = 1;
66+
CF_BITMAP = 2;
67+
CF_UNICODETEXT = 13;
68+
{$ENDIF}
69+
70+
var
71+
Clipboard: TClipboard;
72+
73+
//------------------------------------------------------------------------------
74+
75+
implementation
76+
77+
uses
78+
LLCLOSInt, Windows,
79+
Forms;
80+
81+
{$IFDEF FPC}
82+
{$PUSH} {$HINTS OFF}
83+
{$ENDIF}
84+
85+
type
86+
TPApplication = class(TApplication); // To access to protected part
87+
88+
//------------------------------------------------------------------------------
89+
90+
{ TClipboard }
91+
92+
function TClipboard.OpenClipBrd(): boolean;
93+
begin
94+
if fOwnerHandle=0 then
95+
fOwnerHandle := TPApplication(Application).AppHandle;
96+
result := LLCL_OpenClipboard(fOwnerHandle);
97+
end;
98+
99+
procedure TClipboard.CloseClipBrd;
100+
begin
101+
LLCL_CloseClipboard();
102+
end;
103+
104+
function TClipboard.GetAsText(): string;
105+
var hData: THandle;
106+
begin
107+
result := '';
108+
if not OpenClipBrd() then exit;
109+
hData := LLCL_GetClipboardData(LLCLS_CLPB_GetTextFormat());
110+
if hData<>0 then
111+
begin
112+
result := LLCLS_CLPB_GetText(LLCL_GlobalLock(hData));
113+
LLCL_GlobalUnlock(hData);
114+
end;
115+
CloseClipBrd;
116+
end;
117+
118+
procedure TClipboard.SetAsText(const Value: string);
119+
var lpText: pointer;
120+
var len: cardinal;
121+
begin
122+
lpText := LLCLS_CLPB_SetTextPtr(Value, len);
123+
SetBuffer(LLCLS_CLPB_GetTextFormat(), lpText, len);
124+
end;
125+
126+
procedure TClipboard.SetBuffer(Format: cardinal; Buffer: pointer; Size: integer);
127+
var hMem: THandle;
128+
var pMem: pointer;
129+
begin
130+
if not OpenClipBrd() then exit;
131+
Clear;
132+
hMem := LLCL_GlobalAlloc(GMEM_MOVEABLE or GMEM_DDESHARE, Size);
133+
if hMem<>0 then
134+
begin
135+
pMem := LLCL_GlobalLock(hMem);
136+
if Assigned(pMem) then
137+
Move(Buffer^, pMem^, Size);
138+
LLCL_GlobalUnlock(hMem);
139+
LLCL_SetClipboardData(Format, hMem);
140+
// Don't free the allocated memory
141+
end;
142+
CloseClipBrd;
143+
end;
144+
145+
procedure TClipboard.Open;
146+
begin
147+
OpenClipBrd();
148+
end;
149+
150+
procedure TClipboard.Close;
151+
begin
152+
CloseClipBrd;
153+
end;
154+
155+
procedure TClipboard.Clear;
156+
begin
157+
LLCL_EmptyClipboard();
158+
end;
159+
160+
function TClipboard.HasFormat(Format: cardinal): boolean;
161+
begin
162+
result := LLCL_IsClipboardFormatAvailable(Format);
163+
end;
164+
165+
function TClipboard.GetAsHandle(Format: cardinal): THandle;
166+
begin
167+
result := 0;
168+
if not OpenClipBrd() then exit;
169+
result := LLCL_GetClipboardData(Format);
170+
Close;
171+
end;
172+
173+
procedure TClipboard.SetAsHandle(Format: cardinal; Value: THandle);
174+
begin
175+
if not OpenClipBrd() then exit;
176+
Clear;
177+
LLCL_SetClipboardData(Format, Value);
178+
Close;
179+
end;
180+
181+
//------------------------------------------------------------------------------
182+
183+
initialization
184+
Clipboard := TClipboard.Create();
185+
186+
finalization
187+
Clipboard.Free;
188+
189+
{$IFDEF FPC}
190+
{$POP}
191+
{$ENDIF}
192+
193+
end.

‎sources/ComCtrls.pas

+16-11
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
25+
* TWinControl: notifications for child controls modified
26+
* TTrackBar: 'Orientation' and 'TickStyle' properties now accessible (design time only)
2427
Version 1.00:
2528
* File creation.
2629
* TProgressBar implemented
@@ -59,7 +62,7 @@ TProgressBar = class(TWinControl)
5962
procedure SetStep(Value: integer);
6063
protected
6164
procedure CreateHandle; override;
62-
procedure CreateParams(var Params : TCreateParams); override;
65+
procedure CreateParams(var Params: TCreateParams); override;
6366
procedure ReadProperty(const PropName: string; Reader: TReader); override;
6467
public
6568
constructor Create(AOwner: TComponent); override;
@@ -97,9 +100,9 @@ TTrackBar = class(TWinControl)
97100
procedure SetPageSize(Value: integer);
98101
protected
99102
procedure CreateHandle; override;
100-
procedure CreateParams(var Params : TCreateParams); override;
103+
procedure CreateParams(var Params: TCreateParams); override;
101104
procedure ReadProperty(const PropName: string; Reader: TReader); override;
102-
procedure ComponentNotif(var Msg: TMessage); override;
105+
function ComponentNotif(var Msg: TMessage): boolean; override;
103106
public
104107
constructor Create(AOwner: TComponent); override;
105108
property Min: integer read fMin write SetMin;
@@ -108,6 +111,8 @@ TTrackBar = class(TWinControl)
108111
property Frequency: integer read fFrequency write SetFrequency;
109112
property LineSize: integer read fLineSize write SetLineSize;
110113
property PageSize: integer read fPageSize write SetPageSize;
114+
property Orientation: TOrientation read fOrientation write fOrientation; // Run-time modification ignored; write present only for dynamical control creation purpose
115+
property TickStyle: TTickStyle read fTickStyle write fTickStyle; // Run-time modification ignored; write present only for dynamical control creation purpose
111116
property OnChange: TNotifyEvent read EOnChange write EOnChange;
112117
end;
113118

@@ -147,7 +152,7 @@ function LMessages_Dummy(const Msg: TLMCommand): boolean;
147152

148153
{ TProgressBar }
149154

150-
constructor TProgressBar.Create(AOwner:TComponent);
155+
constructor TProgressBar.Create(AOwner: TComponent);
151156
begin
152157
inherited;
153158
ATType := ATTProgressBar;
@@ -166,7 +171,7 @@ procedure TProgressBar.CreateHandle;
166171
SetStep(fStep);
167172
end;
168173

169-
procedure TProgressBar.CreateParams(var Params : TCreateParams);
174+
procedure TProgressBar.CreateParams(var Params: TCreateParams);
170175
const PROGRESS_CLASS = 'msctls_progress32';
171176
begin
172177
inherited;
@@ -237,7 +242,7 @@ procedure TProgressBar.StepBy(Value: integer);
237242

238243
{ TTrackBar }
239244

240-
constructor TTrackBar.Create(AOwner:TComponent);
245+
constructor TTrackBar.Create(AOwner: TComponent);
241246
begin
242247
inherited;
243248
ATType := ATTTrackBar;
@@ -261,7 +266,7 @@ procedure TTrackBar.CreateHandle;
261266
fOnChangeOK := true; // OnChange is now OK for being activated
262267
end;
263268

264-
procedure TTrackBar.CreateParams(var Params : TCreateParams);
269+
procedure TTrackBar.CreateParams(var Params: TCreateParams);
265270
const TRACKBAR_CLASS = 'msctls_trackbar32';
266271
begin
267272
inherited;
@@ -347,9 +352,9 @@ procedure TTrackBar.SetPageSize(Value: integer);
347352
end;
348353

349354
// Scroll messages coming from form
350-
procedure TTrackBar.ComponentNotif(var Msg: TMessage);
355+
function TTrackBar.ComponentNotif(var Msg: TMessage): boolean;
351356
begin
352-
inherited;
357+
result := inherited ComponentNotif(Msg);
353358
case Msg.Msg of
354359
WM_HSCROLL, WM_VSCROLL:
355360
if fOnChangeOK and Assigned(EOnChange) then

‎sources/Controls.pas

+235-170
Large diffs are not rendered by default.

‎sources/Dialogs.pas

+48-6
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
25+
* SelectDirectory added (for FPC/Lazarus)
26+
* TSelectDirectoryDialog added for FPC/Lazarus (not enabled by default - see LLCL_OPT_USESELECTDIRECTORYDIALOG in LLCLOptions.inc)
2427
Version 1.00:
2528
* Application.BiDiMode used for ShowMessage (through Application.MessageBox)
2629
* TOpenDialog and TSaveDialog implemented
@@ -119,19 +122,31 @@ TSaveDialog = class(TOpenDialog)
119122
public
120123
constructor Create(AOwner: TComponent); override;
121124
end;
122-
{$endif}
125+
126+
{$ifdef LLCL_OPT_USESELECTDIRECTORYDIALOG}
127+
TSelectDirectoryDialog = class(TOpenDialog)
128+
public
129+
constructor Create(AOwner: TComponent); override;
130+
function Execute: boolean; override;
131+
end;
132+
{$endif LLCL_OPT_USESELECTDIRECTORYDIALOG}
133+
{$endif LLCL_OPT_USEDIALOG}
123134

124135
procedure ShowMessage(const Msg: string);
136+
{$IFDEF FPC} // SelectDirectory is in FileCtrl.pas for Delphi
137+
function SelectDirectory(const Caption: string; const InitialDirectory: string; out Directory: string): Boolean; overload;
138+
{$ENDIF FPC}
125139

126140
//------------------------------------------------------------------------------
127141

128142
implementation
129143

130144
uses
131145
{$ifdef LLCL_OPT_USEDIALOG}
132-
{$IFDEF FPC}{$ELSE}CommDlg,{$ENDIF}
146+
{$IFDEF FPC}FileCtrl,{$ELSE}CommDlg,{$ENDIF}
133147
Forms, SysUtils;
134148
{$else}
149+
{$IFDEF FPC}FileCtrl,{$ENDIF}
135150
Forms;
136151
{$endif}
137152

@@ -171,6 +186,13 @@ procedure ShowMessage(const Msg: string);
171186
Application.MessageBox(@Msg[1], @Application.Title[1], MB_OK or MB_ICONMASK);
172187
end;
173188

189+
{$IFDEF FPC}
190+
function SelectDirectory(const Caption: string; const InitialDirectory: string; out Directory: string): Boolean;
191+
begin
192+
result := FC_SelectDirectory(Caption, InitialDirectory, [sdNewFolder, sdShowEdit, sdNewUI], Directory);
193+
end;
194+
{$ENDIF FPC}
195+
174196
{$ifdef LLCL_OPT_USEDIALOG}
175197
//------------------------------------------------------------------------------
176198

@@ -292,13 +314,33 @@ constructor TSaveDialog.Create(AOwner: TComponent);
292314
inherited;
293315
ATType := ATTSaveDialog;
294316
end;
295-
{$endif}
317+
318+
{$ifdef LLCL_OPT_USESELECTDIRECTORYDIALOG}
319+
{ TSelectDirectoryDialog }
320+
321+
constructor TSelectDirectoryDialog.Create(AOwner: TComponent);
322+
begin
323+
inherited;
324+
ATType := ATTSelectDirectoryDialog;
325+
end;
326+
327+
function TSelectDirectoryDialog.Execute: boolean;
328+
var sdOptions: TSelectDirExtOpts;
329+
begin
330+
if ofOldStyleDialog in Options then
331+
sdOptions := []
332+
else
333+
sdOptions := [sdNewFolder, sdShowEdit, sdNewUI];
334+
result := FC_SelectDirectory(fTitle, fInitialDir, sdOptions, fFileName);
335+
end;
336+
{$endif LLCL_OPT_USESELECTDIRECTORYDIALOG}
296337

297338
//------------------------------------------------------------------------------
339+
{$endif}
298340

299341
{$ifdef LLCL_OPT_USEDIALOG}
300342
initialization
301-
RegisterClasses([TOpenDialog, TSaveDialog]);
343+
RegisterClasses([TOpenDialog, TSaveDialog {$ifdef LLCL_OPT_USESELECTDIRECTORYDIALOG}, TSelectDirectoryDialog{$endif}]);
302344
{$endif}
303345

304346
{$IFDEF FPC}

‎sources/ExtCtrls.pas

+24-4
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
25+
* TImage: Changed added (when bitmap data are changed)
26+
* TImage: SetStretch modified
27+
* LLCL_OPT_USEIMAGE option added (enabled by default - see LLCLOptions.inc)
2428
Version 1.00:
2529
* TImage: Show and Hide added (see TGraphicControl)
2630
* TImage: Stretch added
@@ -66,6 +70,7 @@
6670
{$I LLCLFPCInc.inc} // For mode
6771
{$undef LLCL_FPC_MODESECTION}
6872
{$ENDIF}
73+
{$ifdef FPC_OBJFPC} {$define LLCL_OBJFPC_MODE} {$endif} // Object pascal mode
6974

7075
{$I LLCLOptions.inc} // Options
7176

@@ -78,13 +83,16 @@ interface
7883
Classes, Controls, {$ifdef LLCL_OPT_USEMENUS}Menus,{$endif} Graphics;
7984

8085
type
86+
87+
{$ifdef LLCL_OPT_USEIMAGE}
8188
TImage = class(TGraphicControl)
8289
private
8390
fPicture: TPicture;
8491
fStretch: boolean;
8592
function GetPicture(): TPicture;
8693
procedure SetPicture(APicture: TPicture);
8794
procedure SetStretch(const Value: boolean);
95+
procedure Changed(Sender: TObject);
8896
protected
8997
procedure ReadProperty(const PropName: string; Reader: TReader); override;
9098
function SubProperty(const SubPropName: string): TPersistent; override;
@@ -95,6 +103,7 @@ TImage = class(TGraphicControl)
95103
property Picture: TPicture read GetPicture write SetPicture;
96104
property Stretch: boolean read fStretch write SetStretch;
97105
end;
106+
{$endif LLCL_OPT_USEIMAGE}
98107

99108
TTimer = class(TNonVisualControl)
100109
private
@@ -187,8 +196,10 @@ implementation
187196
{$PUSH} {$HINTS OFF}
188197
{$ENDIF}
189198

199+
{$ifdef LLCL_OPT_USEIMAGE}
190200
type
191201
TPPicture = class(TPicture); // To access to protected part
202+
{$endif LLCL_OPT_USEIMAGE}
192203

193204
const
194205
NIF_MESSAGE = $00000001; // SysTray
@@ -217,6 +228,7 @@ function LMessages_Dummy(const Msg: TLMCommand): boolean;
217228
end;
218229
{$ENDIF FPC}
219230

231+
{$ifdef LLCL_OPT_USEIMAGE}
220232
{ TImage }
221233

222234
constructor TImage.Create(AOwner: TComponent);
@@ -236,6 +248,7 @@ function TImage.GetPicture(): TPicture;
236248
begin
237249
if fPicture=nil then
238250
fPicture := TPicture.Create;
251+
fPicture.OnChange := {$IFDEF LLCL_OBJFPC_MODE}@{$ENDIF}Changed;
239252
result := fPicture;
240253
end;
241254

@@ -248,7 +261,13 @@ procedure TImage.SetStretch(const Value: boolean);
248261
begin
249262
if fStretch=Value then exit;
250263
fStretch := Value;
251-
Show;
264+
Changed(self);
265+
end;
266+
267+
procedure TImage.Changed(Sender: TObject);
268+
begin
269+
if Visible then
270+
InvalidateEx(true);
252271
end;
253272

254273
procedure TImage.ReadProperty(const PropName: string; Reader: TReader);
@@ -274,6 +293,7 @@ procedure TImage.Paint;
274293
if fPicture<>nil then
275294
TPPicture(fPicture).DrawRect(ClientRect, Canvas, fStretch); // not VCL standard, but works for BITMAP
276295
end;
296+
{$endif LLCL_OPT_USEIMAGE}
277297

278298
{ TTimer }
279299

@@ -530,7 +550,7 @@ procedure TTrayIcon.ShowBalloonHint;
530550
//------------------------------------------------------------------------------
531551

532552
initialization
533-
RegisterClasses([TImage, TTimer, TTrayIcon]);
553+
RegisterClasses([TTimer, TTrayIcon {$ifdef LLCL_OPT_USEIMAGE}, TImage{$endif}]);
534554

535555
{$IFDEF FPC}
536556
{$POP}

‎sources/FileCtrl.pas

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
unit FileCtrl;
2+
3+
{
4+
LLCL - FPC/Lazarus Light LCL
5+
based upon
6+
LVCL - Very LIGHT VCL
7+
----------------------------
8+
9+
This file is a part of the Light LCL (LLCL).
10+
11+
This Source Code Form is subject to the terms of the Mozilla Public
12+
License, v. 2.0. If a copy of the MPL was not distributed with this
13+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
14+
15+
This Source Code Form is "Incompatible With Secondary Licenses",
16+
as defined by the Mozilla Public License, v. 2.0.
17+
18+
Copyright (c) 2015-2016 ChrisF
19+
20+
Based upon the Very LIGHT VCL (LVCL):
21+
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
22+
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
23+
24+
Version 1.01:
25+
* File creation.
26+
* SelectDirectory added (for Delphi)
27+
}
28+
29+
{$IFDEF FPC}
30+
{$define LLCL_FPC_MODESECTION}
31+
{$I LLCLFPCInc.inc} // For mode
32+
{$undef LLCL_FPC_MODESECTION}
33+
{$ENDIF}
34+
35+
{$I LLCLOptions.inc} // Options
36+
37+
//------------------------------------------------------------------------------
38+
39+
interface
40+
41+
uses
42+
LLCLOSInt;
43+
44+
type
45+
TSelectDirExtOpt = (sdNewFolder, sdShowEdit, sdShowShares, sdNewUI,
46+
sdShowFiles, sdValidateDir);
47+
TSelectDirExtOpts = set of TSelectDirExtOpt;
48+
49+
{$IFNDEF FPC} // SelectDirectory is in Dialogs.pas for FPC/Lazarus
50+
function SelectDirectory(const Caption: string; const Root: string; var Directory: string): boolean; overload;
51+
{$if CompilerVersion >= 18)} // Delphi 2006 or after
52+
function SelectDirectory(const Caption: string; const Root: string; var Directory: string; Options: TSelectDirExtOpts = [sdNewUI]; Parent: TWinControl = nil): boolean; overload;
53+
{$ifend}
54+
{$ENDIF}
55+
56+
// (Not VCL/LCL standard - Called from Dialogs.pas for FPC)
57+
function FC_SelectDirectory(const Caption: string; const InitialDirectory: string; Options: TSelectDirExtOpts; var Directory: string): Boolean;
58+
59+
//------------------------------------------------------------------------------
60+
61+
implementation
62+
63+
uses
64+
{$IFNDEF FPC}ShlObj,{$ENDIF}
65+
Forms;
66+
67+
{$IFDEF FPC}
68+
{$PUSH} {$HINTS OFF}
69+
{$ENDIF}
70+
71+
//------------------------------------------------------------------------------
72+
73+
{$IFNDEF FPC}
74+
function SelectDirectory(const Caption: string; const Root: string; var Directory: string): Boolean;
75+
begin
76+
result := FC_SelectDirectory(Caption, Root, [], Directory);
77+
end;
78+
79+
{$if CompilerVersion >= 18)} // Delphi 2006 or after
80+
function SelectDirectory(const Caption: string; const Root: string; var Directory: string; Options: TSelectDirExtOpts = [sdNewUI]; Parent: TWinControl = nil): boolean; overload;
81+
begin
82+
result := FC_SelectDirectory(Caption, Root, Options, Directory);
83+
end;
84+
{$ifend}
85+
86+
{$ENDIF}
87+
88+
function FC_SelectDirectory(const Caption: string; const InitialDirectory: string; Options: TSelectDirExtOpts; var Directory: string): Boolean;
89+
var BrowseInfo: TBrowseInfo;
90+
begin
91+
FillChar(BrowseInfo, SizeOf(BrowseInfo), 0);
92+
BrowseInfo.hwndOwner := Application.MainForm.Handle;
93+
BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS;
94+
if (sdNewUI in Options) or (sdShowShares in Options) then
95+
begin
96+
BrowseInfo.ulFlags := BrowseInfo.ulFlags or BIF_NEWDIALOGSTYLE;
97+
if not (sdNewFolder in Options) then
98+
BrowseInfo.ulFlags := BrowseInfo.ulFlags or BIF_NONEWFOLDERBUTTON;
99+
if (sdShowShares in Options) then
100+
BrowseInfo.ulFlags := BrowseInfo.ulFlags or BIF_SHAREABLE;
101+
end;
102+
if (sdShowEdit in Options) then
103+
BrowseInfo.ulFlags := BrowseInfo.ulFlags or BIF_EDITBOX;
104+
if (sdShowFiles in Options) then
105+
BrowseInfo.ulFlags := BrowseInfo.ulFlags or BIF_BROWSEINCLUDEFILES;
106+
if (sdValidateDir in Options) and (sdShowEdit in Options) then
107+
BrowseInfo.ulFlags := BrowseInfo.ulFlags or BIF_VALIDATE;
108+
result := LLCLS_SH_BrowseForFolder(BrowseInfo, Caption, InitialDirectory, Directory);
109+
end;
110+
111+
//------------------------------------------------------------------------------
112+
113+
{$IFDEF FPC}
114+
{$POP}
115+
{$ENDIF}
116+
117+
end.

‎sources/FileUtil.pas

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
2425
Version 1.00:
2526
* File creation.
2627
* UTF8 file functions (equivalent of SysUtils ones - mapped to LazFileutils)

‎sources/Forms.pas

+15-8
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
25+
* Bug fix: Color in TCustomForm
26+
* TForm: 'BorderStyle', 'Position' and 'FormStyle' properties now accessible (design time only)
27+
* TApplication: AppHandle moved in protected part
2428
Version 1.00:
2529
* Old unused properties removed: OldCreateOrder, PixelsPerInch and TextHeight
2630
* IsAccel function added
@@ -177,6 +181,9 @@ TCustomForm = class(TWinControl)
177181
property ActiveControl: TWinControl read fActiveControl write SetActiveControl;
178182
property KeyPreview: boolean read fKeyPreview write fKeyPreview;
179183
property WindowState: TWindowState read fWindowState write SetWindowState;
184+
property BorderStyle: TFormBorderStyle read fBorderStyle write fBorderStyle; // Run-time modification ignored; write present only for dynamical control creation purpose
185+
property Position: TPosition read fPosition write fPosition; // Run-time modification ignored; write present only for dynamical control creation purpose
186+
property FormStyle: TFormStyle read fFormStyle write fFormStyle; // Run-time modification ignored; write present only for dynamical control creation purpose
180187
{$ifdef LLCL_OPT_USEMENUS}
181188
property Menu: TMainMenu read fMenu write fMenu;
182189
{$endif}
@@ -213,7 +220,6 @@ TApplication = class(TComponent)
213220
{$endif}
214221
EOnMinimize,
215222
EOnRestore: TNotifyEvent;
216-
function AppHandle(): THandle;
217223
procedure SetTitle(const Value: string);
218224
procedure SetBiDiMode(const Value: TBiDiMode);
219225
{$ifndef DefNo_MainFormOnTaskBar}
@@ -224,6 +230,8 @@ TApplication = class(TComponent)
224230
{$ifdef LLCL_OPT_TOPFORM}
225231
procedure SetVisible(ShowCall: boolean);
226232
{$endif}
233+
protected
234+
function AppHandle(): THandle;
227235
public
228236
constructor Create(AOwner: TComponent); override;
229237
destructor Destroy; override;
@@ -328,7 +336,7 @@ function RPos(const SubStr : string; const S: string): cardinal;
328336

329337
{ TCustomForm }
330338

331-
constructor TCustomForm.Create(AOwner:TComponent);
339+
constructor TCustomForm.Create(AOwner: TComponent);
332340
begin
333341
ATType := ATTCustomForm; // Needed before inherited
334342
inherited;
@@ -427,7 +435,8 @@ procedure TCustomForm.CreateHandle;
427435
SetBounds(aRect.Left, aRect.Top, Width, Height);
428436
// UI
429437
if CheckWin32Version(LLCL_WIN2000_MAJ, LLCL_WIN2000_MIN) then
430-
LLCL_PostMessage(Handle, WM_CHANGEUISTATE, WPARAM(UIS_INITIALIZE or ((UISF_HIDEFOCUS or UISF_HIDEACCEL) shl 16)), 0);
438+
// (Clear UI states if LLCL_OPT_NESTEDGROUPBOXWINXPFIX activated)
439+
LLCL_PostMessage(Handle, WM_CHANGEUISTATE, WPARAM({$ifdef LLCL_OPT_NESTEDGROUPBOXWINXPFIX}UIS_CLEAR{$else}UIS_INITIALIZE{$endif} or ((UISF_HIDEFOCUS or UISF_HIDEACCEL) shl 16)), 0);
431440
end;
432441

433442
procedure TCustomForm.CreateParams(var Params : TCreateParams);
@@ -833,7 +842,6 @@ procedure TApplication.CreateHandle;
833842
var WndClass: TWndClass;
834843
var Style, ExStyle: cardinal;
835844
var SystemMenu: THandle;
836-
var sClassName: string; // Conversion needed (especially because System and RTL are not fully Unicode for FPC)
837845
begin
838846
// Application Class
839847
FillChar(WndClass, SizeOf(WndClass), 0);
@@ -850,8 +858,7 @@ procedure TApplication.CreateHandle;
850858
ExStyle := 0;
851859
if (not fMainFormOnTaskBar) then
852860
ExStyle := ExStyle or WS_EX_APPWINDOW;
853-
sClassName := string(WndClass.lpszClassName);
854-
fHandle := LLCL_CreateWindowEx(ExStyle, @sClassName[1], @fTitle[1], Style,
861+
fHandle := LLCL_CreateWindowEx(ExStyle, TAPPL_CLASS, @fTitle[1], Style,
855862
LLCL_GetSystemMetrics(SM_CXSCREEN) div 2, LLCL_GetSystemMetrics(SM_CYSCREEN) div 2,
856863
0, 0, 0, 0, WndClass.hInstance, nil);
857864
SystemMenu := LLCL_GetSystemMenu(fHandle, False);

‎sources/Graphics.pas

+345-120
Large diffs are not rendered by default.

‎sources/Grids.pas

+1,527
Large diffs are not rendered by default.

‎sources/IniFiles.pas

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
unit IniFiles;
2+
3+
{
4+
LLCL - FPC/Lazarus Light LCL
5+
based upon
6+
LVCL - Very LIGHT VCL
7+
----------------------------
8+
9+
This file is a part of the Light LCL (LLCL).
10+
11+
This Source Code Form is subject to the terms of the Mozilla Public
12+
License, v. 2.0. If a copy of the MPL was not distributed with this
13+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
14+
15+
This Source Code Form is "Incompatible With Secondary Licenses",
16+
as defined by the Mozilla Public License, v. 2.0.
17+
18+
Copyright (c) 2015-2016 ChrisF
19+
20+
Based upon the Very LIGHT VCL (LVCL):
21+
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
22+
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
23+
24+
Version 1.01:
25+
* File creation.
26+
* TIniFile implemented
27+
}
28+
29+
{$IFDEF FPC}
30+
{$define LLCL_FPC_MODESECTION}
31+
{$I LLCLFPCInc.inc} // For mode
32+
{$undef LLCL_FPC_MODESECTION}
33+
{$ENDIF}
34+
35+
{$I LLCLOptions.inc} // Options
36+
37+
//------------------------------------------------------------------------------
38+
39+
interface
40+
41+
uses
42+
LLCLOSInt,
43+
Classes, SysUTils;
44+
45+
type
46+
// (No intermediate classes used)
47+
TIniFile = class(TObject)
48+
private
49+
fFileName: string;
50+
public
51+
constructor Create(const AFileName: string);
52+
function ReadString(const Section, Ident, Default: string): string; virtual;
53+
procedure WriteString(const Section, Ident, Value: string); virtual;
54+
function ReadInteger(const Section, Ident: string; Default: integer): integer; virtual;
55+
procedure WriteInteger(const Section, Ident: string; Value: integer); virtual;
56+
function ReadInt64(const Section, Ident: string; Default: int64): int64; virtual;
57+
procedure WriteInt64(const Section, Ident: string; Value: int64); virtual;
58+
function ReadBool(const Section, Ident: string; Default: boolean): boolean; virtual;
59+
procedure WriteBool(const Section, Ident: string; Value: boolean); virtual;
60+
// (Caution: string date formating with LLCL SysUtils is specific)
61+
function ReadDate(const Section, Ident: string; Default: TDateTime): TDateTime; virtual;
62+
procedure WriteDate(const Section, Ident: string; Value: TDateTime); virtual;
63+
procedure DeleteKey(const Section, Ident: string); virtual;
64+
procedure EraseSection(const Section: string); virtual;
65+
property FileName: string read fFileName;
66+
end;
67+
68+
//------------------------------------------------------------------------------
69+
70+
implementation
71+
72+
{$IFDEF FPC}
73+
{$PUSH} {$HINTS OFF}
74+
{$ENDIF}
75+
76+
{ TIniFile }
77+
78+
constructor TIniFile.Create(const AFileName: string);
79+
begin
80+
inherited Create();
81+
if ExtractFilePath(AFileName)='' then
82+
fFileName := '.\' + AFileName
83+
else
84+
fFileName := AFileName;
85+
end;
86+
87+
function TIniFile.ReadString(const Section, Ident, Default: string): string;
88+
begin
89+
result := LLCLS_INI_ReadString(fFileName, Section, Ident, Default);
90+
end;
91+
92+
procedure TIniFile.WriteString(const Section, Ident, Value: string);
93+
begin
94+
LLCLS_INI_WriteString(fFileName, Section, Ident, Value);
95+
end;
96+
97+
function TIniFile.ReadInteger(const Section, Ident: string; Default: integer): integer;
98+
begin
99+
result := StrToIntDef(ReadString(Section, Ident, ''), Default);
100+
end;
101+
102+
procedure TIniFile.WriteInteger(const Section, Ident: string; Value: integer);
103+
begin
104+
WriteString(Section, Ident, IntToStr(Value));
105+
end;
106+
107+
function TIniFile.ReadInt64(const Section, Ident: string; Default: int64): int64;
108+
begin
109+
result := StrToInt64Def(ReadString(Section, Ident, ''), Default);
110+
end;
111+
112+
procedure TIniFile.WriteInt64(const Section, Ident: string; Value: int64);
113+
begin
114+
WriteString(Section, Ident, IntToStr(Value));
115+
end;
116+
117+
function TIniFile.ReadBool(const Section, Ident: string; Default: boolean): boolean;
118+
begin
119+
result := (ReadInteger(Section, Ident, integer(Default))<>0);
120+
end;
121+
122+
procedure TIniFile.WriteBool(const Section, Ident: string; Value: boolean);
123+
const BoolString: array[boolean] of string = ('0', '1');
124+
begin
125+
WriteString(Section, Ident, BoolString[Value]);
126+
end;
127+
128+
function TIniFile.ReadDate(const Section, Ident: string; Default: TDateTime): TDateTime;
129+
begin
130+
if not TryStrToDate(ReadString(Section, Ident, ''), result) then
131+
result := Default;
132+
end;
133+
134+
procedure TIniFile.WriteDate(const Section, Ident: string; Value: TDateTime);
135+
begin
136+
WriteString(Section, Ident, DateToStr(Value));
137+
end;
138+
139+
procedure TIniFile.DeleteKey(const Section, Ident: string);
140+
begin
141+
LLCLS_INI_Delete(fFileName, @Section[1], @Ident[1]);
142+
end;
143+
144+
procedure TIniFile.EraseSection(const Section: string);
145+
begin
146+
LLCLS_INI_Delete(fFileName, @Section[1], nil);
147+
end;
148+
149+
//------------------------------------------------------------------------------
150+
151+
{$IFDEF FPC}
152+
{$POP}
153+
{$ENDIF}
154+
155+
end.

‎sources/Interfaces.pp

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
2425
Version 1.00:
2526
* File creation.
2627

‎sources/LCLIntF.pas

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
unit LCLIntF;
2+
3+
{
4+
LLCL - FPC/Lazarus Light LCL
5+
based upon
6+
LVCL - Very LIGHT VCL
7+
----------------------------
8+
9+
This file is a part of the Light LCL (LLCL).
10+
11+
This Source Code Form is subject to the terms of the Mozilla Public
12+
License, v. 2.0. If a copy of the MPL was not distributed with this
13+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
14+
15+
This Source Code Form is "Incompatible With Secondary Licenses",
16+
as defined by the Mozilla Public License, v. 2.0.
17+
18+
Copyright (c) 2015-2016 ChrisF
19+
20+
Based upon the Very LIGHT VCL (LVCL):
21+
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
22+
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
23+
24+
Version 1.01:
25+
* File creation.
26+
27+
Notes:
28+
- very basic unit specific to FPC/Lazarus (not used with Delphi).
29+
}
30+
31+
{$IFDEF FPC}
32+
{$define LLCL_FPC_MODESECTION}
33+
{$I LLCLFPCInc.inc} // For mode
34+
{$undef LLCL_FPC_MODESECTION}
35+
{$ENDIF}
36+
37+
{$I LLCLOptions.inc} // Options
38+
39+
//------------------------------------------------------------------------------
40+
41+
interface
42+
43+
uses
44+
LLCLOSInt,
45+
Windows;
46+
47+
const
48+
LM_USER = Windows.WM_USER;
49+
50+
function CallWindowProc(lpPrevWndFunc: TFarProc; Handle: HWND; Msg: UINT; WParam: WParam; LParam: LParam): integer;
51+
function PostMessage(Handle: HWND; Msg: Cardinal; WParam: WParam; LParam: LParam): boolean;
52+
function SendMessage(Handle: HWND; Msg: Cardinal; WParam: WParam; LParam: LParam): LRESULT;
53+
54+
function MakeLong(A, B: word): DWORD; inline;
55+
function MakeWParam(l, h: word): WPARAM; inline;
56+
function MakeLParam(l, h: word): LPARAM; inline;
57+
function MakeLResult(l, h: word): LRESULT; inline;
58+
59+
//------------------------------------------------------------------------------
60+
61+
implementation
62+
63+
{$IFDEF FPC}
64+
{$PUSH} {$HINTS OFF}
65+
{$ENDIF}
66+
67+
//------------------------------------------------------------------------------
68+
69+
function CallWindowProc(lpPrevWndFunc: TFarProc; Handle: HWND; Msg: UINT; WParam: WParam; LParam: LParam): integer;
70+
begin
71+
result := LLCL_CallWindowProc(lpPrevWndFunc, Handle, Msg, WParam, LParam);
72+
end;
73+
74+
function PostMessage(Handle: HWND; Msg: Cardinal; WParam: WParam; LParam: LParam): boolean;
75+
begin
76+
result := LLCL_PostMessage(Handle, Msg, WParam, LParam);
77+
end;
78+
79+
function SendMessage(Handle: HWND; Msg: Cardinal; WParam: WParam; LParam: LParam): LRESULT;
80+
begin
81+
result := LLCL_SendMessage(Handle, Msg, WParam, LParam);
82+
end;
83+
84+
function MakeLong(A, B: word): DWORD; inline;
85+
begin
86+
result := A or (B shl 16);
87+
end;
88+
89+
function MakeWParam(l, h: word): WPARAM; inline;
90+
begin
91+
result := MakeLong(l, h);
92+
end;
93+
94+
function MakeLParam(l, h: word): LPARAM; inline;
95+
begin
96+
result := MakeLong(l, h);
97+
end;
98+
99+
function MakeLResult(l, h: word): LRESULT; inline;
100+
begin
101+
result := MakeLong(l, h);
102+
end;
103+
104+
//------------------------------------------------------------------------------
105+
106+
{$IFDEF FPC}
107+
{$POP}
108+
{$ENDIF}
109+
110+
end.

‎sources/LCLType.pp

+29-11
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
25+
* RT_**** constants added (point to Windows declarations)
2426
Version 1.00:
2527
* File creation.
2628
@@ -45,17 +47,33 @@ interface
4547

4648
type
4749
TCreateParams = record // Not present in Control.pas for FPC/Lazarus
48-
Caption: PChar;
49-
Style: cardinal;
50-
ExStyle: cardinal;
51-
X, Y: integer;
52-
Width, Height: integer;
53-
WndParent: HWnd;
54-
Param: pointer;
55-
WindowClass: TWndClass;
56-
WinClassName: array[0..63] of Char;
50+
Caption: PChar;
51+
Style: cardinal;
52+
ExStyle: cardinal;
53+
X, Y: integer;
54+
Width, Height: integer;
55+
WndParent: HWnd;
56+
Param: pointer;
57+
WindowClass: TWndClass;
58+
WinClassName: array[0..63] of Char;
5759
end;
5860

61+
const
62+
RT_CURSOR = Windows.RT_CURSOR;
63+
RT_BITMAP = Windows.RT_BITMAP;
64+
RT_ICON = Windows.RT_ICON;
65+
RT_MENU = Windows.RT_MENU;
66+
RT_DIALOG = Windows.RT_DIALOG;
67+
RT_STRING = Windows.RT_STRING;
68+
RT_FONTDIR = Windows.RT_FONTDIR;
69+
RT_FONT = Windows.RT_FONT;
70+
RT_ACCELERATOR = Windows.RT_ACCELERATOR;
71+
RT_RCDATA = Windows.RT_RCDATA;
72+
RT_MESSAGETABLE = Windows.RT_MESSAGETABLE;
73+
RT_GROUP_CURSOR = Windows.RT_GROUP_CURSOR;
74+
RT_GROUP_ICON = Windows.RT_GROUP_ICON;
75+
RT_VERSION = Windows.RT_VERSION;
76+
5977
//------------------------------------------------------------------------------
6078

6179
implementation

‎sources/LLCLFPCInc.inc

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
Optional compilation directives for FPC/Lazarus
2+
Optional compilation directives for FPC/Lazarus
33
4-
This file is a part of the Light LCL (LLCL).
4+
This file is a part of the Light LCL (LLCL).
55
6-
Notes:
7-
- specific to FPC/Lazarus (not used with Delphi),
8-
- external file because of Delphi (i.e. $if problem).
6+
Notes:
7+
- specific to FPC/Lazarus (not used with Delphi),
8+
- external file because of Delphi (i.e. $if problem).
99
}
1010

1111
{$ifdef LLCL_FPC_MODESECTION}
@@ -14,7 +14,12 @@
1414
{$mode objfpc}{$H+}
1515
// {$mode delphi}
1616
// {$mode objfpc}{$modeswitch unicodestrings}{$H+} // Requires FPC 2.7.1+
17-
// {$mode delphiunicode} // Requires FPC 2.7.1+
17+
// {$mode delphiunicode}{$codepage UTF8} // Requires FPC 2.7.1+
18+
19+
// Specific (i.e. not LCL standard) Ansi only option (no UTF8 at all)
20+
// Can't be used with any Unicode mode ({$modeswitch unicodestrings} or {$mode delphiunicode})
21+
// {$define LLCL_FPC_ANSI_ONLY}
22+
{$IFDEF UNICODE} {$undef LLCL_FPC_ANSI_ONLY} {$ENDIF}
1823

1924
{$else LLCL_FPC_MODESECTION}
2025
//------------------------------------------------------------------------------
@@ -44,18 +49,20 @@
4449

4550
// LLCLOSInt
4651
{$define LLCL_MISSING_WINDOWS_DEC} // Windows declarations missing
52+
{$define LLCL_FPC_UTF8_EXTINC} // Constant message strings: UTF8 type
4753
{$if defined(FPC_FULLVERSION) and (FPC_FULLVERSION >= 999999)}
4854
{$undef LLCL_MISSING_WINDOWS_DEC}
4955
{$ifend}
5056
{$if defined(LLCL_FPC_27PLUS)}
5157
{$define LLCL_EXTWIN_WIDESTRUCT} // External Windows wide structures
5258
{$define LLCL_FPC_CPSTRING} // RawByteStrings have code page
53-
{$ifdef EnableUTF8RTL}
54-
{$define LLCL_FPC_UTF8RTL} // Has UTF8 RTL (LCL)
59+
{$define LLCL_FPC_UTF8RTL} // Has UTF8 RTL (LCL)
60+
{$ifdef DisableUTF8RTL}
61+
{$undef LLCL_FPC_UTF8RTL} // Compliant with LCL
5562
{$endif}
56-
{$else}
57-
{$ifdef EnableUTF8RTL}
58-
{$error EnableUTF8RTL requires FPC 2.7.1+}
63+
{$ifdef LLCL_FPC_ANSI_ONLY} // Specific to LLCL
64+
{$undef LLCL_FPC_UTF8RTL} // " "
65+
{$undef LLCL_FPC_UTF8_EXTINC} // " "
5966
{$endif}
6067
{$ifend}
6168

‎sources/LLCLOSInt.pas

+941-107
Large diffs are not rendered by default.

‎sources/LLCLOptions.inc

+136-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
{
2-
Main options: compilation directives
2+
Main options: compilation directives
33
4-
This file is a part of the Light LCL (LLCL).
5-
6-
Notes: Except for the Ansi/Unicode APIs options,
7-
- all the following options are defined by default,
8-
- undefining them usually permits to shrink a little bit
9-
the size of the final executable, but with the penality
10-
of having not the concerned functionnality.
4+
This file is a part of the Light LCL (LLCL).
115
}
126

137
//------------------------------------------------------------------------------
148

9+
{
10+
Section 1: options defined by default.
11+
12+
Undefining them usually permits to shrink a little bit the size
13+
of the final executable, but with the penality of having not the
14+
concerned functionnality.
15+
}
16+
1517
{ LLCL_OPT_TOPFORM - Forms.pas
1618
1719
"Top invisible" form above all forms and enhanced multi-forms support
@@ -34,14 +36,23 @@
3436

3537
{ LLCL_OPT_USEDIALOG - Dialogs.pas
3638
37-
OpenDialog/SaveDialog used in program
39+
OpenDialog/SaveDialog(/SelectDirectoryDialog) classes used in program
3840
39-
Notes: when undefined, this permits to use the ShowMessage function
40-
without a size penality due to the TOpenDialog/TSaveDialog classes.
41-
This option has no effect if the Dialogs units is not used.
41+
Notes: when undefined, this permits to use the ShowMessage and the
42+
SelectDirectory functions without a size penality due to the Dialog classes.
43+
This option has no effect if the Dialogs unit is not used.
4244
}
4345
{$DEFINE LLCL_OPT_USEDIALOG}
4446

47+
{ LLCL_OPT_USEIMAGE - ExtCtrls.pas
48+
49+
Image class used in program
50+
51+
Notes: when undefined, this permits to use the ExtCtrls unit (Timer and
52+
TrayIcon controls) without a size penality due to the Image class.
53+
}
54+
{$DEFINE LLCL_OPT_USEIMAGE}
55+
4556
{ LLCL_OPT_EXCEPTIONS - SysUtils.pas
4657
4758
Support (limited) for Exceptions
@@ -58,18 +69,129 @@
5869

5970
//------------------------------------------------------------------------------
6071

72+
{
73+
Section 2: options not defined by default.
74+
75+
Defining them permits to have the corresponding functionnality
76+
or fix, but with the penality of having an extra size in the
77+
final executable.
78+
}
79+
80+
{ LLCL_OPT_USESELECTDIRECTORYDIALOG - Dialogs.pas
81+
82+
SelectDirectoryDialog class used in program
83+
84+
Notes: when defined, this permits to use the SelectDirectoryDialog
85+
class (use preferably the SelectDirectory function instead).
86+
This option has no effect if the Dialogs unit is not used,
87+
or if the LLCL_OPT_USEDIALOG option is not set.
88+
}
89+
{$IFDEF FPC}
90+
//{$DEFINE LLCL_OPT_USESELECTDIRECTORYDIALOG}
91+
{$ENDIF}
92+
93+
{ LLCL_OPT_NESTEDGROUPBOXWINXPFIX - Forms.pas, Controls.pas
94+
95+
Fix for the nested groupboxes issue with Windows XP
96+
97+
Notes: this concerns only Windows XP (not before and not after),
98+
and only if nested groupboxes are used (font display issue).
99+
When set, this option also implies that UI states (accelerators
100+
and focus rectangles) are visible when the application starts
101+
(which is not the standard for a Windows application).
102+
}
103+
//{$DEFINE LLCL_OPT_NESTEDGROUPBOXWINXPFIX}
104+
105+
{ LLCL_OPT_PNGSUPPORT - Graphics.pas
106+
LLCL_OPT_PNGSIMPLIFIED - LLCLPng.pas
107+
LLCL_OPT_IMGTRANSPARENT - Graphics.pas
108+
LLCL_OPT_DOUBLEBUFF - Control.pas
109+
110+
Extended graphical options
111+
112+
Notes:
113+
- when defined, LLCL_OPT_PNGSUPPORT permits the support of
114+
PNG files/resources in the TBitmap class,
115+
- LLCL_OPT_PNGSIMPLIFIED (requires LLCL_OPT_PNGSUPPORT) allows only the
116+
basic types of PNG files/resources: truecolour 8 bits (colour type = 2),
117+
truecolour + alpha 8 bits (colour type = 6) or indexed colour 1,4,8 bits
118+
(colour type = 3); with no interlaced data. Furthermore, the
119+
transparency chunk data are ignored in this case,
120+
- when defined, LLCL_OPT_IMGTRANSPARENT permits the support of
121+
transparent images/bitmaps (only for Windows 2000 or newer),
122+
- when defined, LLCL_OPT_DOUBLEBUFF permits the support of the double
123+
buffering painting method for Forms (if DoubleBuffered = true),
124+
- for simplification, with LLCL_OPT_EXTENDGRAPHICAL all these options
125+
are defined. However, these options are completely independent and
126+
may be defined individually,
127+
- except for the LLCL_OPT_DOUBLEBUFF option, these options have no
128+
effects if the LLCL_OPT_USEIMAGE option is not defined.
129+
}
130+
//{$DEFINE LLCL_OPT_EXTENDGRAPHICAL}
131+
{$IF DEFINED(LLCL_OPT_EXTENDGRAPHICAL)}
132+
{$DEFINE LLCL_OPT_PNGSUPPORT}
133+
//{$DEFINE LLCL_OPT_PNGSIMPLIFIED}
134+
{$DEFINE LLCL_OPT_IMGTRANSPARENT}
135+
{$DEFINE LLCL_OPT_DOUBLEBUFF}
136+
{$IFEND}
137+
138+
//------------------------------------------------------------------------------
139+
140+
{
141+
Section 3: options with various possible values
142+
}
143+
61144
{ LLCL_OPT_UNICODE_API_A/W/W_ONLY - LLCLOSInt.pas
62145
63146
Windows Ansi and/or Unicode/WideString APIs to use
64147
65148
Notes:
66-
- LLCL_OPT_UNICODE_API_A: forces to use the Ansi APIs only
67-
- LLCL_OPT_UNICODE_API_W: forces to use both the Ansi and the Unicode APIs
149+
- LLCL_OPT_UNICODE_API_A: forces to use the Ansi APIs only (default for Delphi 7)
150+
- LLCL_OPT_UNICODE_API_W: forces to use both the Ansi and the Unicode APIs (default for FPC/Lazarus)
68151
- LLCL_OPT_UNICODE_API_W_ONLY: forces to use the Unicode APIs only
152+
69153
By default, these options are not concerning the Windows API calls in
70154
SysUtils for Free Pascal/Lazarus (see LLCL_FPC_SYSRTL in LLCLFPCInc.inc).
71155
}
72156
//{$DEFINE LLCL_OPT_UNICODE_API_A}
73157
//{$DEFINE LLCL_OPT_UNICODE_API_W}
74158
//{$DEFINE LLCL_OPT_UNICODE_API_W_ONLY}
75159

160+
{ LLCL_OPT_GRIDSOPT_1/2/LV/ALL - Grids.pas
161+
162+
TStringGrid options
163+
164+
Notes:
165+
- LLCL_OPT_GRIDSOPT_1: TStringGrid compatibility Level 1 (proposed default)
166+
. support for "DefaultRowHeight" property
167+
. support for column sorting
168+
- LLCL_OPT_GRIDSOPT_2: TStringGrid compatibility Level 2
169+
. options for LLCL_OPT_GRIDSOPT_1
170+
. support for cells mouse button events
171+
. support for header (i.e. fixed row) mouse messages
172+
. support for first column editing
173+
- LLCL_OPT_GRIDSOPT_LV: ListView compatibility
174+
. right-click selects also a row (like left-click)
175+
. Ctrl+A selects all the rows
176+
- LLCL_OPT_GRIDSOPT_ALL: all options (LLCL_OPT_GRIDSOPT_2 + LLCL_OPT_GRIDSOPT_LV)
177+
}
178+
{$DEFINE LLCL_OPT_GRIDSOPT_1}
179+
//{$DEFINE LLCL_OPT_GRIDSOPT_2}
180+
//{$DEFINE LLCL_OPT_GRIDSOPT_LV}
181+
//{$DEFINE LLCL_OPT_GRIDSOPT_ALL}
182+
183+
{ LLCL_OPT_USEZLIBDLL/USEZLIBDLLDYN/USEZLIBOBJ - LLCLZlib.pas
184+
185+
Zlib options
186+
187+
Notes:
188+
- LLCL_OPT_USEZLIBDLL: use static ZLib DLL (zlib1.dll)
189+
- LLCL_OPT_USEZLIBDLLDYN: use dynamic ZLib DLL (zlib1.dll) - requires LLCL_OPT_USEZLIBDLL
190+
- LLCL_OPT_USEZLIBOBJ: use external (C) object files
191+
192+
If no such option is defined, pure Pascal functions are used (i.e. PasZlib).
193+
}
194+
//{$DEFINE LLCL_OPT_USEZLIBDLL}
195+
//{$DEFINE LLCL_OPT_USEZLIBDLLDYN}
196+
//{$DEFINE LLCL_OPT_USEZLIBOBJ}
197+

‎sources/LLCLPng.pas

+892
Large diffs are not rendered by default.

‎sources/LLCLZlib.pas

+464
Large diffs are not rendered by default.

‎sources/LMessages.pp

+38-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
25+
* TWMMove, TWMNotify, TWMSysCommand added
2426
Version 1.00:
2527
* File creation.
2628
@@ -179,6 +181,20 @@ TWMMouse = record
179181
TWMRButtonDblClk = TWMMouse;
180182
TWMMouseMove = TWMMouse;
181183

184+
TWMMove = record
185+
Msg: cardinal;
186+
MsgFiller: TDWordFiller;
187+
Unused: WPARAM;
188+
case integer of
189+
0: (
190+
XPos: smallint;
191+
YPos: smallint; );
192+
1: (
193+
Pos: TSmallPoint;
194+
LParamFiller: TDWordFiller;
195+
Result: LRESULT; );
196+
end;
197+
182198
TWMNCHitTest = record
183199
Msg: cardinal;
184200
MsgFiller: TDWordFiller;
@@ -193,6 +209,15 @@ TWMNCHitTest = record
193209
Result: LRESULT; );
194210
end;
195211

212+
TWMNotify = record
213+
Msg: cardinal;
214+
MsgFiller: TDWordFiller;
215+
IDCtrl: longint;
216+
WParamFiller: TDWordFiller;
217+
NMHdr: PNMHdr;
218+
Result: LRESULT;
219+
end;
220+
196221
TWMPaint = record
197222
Msg: cardinal;
198223
MsgFiller: TDWordFiller;
@@ -232,6 +257,17 @@ TWMSize = record
232257
Result: LRESULT;
233258
end;
234259

260+
TWMSysCommand = record
261+
Msg: cardinal;
262+
MsgFiller: TDWordFiller;
263+
case CmdType: WPARAM of
264+
SC_HOTKEY: (ActivateWindow: HWND);
265+
SC_KEYMENU: (Key: word);
266+
SC_CLOSE, SC_HSCROLL, SC_MAXIMIZE, SC_MINIMIZE, SC_MOUSEMENU, SC_MOVE,
267+
SC_NEXTWINDOW, SC_PREVWINDOW, SC_RESTORE, SC_SCREENSAVE, SC_SIZE, SC_TASKLIST, SC_VSCROLL:
268+
(XPos: smallint; YPos: smallint; LParamFiller: TDWordFiller; Result: LRESULT; );
269+
end;
270+
235271
TWMTimer = record
236272
Msg: cardinal;
237273
MsgFiller: TDWordFiller;

‎sources/LazFileUtils.pas

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
2425
Version 1.00:
2526
* File creation.
2627
* UTF8 file functions (equivalent of SysUtils ones)

‎sources/LazUTF8.pas

+65-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
25+
* UTF8CompareStr, UTF8CompareText, UTF8LowerCase and UTF8UpperCase added
2426
Version 1.00:
2527
* File creation.
2628
* Some UTF8 functions (not present in LazFileUtils)
@@ -48,11 +50,21 @@ function UTF8ToSys(const S: utf8string): ansistring;
4850
function SysToUTF8(const S: ansistring): utf8string;
4951
function UTF8ToWinCP(const S: utf8string): ansistring;
5052
function WinCPToUTF8(const S: ansistring): utf8string;
53+
function UTF8CompareStr(const S1, S2: utf8string): integer;
54+
function UTF8CompareText(const S1, S2: utf8string): integer;
55+
// Note: ALanguage is ignored in UTF8LowerCase and UTF8UpperCase
56+
function UTF8LowerCase(const AInStr: utf8string; ALanguage: utf8string=''): utf8string;
57+
function UTF8UpperCase(const AInStr: utf8string; ALanguage: utf8string=''): utf8string;
5158
{$ELSE UNICODE}
5259
function UTF8ToSys(const S: string): string;
5360
function SysToUTF8(const S: string): string;
5461
function UTF8ToWinCP(const S: string): string;
5562
function WinCPToUTF8(const S: string): string;
63+
function UTF8CompareStr(const S1, S2: string): integer;
64+
function UTF8CompareText(const S1, S2: string): integer;
65+
// Note: ALanguage is ignored in UTF8LowerCase and UTF8UpperCase
66+
function UTF8LowerCase(const AInStr: string; ALanguage: string=''): string;
67+
function UTF8UpperCase(const AInStr: string; ALanguage: string=''): string;
5668
{$ENDIF UNICODE}
5769

5870
//------------------------------------------------------------------------------
@@ -110,6 +122,57 @@ function WinCPToUTF8(const S: string): string;
110122
result := LLCLS_WinCPToUTF8(S);
111123
end;
112124

125+
{$IFDEF UNICODE}
126+
function UTF8CompareStr(const S1, S2: utf8string): integer;
127+
{$ELSE UNICODE}
128+
function UTF8CompareStr(const S1, S2: string): integer;
129+
{$ENDIF UNICODE}
130+
var count, count1, count2: integer;
131+
begin
132+
count1 := length(S1);
133+
count2 := length(S2);
134+
if count1 > count2 then
135+
count := count2
136+
else
137+
count := count1;
138+
result := CompareByte(pointer(@s1[1])^, pointer(@s2[1])^, count);
139+
if result=0 then
140+
if count1 > count2 then
141+
result := 1 // Doesn't return count1 - count 2
142+
else
143+
if count1 < count2 then
144+
result := -1; // Like CompareStr in SysUTils
145+
end;
146+
147+
{$IFDEF UNICODE}
148+
function UTF8CompareText(const S1, S2: utf8string): integer;
149+
{$ELSE UNICODE}
150+
function UTF8CompareText(const S1, S2: string): integer;
151+
{$ENDIF UNICODE}
152+
begin
153+
result := UTF8CompareStr(UTF8UpperCase(S1), UTF8UpperCase(S2));
154+
end;
155+
156+
{$IFDEF UNICODE}
157+
function UTF8LowerCase(const AInStr: utf8string; ALanguage: utf8string=''): utf8string;
158+
{$ELSE UNICODE}
159+
function UTF8LowerCase(const AInStr: string; ALanguage: string=''): string;
160+
{$ENDIF UNICODE}
161+
begin
162+
// (Language ignored)
163+
result := LLCLS_UTF8LowerCase(AInStr);
164+
end;
165+
166+
{$IFDEF UNICODE}
167+
function UTF8UpperCase(const AInStr: utf8string; ALanguage: utf8string=''): utf8string;
168+
{$ELSE UNICODE}
169+
function UTF8UpperCase(const AInStr: string; ALanguage: string=''): string;
170+
{$ENDIF UNICODE}
171+
begin
172+
// (Language ignored)
173+
result := LLCLS_UTF8UpperCase(AInStr);
174+
end;
175+
113176
//------------------------------------------------------------------------------
114177

115178
{$IFDEF FPC}

‎sources/LazUTF8Classes.pas

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
2425
Version 1.00:
2526
* File creation.
2627
* TFileStreamUTF8 class (simplified)

‎sources/Menus.pas

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
2425
Version 1.00:
2526
* File creation.
2627
* TMenuItem, TMenu, TMainMenu and TPopupMenu implemented

‎sources/StdCtrls.pas

+88-77
Large diffs are not rendered by default.

‎sources/SysUtils.pas

+83-54
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
25+
* Some (irrelevant) Kylix code removed
26+
* StrToInt64/StrToInt64Def/TryStrToInt64 added
27+
* TryStrToDate/TryStrToTime added
2428
Version 1.00:
25-
* FPC/Lazarus part doesn't use any asm code
26-
* CheckWin32Version added
27-
* Warning: Kylix compatibility broken
29+
* FPC/Lazarus part doesn't use any asm code
30+
* CheckWin32Version added
31+
* Warning: Kylix compatibility broken
2832
}
2933

3034
// Original notes from LVCL
@@ -283,6 +287,9 @@ function IntToHex(Value: int64; Digits: integer): string; overload;
283287
function StrToInt(const S: string): integer;
284288
function StrToIntDef(const S: string; Default: integer): integer;
285289
function TryStrToInt(const S: string; out Value: integer): boolean;
290+
function StrToInt64(const S: string): int64;
291+
function StrToInt64Def(const S: string; Default: int64): int64;
292+
function TryStrToInt64(const S: string; out Value: int64): boolean;
286293
function GUIDToString(const GUID: TGUID): string;
287294

288295
{$if (not Defined(FPC)) or (not Defined(UNICODE))} // Delphi, or FPC/Lazarus non Unicode
@@ -365,6 +372,8 @@ function TrySystemTimeToDateTime(const SystemTime: TSystemTime; out DateTime: T
365372
function DateTimeToStr(const DateTime: TDateTime): string;
366373
function DateToStr(const DateTime: TDateTime): string;
367374
function TimeToStr(const DateTime: TDateTime): string;
375+
function TryStrToDate(const S: string; out Value: TDateTime): boolean;
376+
function TryStrToTime(const S: string; out Value: TDateTime): boolean;
368377
function TryStrToDateTime(const S: string; out Value: TDateTime): boolean;
369378

370379
function FileCreate(const FileName: {$IFDEF LLCL_FPC_UNISYS}unicodestring{$ELSE}string{$ENDIF}): THandle; {$IFDEF LLCL_FPC_UNISYS}overload;{$ENDIF}
@@ -491,6 +500,9 @@ implementation
491500

492501
const
493502
HexChars: array[0..15] of Char = '0123456789ABCDEF';
503+
SYSLLCL_TIME_SEP = ':';
504+
SYSLLCL_DATE_SEP = '/';
505+
SYSLLCL_DATETIME_SEP = ' ';
494506

495507
{$IFNDEF FPC}
496508
// our customs SysUtils.pas (normal and LVCL) contains the same array
@@ -529,7 +541,7 @@ procedure FindSearchRecUniToRaw(const F: TUnicodeSearchRec; var FF: TRawByteSear
529541
{$ifdef LLCL_OPT_EXCEPTIONS}
530542
{$IFDEF FPC}
531543
procedure ExceptHandler(ExceptObject: TObject; ExceptAddr: pointer; FrameCount: longint; Frames: PPointer); forward;
532-
procedure ErrorHandler(ErrorCode: integer; ErrorAddr, Frame : pointer); forward;
544+
procedure ErrorHandler(ErrorCode: integer; ErrorAddr, Frame: pointer); forward;
533545
procedure AssertErrorHandler(const aMessage, aFilename: shortstring; aLineNumber: longint; aErrorAddr: pointer); forward;
534546
{$ELSE FPC}
535547
procedure ExceptHandler(ExceptObject: TObject; ExceptAddr: pointer); far; forward;
@@ -625,7 +637,7 @@ function Format(const sFormat: string; const Args: array of const): string;
625637
end;
626638
end;
627639

628-
function IntToStr(Value : integer): string;
640+
function IntToStr(Value: integer): string;
629641
{$if Defined(UNICODE) or Defined(FPC)}
630642
begin
631643
Str(Value, result);
@@ -1014,6 +1026,24 @@ function TryStrToInt(const S: string; out Value: integer): boolean;
10141026
result := (E=0);
10151027
end;
10161028

1029+
function StrToInt64(const S: string): int64;
1030+
begin
1031+
result := StrToInt64Def(S, 0);
1032+
end;
1033+
1034+
function StrToInt64Def(const S: string; Default: int64): int64;
1035+
begin
1036+
if not TryStrToInt64(S, result) then
1037+
result := Default;
1038+
end;
1039+
1040+
function TryStrToInt64(const S: string; out Value: int64): boolean;
1041+
var E: integer;
1042+
begin
1043+
Val(S, Value, E);
1044+
result := (E=0);
1045+
end;
1046+
10171047
function GUIDToString(const GUID: TGUID): string;
10181048
procedure Write(P: PChar; B: PByteArray);
10191049
var i: integer;
@@ -2037,41 +2067,33 @@ function AnsiDequotedStr(const S: string; AQuote: Char): string;
20372067
function AnsiCompareText(const S1, S2: string): integer;
20382068
begin // (LVCL uses also SORT_STRINGSORT)
20392069
result := {$IFDEF LLCL_FPC_SYSRTL}LLCLSys_CompareString{$ELSE}LLCLS_CompareString{$ENDIF}
2040-
(LOCALE_USER_DEFAULT, NORM_IGNORECASE, S1, length(S1), S2, length(S2)) - 2;
2070+
(LOCALE_USER_DEFAULT, NORM_IGNORECASE, S1, S2) - 2;
20412071
end;
20422072

20432073
function AnsiSameText(const S1, S2: string): boolean;
20442074
begin
2045-
result := (AnsiCompareText(S1, S2)=0);
2075+
result := (AnsiCompareText(S1, S2)=0);
20462076
end;
20472077

20482078
function AnsiCompareStr(const S1, S2: string): integer;
20492079
begin // (LVCL uses also SORT_STRINGSORT)
20502080
result := {$IFDEF LLCL_FPC_SYSRTL}LLCLSys_CompareString{$ELSE}LLCLS_CompareString{$ENDIF}
2051-
(LOCALE_USER_DEFAULT, 0, S1, length(S1), S2, length(S2)) - 2;
2081+
(LOCALE_USER_DEFAULT, 0, S1, S2) - 2;
20522082
end;
20532083

20542084
function AnsiSameStr(const S1, S2: string): boolean;
20552085
begin
2056-
result := (AnsiCompareStr(S1, S2)=0);
2086+
result := (AnsiCompareStr(S1, S2)=0);
20572087
end;
20582088

20592089
function AnsiUpperCase(const S: string): string;
20602090
begin
2061-
{$ifdef MSWindows}
20622091
result := {$IFDEF LLCL_FPC_SYSRTL}LLCLSys_CharUpperBuff{$ELSE}LLCLS_CharUpperBuff{$ENDIF}(S);
2063-
{$else}
2064-
result := WideUpperCase(S);
2065-
{$endif}
20662092
end;
20672093

20682094
function AnsiLowerCase(const S: string): string;
20692095
begin
2070-
{$ifdef MSWindows}
20712096
result := {$IFDEF LLCL_FPC_SYSRTL}LLCLSys_CharLowerBuff{$ELSE}LLCLS_CharLowerBuff{$ENDIF}(S);
2072-
{$else}
2073-
result := WideLowerCase(S);
2074-
{$endif}
20752097
end;
20762098

20772099
function WideCompareText(const S1, S2: widestring): integer;
@@ -2081,7 +2103,7 @@ function WideCompareText(const S1, S2: widestring): integer;
20812103

20822104
function WideSameText(const S1, S2: widestring): boolean;
20832105
begin // (LVCL uses also SORT_STRINGSORT)
2084-
result := (WideCompareText(S1, S2)=0);
2106+
result := (WideCompareText(S1, S2)=0);
20852107
end;
20862108

20872109
function WideCompareStr(const S1, S2: widestring): integer;
@@ -2091,36 +2113,24 @@ function WideCompareStr(const S1, S2: widestring): integer;
20912113

20922114
function WideSameStr(const S1, S2: widestring): boolean;
20932115
begin
2094-
result := (WideCompareStr(S1, S2)=0);
2116+
result := (WideCompareStr(S1, S2)=0);
20952117
end;
20962118

20972119
function WideUpperCase(const S: widestring): widestring;
2098-
{$ifdef MSWindows}
20992120
var Len: cardinal;
21002121
begin
21012122
Len := length(S);
21022123
SetString(result, PWideChar(S), Len);
21032124
if Len > 0 then LLCL_CharUpperBuffW(pointer(result), Len);
21042125
end;
2105-
{$else}
2106-
begin
2107-
result := WideUpperCase(S);
2108-
end;
2109-
{$endif}
21102126

21112127
function WideLowerCase(const S: widestring): widestring;
2112-
{$ifdef MSWindows}
21132128
var Len: cardinal;
21142129
begin
21152130
Len := length(S);
21162131
SetString(result, PWideChar(S), Len);
21172132
if Len > 0 then LLCL_CharLowerBuffW(pointer(result), Len);
21182133
end;
2119-
{$else}
2120-
begin
2121-
result := WideLowerCase(S);
2122-
end;
2123-
{$endif}
21242134

21252135
procedure DecodeDate({$IFDEF FPC}{$ELSE}const {$ENDIF}DateTime: TDateTime; var Year, Month, Day: word);
21262136
var J: integer;
@@ -2366,7 +2376,7 @@ function SysAddDatePlusTime(const BaseDate: TDateTime; const PlusTime: TDateTim
23662376
if BaseDate>=0 then
23672377
result := BaseDate + PlusTime
23682378
else
2369-
result := BaseDate + PlusTime;
2379+
result := BaseDate - PlusTime;
23702380
end;
23712381

23722382
function SysCurrDT(WithDate, WithTime: boolean): TDateTime;
@@ -2417,15 +2427,15 @@ function SysDTToStr(const DateTime: TDateTime; WithDate, WithTime: boolean): st
24172427
result := '';
24182428
if WithDate then
24192429
begin
2420-
DecodeDate(DateTime, Y,M,D);
2421-
result := result+Format('%.4d',[Y])+'/'+Format('%.2d',[M])+'/'+Format('%.2d',[D]);
2430+
DecodeDate(DateTime, Y, M, D);
2431+
result := result + Format('%.4d', [Y]) + SYSLLCL_DATE_SEP + Format('%.2d', [M]) + SYSLLCL_DATE_SEP + Format('%.2d', [D]);
24222432
end;
24232433
if WithDate and WithTime then
2424-
result := result+' ';
2434+
result := result + SYSLLCL_DATETIME_SEP;
24252435
if WithTime then
24262436
begin
2427-
DecodeTime(DateTime, H,MI,S,MS);
2428-
result := result+Format('%.2d',[H])+':'+Format('%.2d',[MI])+':'+Format('%.2d',[S]);
2437+
DecodeTime(DateTime, H, MI, S, MS);
2438+
result := result + Format('%.2d', [H]) + SYSLLCL_TIME_SEP + Format('%.2d', [MI]) + SYSLLCL_TIME_SEP + Format('%.2d', [S]);
24292439
end;
24302440
end;
24312441

@@ -2481,26 +2491,45 @@ function TimeToStr(const DateTime: TDateTime): string;
24812491
end;
24822492

24832493
// Only for 'YYYY/MM/DD hh:mm:ss' (see Date/Time To Str functions)
2484-
function TryStrToDateTime(const S: string; out Value: TDateTime): boolean;
2485-
var Y,M,D, H,MI,SS: cardinal;
2494+
2495+
function TryStrToDate(const S: string; out Value: TDateTime): boolean;
2496+
var Y, M, D: cardinal;
24862497
begin
2487-
if length(S)<>19 then
2488-
begin
2489-
result := false;
2490-
exit;
2491-
end;
2498+
result := false;
2499+
if length(S)<>10 then exit;
24922500
Y := ord(S[1])*1000+ord(S[2])*100+ord(S[3])*10+ord(S[4])-(48+480+4800+48000);
24932501
M := ord(S[6])*10+ord(S[7])-(48+480);
24942502
D := ord(S[9])*10+ord(S[10])-(48+480);
2495-
H := ord(S[12])*10+ord(S[13])-(48+480);
2496-
MI := ord(S[15])*10+ord(S[16])-(48+480);
2497-
SS := ord(S[18])*10+ord(S[19])-(48+480);
2498-
result := (Y<=2100) and (Y>=1980) and (M in [1..12]) and (D<=MonthDays[true][M]) and
2499-
(D<>0) and (H<=23) and (MI<=59) and (SS<=59);
2503+
// (Reduced checks on year)
2504+
result := (Y<=3000) and (Y>=1) and (M in [1..12]) and (D<=MonthDays[true][M]) and (D<>0);
2505+
if result then
2506+
Value := EncodeDate(Y, M, D);
2507+
end;
2508+
2509+
function TryStrToTime(const S: string; out Value: TDateTime): boolean;
2510+
var HH, MM, SS: cardinal;
2511+
begin
2512+
result := false;
2513+
if length(S)<>8 then exit;
2514+
HH := ord(S[1])*10+ord(S[2])-(48+480);
2515+
MM := ord(S[4])*10+ord(S[5])-(48+480);
2516+
SS := ord(S[7])*10+ord(S[8])-(48+480);
2517+
result := (HH<=23) and (MM<=59) and (SS<=59);
2518+
if result then
2519+
Value := EncodeTime(HH, MM, SS, 0);
2520+
end;
2521+
2522+
function TryStrToDateTime(const S: string; out Value: TDateTime): boolean;
2523+
var TimeValue: TDateTime;
2524+
begin
2525+
result := false;
2526+
if length(S)<>19 then exit;
2527+
result := TryStrToDate(Copy(S, 1, 10), Value);
25002528
if result then
25012529
begin
2502-
Value := EncodeDate(Y, M, D);
2503-
Value := SysAddDatePlusTime(Value, EncodeTime(H, MI, SS, 0));
2530+
result := TryStrToTime(Copy(S, 12, 8), TimeValue);
2531+
if result then
2532+
SysAddDatePlusTime(Value, TimeValue);
25042533
end;
25052534
end;
25062535

@@ -3571,7 +3600,7 @@ procedure ExceptHandler(ExceptObject: TObject; ExceptAddr: pointer); far;
35713600
end;
35723601

35733602
{$IFDEF FPC}
3574-
procedure ErrorHandler(ErrorCode: integer; ErrorAddr, Frame : pointer);
3603+
procedure ErrorHandler(ErrorCode: integer; ErrorAddr, Frame: pointer);
35753604
{$ELSE FPC}
35763605
procedure ErrorHandler(ErrorCode: integer; ErrorAddr: pointer);
35773606
{$ENDIF FPC}

‎sources/Variants.pas

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
2425
Version 1.00:
2526
2627
Notes:

‎sources/XPMan.pas

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
License, v. 2.0. If a copy of the MPL was not distributed with this
1313
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1414
15-
This Source Code Form is Incompatible With Secondary Licenses,
15+
This Source Code Form is "Incompatible With Secondary Licenses",
1616
as defined by the Mozilla Public License, v. 2.0.
1717
18-
Copyright (c) 2015 ChrisF
18+
Copyright (c) 2015-2016 ChrisF
1919
2020
Based upon the Very LIGHT VCL (LVCL):
2121
Copyright (c) 2008 Arnaud Bouchez - http://bouchez.info
2222
Portions Copyright (c) 2001 Paul Toth - http://tothpaul.free.fr
2323
24+
Version 1.01:
2425
Version 1.00:
2526
* File creation.
2627
* TXPManifest implemented

0 commit comments

Comments
 (0)
Please sign in to comment.