You've already forked lazarus-ccr
jvcllaz: Make available some "trivial" functions of unit JvJVCLUtils.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8073 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -37,8 +37,8 @@ uses
|
|||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
Windows, // before Types!
|
Windows, // before Types!
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, Graphics, Controls, ImgList,
|
Classes, Graphics, Controls, ImgList, Menus, Forms, Types,
|
||||||
LCLType, LCLProc, LCLVersion, LMessages, Types,
|
LCLType, LCLProc, LCLVersion, LMessages,
|
||||||
JvTypes;
|
JvTypes;
|
||||||
|
|
||||||
(******************** NOT CONVERTED
|
(******************** NOT CONVERTED
|
||||||
@@ -360,8 +360,10 @@ function ToRightOf(const pc: TControl; piSpace: Integer = 0): Integer;
|
|||||||
{ sets the top of pc to be in the middle of pcParent }
|
{ sets the top of pc to be in the middle of pcParent }
|
||||||
procedure CenterHeight(const pc, pcParent: TControl);
|
procedure CenterHeight(const pc, pcParent: TControl);
|
||||||
procedure CenterHor(Parent: TControl; MinLeft: Integer; Controls: array of TControl);
|
procedure CenterHor(Parent: TControl; MinLeft: Integer; Controls: array of TControl);
|
||||||
|
*)
|
||||||
procedure EnableControls(Control: TWinControl; const Enable: Boolean);
|
procedure EnableControls(Control: TWinControl; const Enable: Boolean);
|
||||||
procedure EnableMenuItems(MenuItem: TMenuItem; const Tag: Integer; const Enable: Boolean);
|
procedure EnableMenuItems(MenuItem: TMenuItem; const Tag: Integer; const Enable: Boolean);
|
||||||
|
(*
|
||||||
procedure ExpandWidth(Parent: TControl; MinWidth: Integer; Controls: array of TControl);
|
procedure ExpandWidth(Parent: TControl; MinWidth: Integer; Controls: array of TControl);
|
||||||
function PanelBorder(Panel: TCustomPanel): Integer;
|
function PanelBorder(Panel: TCustomPanel): Integer;
|
||||||
function Pixels(Control: TControl; APixels: Integer): Integer;
|
function Pixels(Control: TControl; APixels: Integer): Integer;
|
||||||
@@ -420,10 +422,10 @@ procedure SaveGridLayout(Grid: TCustomGrid; const AppStorage: TJvCustomAppStorag
|
|||||||
|
|
||||||
function StrToIniStr(const Str: string): string;
|
function StrToIniStr(const Str: string): string;
|
||||||
function IniStrToStr(const Str: string): string;
|
function IniStrToStr(const Str: string): string;
|
||||||
|
*)
|
||||||
|
|
||||||
// Ini Utilitie Functions
|
// Ini Utility Functions
|
||||||
// Added by RDB
|
// Added by RDB
|
||||||
|
|
||||||
function FontStylesToString(Styles: TFontStyles): string;
|
function FontStylesToString(Styles: TFontStyles): string;
|
||||||
function StringToFontStyles(const Styles: string): TFontStyles;
|
function StringToFontStyles(const Styles: string): TFontStyles;
|
||||||
|
|
||||||
@@ -434,7 +436,7 @@ function RectToStr(Rect: TRect): string;
|
|||||||
function StrToRect(const Str: string; const Def: TRect): TRect;
|
function StrToRect(const Str: string; const Def: TRect): TRect;
|
||||||
function PointToStr(P: TPoint): string;
|
function PointToStr(P: TPoint): string;
|
||||||
function StrToPoint(const Str: string; const Def: TPoint): TPoint;
|
function StrToPoint(const Str: string; const Def: TPoint): TPoint;
|
||||||
|
(************* NOT CONVERTED
|
||||||
{
|
{
|
||||||
function IniReadString(IniFile: TObject; const Section, Ident,
|
function IniReadString(IniFile: TObject; const Section, Ident,
|
||||||
Default: string): string;
|
Default: string): string;
|
||||||
@@ -472,9 +474,9 @@ procedure InternalRestoreMDIChildren(MainForm: TForm; const AppStorage: TJvCusto
|
|||||||
type
|
type
|
||||||
TMappingMethod = (mmHistogram, mmQuantize, mmTrunc784, mmTrunc666,
|
TMappingMethod = (mmHistogram, mmQuantize, mmTrunc784, mmTrunc666,
|
||||||
mmTripel, mmGrayscale);
|
mmTripel, mmGrayscale);
|
||||||
|
*)
|
||||||
function GetBitmapPixelFormat(Bitmap: TBitmap): TPixelFormat;
|
function GetBitmapPixelFormat(Bitmap: TBitmap): TPixelFormat;
|
||||||
|
(************** NOT CONVERED ***
|
||||||
function GetPaletteBitmapFormat(Bitmap: TBitmap): TPixelFormat;
|
function GetPaletteBitmapFormat(Bitmap: TBitmap): TPixelFormat;
|
||||||
{$IFNDEF CLR}
|
{$IFNDEF CLR}
|
||||||
procedure SetBitmapPixelFormat(Bitmap: TBitmap; PixelFormat: TPixelFormat;
|
procedure SetBitmapPixelFormat(Bitmap: TBitmap; PixelFormat: TPixelFormat;
|
||||||
@@ -719,18 +721,18 @@ function GetAppHandle: THandle;
|
|||||||
// Direction defines the direction of the arrow. If Direction is akLeft, the arrow point is
|
// Direction defines the direction of the arrow. If Direction is akLeft, the arrow point is
|
||||||
// pointing to the left
|
// pointing to the left
|
||||||
procedure DrawArrow(Canvas: TCanvas; Rect: TRect; Color: TColor = clBlack; Direction: TAnchorKind = akBottom);
|
procedure DrawArrow(Canvas: TCanvas; Rect: TRect; Color: TColor = clBlack; Direction: TAnchorKind = akBottom);
|
||||||
|
***********)
|
||||||
function IsPositiveResult(Value: TModalResult): Boolean;
|
function IsPositiveResult(Value: TModalResult): Boolean;
|
||||||
function IsNegativeResult(Value: TModalResult): Boolean;
|
function IsNegativeResult(Value: TModalResult): Boolean;
|
||||||
function IsAbortResult(const Value: TModalResult): Boolean;
|
function IsAbortResult(const Value: TModalResult): Boolean;
|
||||||
function StripAllFromResult(const Value: TModalResult): TModalResult;
|
function StripAllFromResult(const Value: TModalResult): TModalResult;
|
||||||
// returns either BrightColor or DarkColor depending on the luminance of AColor
|
|
||||||
// This function gives the same result (AFAIK) as the function used in Windows to
|
{ Returns either BrightColor or DarkColor depending on the luminance of AColor
|
||||||
// calculate the desktop icon text color based on the desktop background color
|
This function gives the same result (AFAIK) as the function used in Windows to
|
||||||
|
calculate the desktop icon text color based on the desktop background color }
|
||||||
function SelectColorByLuminance(AColor, DarkColor, BrightColor: TColor): TColor;
|
function SelectColorByLuminance(AColor, DarkColor, BrightColor: TColor): TColor;
|
||||||
|
|
||||||
// (peter3) implementation moved from JvHTControls.
|
// (peter3) implementation moved from JvHTControls.
|
||||||
************)
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TJvHTMLCalcType = (htmlShow, htmlCalcWidth, htmlCalcHeight, htmlHyperLink);
|
TJvHTMLCalcType = (htmlShow, htmlCalcWidth, htmlCalcHeight, htmlHyperLink);
|
||||||
@@ -864,7 +866,7 @@ function Scale96ToForm(ASize: Integer): Integer;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
sysutils, LCLIntf, GraphType, Math, Forms,
|
sysutils, LCLIntf, GraphType, GraphUtil, Math,
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
CommCtrl,
|
CommCtrl,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@@ -889,12 +891,17 @@ const
|
|||||||
RC_TileWallpaper = 'TileWallpaper';
|
RC_TileWallpaper = 'TileWallpaper';
|
||||||
RC_RunCpl = 'rundll32.exe shell32,Control_RunDLL ';
|
RC_RunCpl = 'rundll32.exe shell32,Control_RunDLL ';
|
||||||
{$ENDIF MSWINDOWS}
|
{$ENDIF MSWINDOWS}
|
||||||
|
**********************)
|
||||||
|
|
||||||
|
const
|
||||||
|
SInvalidBitmap = 'Invalid bitmap';
|
||||||
|
|
||||||
function GetAppHandle: THandle;
|
function GetAppHandle: THandle;
|
||||||
begin
|
begin
|
||||||
Result := Application.Handle;
|
Result := Application.Handle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
(***************** NOT CONVERTED ***
|
||||||
type
|
type
|
||||||
TWaitCursor = class(TInterfacedObject, IInterface)
|
TWaitCursor = class(TInterfacedObject, IInterface)
|
||||||
private
|
private
|
||||||
@@ -2253,9 +2260,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function PointInPolyRgn(const P: TPoint; const Points: array of TPoint):
|
function PointInPolyRgn(const P: TPoint; const Points: array of TPoint):
|
||||||
Boolean;
|
Boolean;
|
||||||
{$IFNDEF CLR}
|
{$IFNDEF CLR}
|
||||||
@@ -3534,6 +3538,7 @@ begin
|
|||||||
for I := Low(Controls) to High(Controls) do
|
for I := Low(Controls) to High(Controls) do
|
||||||
Controls[I].Left := Max(MinLeft, (Parent.Width - Controls[I].Width) div 2);
|
Controls[I].Left := Max(MinLeft, (Parent.Width - Controls[I].Width) div 2);
|
||||||
end;
|
end;
|
||||||
|
***************)
|
||||||
|
|
||||||
procedure EnableControls(Control: TWinControl; const Enable: Boolean);
|
procedure EnableControls(Control: TWinControl; const Enable: Boolean);
|
||||||
var
|
var
|
||||||
@@ -3552,6 +3557,7 @@ begin
|
|||||||
MenuItem[I].Enabled := Enable;
|
MenuItem[I].Enabled := Enable;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
(************** NOT CONVERTED
|
||||||
procedure ExpandWidth(Parent: TControl; MinWidth: Integer; Controls: array of TControl);
|
procedure ExpandWidth(Parent: TControl; MinWidth: Integer; Controls: array of TControl);
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
@@ -4456,6 +4462,9 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
{ end JvAppUtils }
|
{ end JvAppUtils }
|
||||||
|
|
||||||
|
******************)
|
||||||
|
|
||||||
{ begin JvGraph }
|
{ begin JvGraph }
|
||||||
// (rom) moved here to make JvMaxMin obsolete
|
// (rom) moved here to make JvMaxMin obsolete
|
||||||
|
|
||||||
@@ -4471,11 +4480,7 @@ end;
|
|||||||
|
|
||||||
procedure InvalidBitmap;
|
procedure InvalidBitmap;
|
||||||
begin
|
begin
|
||||||
{$IFDEF CLR}
|
|
||||||
raise EInvalidGraphic.Create(SInvalidBitmap);
|
raise EInvalidGraphic.Create(SInvalidBitmap);
|
||||||
{$ELSE}
|
|
||||||
raise EInvalidGraphic.CreateRes(@SInvalidBitmap);
|
|
||||||
{$ENDIF CLR}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function WidthBytes(I: Longint): Longint;
|
function WidthBytes(I: Longint): Longint;
|
||||||
@@ -4498,7 +4503,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
(************************* NOT CONVERTED
|
||||||
function ScreenPixelFormat: TPixelFormat;
|
function ScreenPixelFormat: TPixelFormat;
|
||||||
var
|
var
|
||||||
DC: HDC;
|
DC: HDC;
|
||||||
@@ -5612,13 +5617,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
*****)
|
||||||
|
|
||||||
function GetBitmapPixelFormat(Bitmap: TBitmap): TPixelFormat;
|
function GetBitmapPixelFormat(Bitmap: TBitmap): TPixelFormat;
|
||||||
begin
|
begin
|
||||||
Result := Bitmap.PixelFormat;
|
Result := Bitmap.PixelFormat;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
(*************** NOT CONVERTED ***
|
||||||
function BytesPerScanLine(PixelsPerScanline, BitsPerPixel,
|
function BytesPerScanLine(PixelsPerScanline, BitsPerPixel,
|
||||||
Alignment: Longint): Longint;
|
Alignment: Longint): Longint;
|
||||||
begin
|
begin
|
||||||
@@ -6624,6 +6630,7 @@ begin
|
|||||||
except
|
except
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
*************)
|
||||||
|
|
||||||
const
|
const
|
||||||
Lefts = ['[', '{', '('];
|
Lefts = ['[', '{', '('];
|
||||||
@@ -6657,8 +6664,6 @@ begin
|
|||||||
Include(Result, fsStrikeOut);
|
Include(Result, fsStrikeOut);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function FontToString(Font: TFont): string;
|
function FontToString(Font: TFont): string;
|
||||||
begin
|
begin
|
||||||
with Font do
|
with Font do
|
||||||
@@ -6667,15 +6672,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function StringToFont(const Str: string): TFont;
|
function StringToFont(const Str: string): TFont;
|
||||||
|
{
|
||||||
const
|
const
|
||||||
Delims = [',', ';'];
|
Delims = [',', ';'];
|
||||||
|
}
|
||||||
var
|
var
|
||||||
|
{
|
||||||
Pos: Integer;
|
Pos: Integer;
|
||||||
I: Byte;
|
I: Byte;
|
||||||
S: string;
|
S: string;
|
||||||
|
}
|
||||||
|
sa: TStringArray;
|
||||||
begin
|
begin
|
||||||
Result := TFont.Create;
|
Result := TFont.Create;
|
||||||
try
|
try
|
||||||
|
sa := Str.Split([',', ';']);
|
||||||
|
Result.Name := sa[0];
|
||||||
|
Result.Size := StrToIntDef(sa[1], Result.Size);
|
||||||
|
Result.Style := StringToFontStyles(sa[2]);
|
||||||
|
Result.Pitch := TFontPitch(StrToIntDef(sa[3], ord(Result.Pitch)));
|
||||||
|
Result.Color := StringToColor(sa[4]);
|
||||||
|
Result.CharSet := TFontCharSet(StrToIntDef(sa[5], Result.CharSet));
|
||||||
|
{ --- original JVCL code, replaced by above FPC code ---
|
||||||
Pos := 1;
|
Pos := 1;
|
||||||
I := 0;
|
I := 0;
|
||||||
while Pos <= Length(Str) do
|
while Pos <= Length(Str) do
|
||||||
@@ -6697,6 +6715,7 @@ begin
|
|||||||
Result.Charset := TFontCharset(StrToIntDef(S, Result.Charset));
|
Result.Charset := TFontCharset(StrToIntDef(S, Result.Charset));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -6777,6 +6796,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
(************** NOT CONVERTED
|
||||||
procedure DrawArrow(Canvas: TCanvas; Rect: TRect; Color: TColor = clBlack; Direction: TAnchorKind = akBottom);
|
procedure DrawArrow(Canvas: TCanvas; Rect: TRect; Color: TColor = clBlack; Direction: TAnchorKind = akBottom);
|
||||||
var
|
var
|
||||||
I, Size: Integer;
|
I, Size: Integer;
|
||||||
@@ -6820,7 +6840,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
*********)
|
||||||
function IsPositiveResult(Value: TModalResult): Boolean;
|
function IsPositiveResult(Value: TModalResult): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := Value in [mrOk, mrYes, mrAll, mrYesToAll];
|
Result := Value in [mrOk, mrYes, mrAll, mrYesToAll];
|
||||||
@@ -6848,7 +6868,7 @@ begin
|
|||||||
else
|
else
|
||||||
Result := Value;
|
Result := Value;
|
||||||
end;
|
end;
|
||||||
end; *)
|
end;
|
||||||
|
|
||||||
//=== { TJvPoint } ===========================================================
|
//=== { TJvPoint } ===========================================================
|
||||||
|
|
||||||
@@ -7069,7 +7089,7 @@ begin
|
|||||||
DoChange;
|
DoChange;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
(*
|
|
||||||
function SelectColorByLuminance(AColor, DarkColor, BrightColor: TColor): TColor;
|
function SelectColorByLuminance(AColor, DarkColor, BrightColor: TColor): TColor;
|
||||||
var
|
var
|
||||||
ACol: Longint;
|
ACol: Longint;
|
||||||
@@ -7080,7 +7100,6 @@ begin
|
|||||||
else
|
else
|
||||||
Result := BrightColor;
|
Result := BrightColor;
|
||||||
end;
|
end;
|
||||||
***********)
|
|
||||||
|
|
||||||
const
|
const
|
||||||
cBR = '<BR>';
|
cBR = '<BR>';
|
||||||
|
Reference in New Issue
Block a user