diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2009-10-13 17:07:22 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2009-10-13 17:07:22 +0200 |
commit | 3ff1e9e96de371807e594fcd7d37fe18fd7426fc (patch) | |
tree | b41407d409771abe3d52e4af11677e007e12e0df /src | |
parent | 4180ebf2b62cd2bdb2fe1062a75357582c7ec3e9 (diff) | |
download | fpGUI-3ff1e9e96de371807e594fcd7d37fe18fd7426fc.tar.xz |
Ported and added new unit from latest NewView.
Diffstat (limited to 'src')
-rw-r--r-- | src/HelpWindowDimensions.pas | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/src/HelpWindowDimensions.pas b/src/HelpWindowDimensions.pas new file mode 100644 index 00000000..948cf003 --- /dev/null +++ b/src/HelpWindowDimensions.pas @@ -0,0 +1,129 @@ +Unit HelpWindowDimensions; + +{$mode objfpc}{$H+} + +// NewView - a new OS/2 Help Viewer +// Copyright 2003 Aaron Lawrence (aaronl at consultant dot com) +// This software is released under the Gnu Public License - see readme.txt + +Interface + +uses + IPFFileFormatUnit; + +const + ptCharacters = 0; + ptPercentage = 1; + ptPixels = 2; + ptPoints = 3; + ptDynamic = 4; + + XPosRight = 577; // some random values as markers + YPosTop = 577; + XYPosCenter = 578; + +type + THelpWindowRect = class + Left: longint; // xposright means, right aligned + Bottom: longint; // xpostop means top aligned + // both: xyposcenter means centered + Width: longint; + Height: longint; + constructor Create; + procedure Assign( Rect: THelpWindowRect ); + end; + +var + FootnoteRect: THelpWindowRect; + +procedure ReadHelpSize( const XY: THelpXYPair; + Var Rect: THelpWindowRect ); +procedure ReadHelpPosition( const XY: THelpXYPair; + Var Rect: THelpWindowRect ); + + +Implementation + +constructor THelpWindowRect.Create; +begin + Left := -1; + Bottom := -1; + Width := -1; + Height := -1; +end; + +procedure THelpWindowRect.Assign( Rect: THelpWindowRect ); +begin + Left := Rect.Left; + Bottom := Rect.Bottom; + Width := Rect.Width; + Height := Rect.Height; +end; + +function GetPos( const PositionType: uint8; + const Value: longint ): longint; +begin + case PositionType of + ptCharacters: + Result := Value; + ptPercentage: + Result := Value; + ptPixels: + Result := Value * 5; + ptPoints: + Result := Value; + ptDynamic: + case Value of + 1: + Result := 0; // left + 2: + Result := XPosRight; // right + 4: + Result := YPosTop; // top + 8: + Result := 0; // bottom + 16: + Result := XYPosCenter; // center. + end; + end; +end; + +procedure ReadHelpPosition( const XY: THelpXYPair; + Var Rect: THelpWindowRect ); +var + XPositionType: uint8; + YPositionType: uint8; +begin + // read origin + XPositionType := XY.Flags div 16; + YPositionType := XY.Flags and 15; + + if XY.X <> $ffff then + Rect.Left := GetPos( XPositionType, XY.X ); + if XY.Y <> $ffff then + Rect.Bottom := GetPos( YPositionType, XY.Y ); +end; + +procedure ReadHelpSize( const XY: THelpXYPair; + Var Rect: THelpWindowRect ); +begin + if XY.X <> $ffff then + Rect.Width := XY.X; + if XY.Y <> $ffff then + Rect.Height := XY.Y; +end; + +initialization + FootnoteRect := THelpWindowRect.Create; + with FootnoteRect do + begin + Left := 10; + Width := 80; + Bottom := 10; + Height := 40; + end; + +finalization + FootnoteRect.Free; + +End. |