From 96db2b4c9e32dd427b5df6dfa9f79d536643d493 Mon Sep 17 00:00:00 2001 From: graemeg Date: Tue, 18 Mar 2008 10:55:47 +0000 Subject: * Applied a patch from Vladimir which imploves the file system encoding and seems to fix the error received in the File dialog. * I implemented three new functions to retrieve the DPI value of the screen. --- src/corelib/gdi/gfx_gdi.pas | 32 +++++++++++++++++++++++--------- src/corelib/gdi/gfx_utils_impl.inc | 35 +++++------------------------------ 2 files changed, 28 insertions(+), 39 deletions(-) (limited to 'src/corelib/gdi') diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas index e785c1e2..66090c92 100644 --- a/src/corelib/gdi/gfx_gdi.pas +++ b/src/corelib/gdi/gfx_gdi.pas @@ -135,8 +135,6 @@ type end; - { TfpgWindowImpl } - TfpgWindowImpl = class(TfpgWindowBase) private FMouseInWindow: boolean; @@ -194,6 +192,9 @@ type procedure DoFlush; function GetScreenWidth: TfpgCoord; override; function GetScreenHeight: TfpgCoord; override; + function Screen_dpi_x: integer; override; + function Screen_dpi_y: integer; override; + function Screen_dpi: integer; override; property Display: HDC read FDisplay; end; @@ -207,12 +208,11 @@ type end; - { TfpgFileListImpl } - TfpgFileListImpl = class(TfpgFileListBase) procedure PopulateSpecialDirs(const aDirectory: TfpgString); override; end; + implementation uses @@ -1015,6 +1015,21 @@ begin Result := r.Bottom - r.Top; end; +function TfpgApplicationImpl.Screen_dpi_x: integer; +begin + Result := 96; +end; + +function TfpgApplicationImpl.Screen_dpi_y: integer; +begin + Result := 96; +end; + +function TfpgApplicationImpl.Screen_dpi: integer; +begin + Result := 96; +end; + { TfpgWindowImpl } var // these are required for Windows MouseEnter & MouseExit detection. @@ -2013,6 +2028,8 @@ end; { TfpgFileListImpl } procedure TfpgFileListImpl.PopulateSpecialDirs(const aDirectory: TfpgString); +const + MAX_DRIVES = 25; var n: integer; drvs: string; @@ -2023,15 +2040,12 @@ begin if Copy(aDirectory, 2, 1) = ':' then begin n := 0; - { TODO: replace 25 with a constant: max nested directories displayed } - while n <= 25 do + while n <= MAX_DRIVES do begin drvs := chr(n+ord('A'))+':\'; if Windows.GetDriveType(PChar(drvs)) <> 1 then begin - // vvzh: to avoid doubling of drive letters in inherited UpdateDirectory - if Pos(drvs, aDirectory) <> 1 then - FSpecialDirs.Add(drvs); + FSpecialDirs.Add(drvs); end; inc(n); end; diff --git a/src/corelib/gdi/gfx_utils_impl.inc b/src/corelib/gdi/gfx_utils_impl.inc index 2597d977..c8b264e1 100644 --- a/src/corelib/gdi/gfx_utils_impl.inc +++ b/src/corelib/gdi/gfx_utils_impl.inc @@ -1,39 +1,14 @@ {%mainunit gfx_utils.pas} -// GDI specific implementations of RTL wrapper functions +// GDI specific implementations of encoding functions -function fpgFindFirst(const Path: TfpgString; Attr: Longint; out - Rslt: TSearchRec): Longint; +function fpgToOSEncoding(aString: TfpgString): string; begin - Result := FindFirst(Utf8ToAnsi(Path), Attr, Rslt); - Rslt.Name := AnsiToUtf8(Rslt.Name); + Result := Utf8ToAnsi(aString); end; -function fpgFindNext(var Rslt: TSearchRec): Longint; +function fpgFromOSEncoding(aString: string): TfpgString; begin - Result := FindNext(Rslt); - Rslt.Name := AnsiToUtf8(Rslt.Name); + Result := AnsiToUtf8(aString); end; -function fpgGetCurrentDir: TfpgString; -begin - Result := AnsiToUtf8(GetCurrentDir); -end; - -function fpgSetCurrentDir(const NewDir: TfpgString): Boolean; -begin - Result := SetCurrentDir(Utf8ToAnsi(NewDir)); -end; - -function fpgExpandFileName(const FileName: TfpgString): TfpgString; -begin - Result := AnsiToUtf8(ExpandFileName(Utf8ToAnsi(FileName))); -end; - -function fpgFileExists(const FileName: TfpgString): Boolean; -begin - Result := FileExists(Utf8ToAnsi(FileName)); -end; - - - -- cgit v1.2.3-70-g09d2