| 1 | Unit HelpWindowDimensions;
 | 
|---|
| 2 | 
 | 
|---|
| 3 | // NewView - a new OS/2 Help Viewer
 | 
|---|
| 4 | // Copyright 2003 Aaron Lawrence (aaronl at consultant dot com)
 | 
|---|
| 5 | // This software is released under the Gnu Public License - see readme.txt
 | 
|---|
| 6 | 
 | 
|---|
| 7 | Interface
 | 
|---|
| 8 | 
 | 
|---|
| 9 | uses
 | 
|---|
| 10 |   IPFFileFormatUnit;
 | 
|---|
| 11 | 
 | 
|---|
| 12 | const
 | 
|---|
| 13 |   ptCharacters = 0;
 | 
|---|
| 14 |   ptPercentage = 1;
 | 
|---|
| 15 |   ptPixels = 2;
 | 
|---|
| 16 |   ptPoints = 3;
 | 
|---|
| 17 |   ptDynamic = 4;
 | 
|---|
| 18 | 
 | 
|---|
| 19 |   XPosRight = 577; // some random values as markers
 | 
|---|
| 20 |   YPosTop = 577;
 | 
|---|
| 21 |   XYPosCenter = 578;
 | 
|---|
| 22 | 
 | 
|---|
| 23 | type
 | 
|---|
| 24 |   THelpWindowRect = class
 | 
|---|
| 25 |     Left: longint; // xposright means, right aligned
 | 
|---|
| 26 |     Bottom: longint; // xpostop means top aligned
 | 
|---|
| 27 |        // both: xyposcenter means centered
 | 
|---|
| 28 |     Width: longint;
 | 
|---|
| 29 |     Height: longint;
 | 
|---|
| 30 |     constructor Create;
 | 
|---|
| 31 |     procedure Assign( Rect: THelpWindowRect );
 | 
|---|
| 32 |   end;
 | 
|---|
| 33 | 
 | 
|---|
| 34 | var
 | 
|---|
| 35 |   FootnoteRect: THelpWindowRect;
 | 
|---|
| 36 | 
 | 
|---|
| 37 | procedure ReadHelpSize( const XY: THelpXYPair;
 | 
|---|
| 38 |                         Var Rect: THelpWindowRect );
 | 
|---|
| 39 | procedure ReadHelpPosition( const XY: THelpXYPair;
 | 
|---|
| 40 |                             Var Rect: THelpWindowRect );
 | 
|---|
| 41 | 
 | 
|---|
| 42 | 
 | 
|---|
| 43 | Implementation
 | 
|---|
| 44 | 
 | 
|---|
| 45 | constructor THelpWindowRect.Create;
 | 
|---|
| 46 | begin
 | 
|---|
| 47 |   Left := -1;
 | 
|---|
| 48 |   Bottom := -1;
 | 
|---|
| 49 |   Width := -1;
 | 
|---|
| 50 |   Height := -1;
 | 
|---|
| 51 | end;
 | 
|---|
| 52 | 
 | 
|---|
| 53 | procedure THelpWindowRect.Assign( Rect: THelpWindowRect );
 | 
|---|
| 54 | begin
 | 
|---|
| 55 |   Left := Rect.Left;
 | 
|---|
| 56 |   Bottom := Rect.Bottom;
 | 
|---|
| 57 |   Width := Rect.Width;
 | 
|---|
| 58 |   Height := Rect.Height;
 | 
|---|
| 59 | end;
 | 
|---|
| 60 | 
 | 
|---|
| 61 | function GetPos( const PositionType: uint8;
 | 
|---|
| 62 |                  const Value: longint ): longint;
 | 
|---|
| 63 | begin
 | 
|---|
| 64 |   case PositionType of
 | 
|---|
| 65 |     ptCharacters:
 | 
|---|
| 66 |       Result := Value;
 | 
|---|
| 67 |     ptPercentage:
 | 
|---|
| 68 |       Result := Value;
 | 
|---|
| 69 |     ptPixels:
 | 
|---|
| 70 |       Result := Value * 5;
 | 
|---|
| 71 |     ptPoints:
 | 
|---|
| 72 |       Result := Value;
 | 
|---|
| 73 |     ptDynamic:
 | 
|---|
| 74 |       case Value of
 | 
|---|
| 75 |         1:
 | 
|---|
| 76 |           Result := 0; // left
 | 
|---|
| 77 |         2:
 | 
|---|
| 78 |           Result := XPosRight; // right
 | 
|---|
| 79 |         4:
 | 
|---|
| 80 |           Result := YPosTop; // top
 | 
|---|
| 81 |         8:
 | 
|---|
| 82 |           Result := 0; // bottom
 | 
|---|
| 83 |         16:
 | 
|---|
| 84 |           Result := XYPosCenter; // center.
 | 
|---|
| 85 |       end;
 | 
|---|
| 86 |   end;
 | 
|---|
| 87 | end;
 | 
|---|
| 88 | 
 | 
|---|
| 89 | procedure ReadHelpPosition( const XY: THelpXYPair;
 | 
|---|
| 90 |                             Var Rect: THelpWindowRect );
 | 
|---|
| 91 | var
 | 
|---|
| 92 |   XPositionType: uint8;
 | 
|---|
| 93 |   YPositionType: uint8;
 | 
|---|
| 94 | begin
 | 
|---|
| 95 |   // read origin
 | 
|---|
| 96 |   XPositionType := XY.Flags div 16;
 | 
|---|
| 97 |   YPositionType := XY.Flags and 15;
 | 
|---|
| 98 | 
 | 
|---|
| 99 |   if XY.X <> $ffff then
 | 
|---|
| 100 |     Rect.Left := GetPos( XPositionType, XY.X );
 | 
|---|
| 101 |   if XY.Y <> $ffff then
 | 
|---|
| 102 |     Rect.Bottom := GetPos( YPositionType, XY.Y );
 | 
|---|
| 103 | end;
 | 
|---|
| 104 | 
 | 
|---|
| 105 | procedure ReadHelpSize( const XY: THelpXYPair;
 | 
|---|
| 106 |                         Var Rect: THelpWindowRect );
 | 
|---|
| 107 | begin
 | 
|---|
| 108 |   if XY.X <> $ffff then
 | 
|---|
| 109 |     Rect.Width := XY.X;
 | 
|---|
| 110 |   if XY.Y <> $ffff then
 | 
|---|
| 111 |     Rect.Height := XY.Y;
 | 
|---|
| 112 | end;
 | 
|---|
| 113 | 
 | 
|---|
| 114 | Initialization
 | 
|---|
| 115 |   FootnoteRect := THelpWindowRect.Create;
 | 
|---|
| 116 |   with FootnoteRect do
 | 
|---|
| 117 |   begin
 | 
|---|
| 118 |     Left := 10;
 | 
|---|
| 119 |     Width := 80;
 | 
|---|
| 120 |     Bottom := 10;
 | 
|---|
| 121 |     Height := 40;
 | 
|---|
| 122 |   end;
 | 
|---|
| 123 | 
 | 
|---|
| 124 | End.
 | 
|---|