home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / tvision / gravis / gv / gvviews.int < prev   
Encoding:
Text File  |  1994-05-23  |  14.5 KB  |  508 lines

  1. Unit GVViews;
  2.  
  3.  
  4. interface
  5.  
  6. uses Objects, Drivers, Views, Memory;
  7.  
  8. Const
  9.  
  10. { Color Palettes }
  11.  
  12.   CBackground  = #1;
  13.   CFrame       = #2#3#4#5#6#7#8#9#10#11#12#13;
  14.   CScrollBar   = #14#15#16#17#18;
  15.   CScroller    = #19#20#21#22;
  16.   CListViewer  = #134#135#136#137#138#139;
  17.  
  18.   CWhiteWindow = #10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28+
  19.                  #29#30#31;
  20.   CGrayWindow  = #32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48#49#50+
  21.                  #51#52#53;
  22.   CCyanWindow  = #54#55#56#57#58#59#60#61#62#63#64#65#66#67#68#69#70#71#72+
  23.                  #73#74#75;
  24.  
  25. { TView State masks (Auszug aus VIEWS.INT) }
  26.  
  27.   sfVisible     = $0001;    sfCursorVis   = $0002;    sfCursorIns   = $0004;
  28.   sfShadow      = $0008;    sfActive      = $0010;    sfSelected    = $0020;
  29.   sfFocused     = $0040;    sfDragging    = $0080;    sfDisabled    = $0100;
  30.   sfModal       = $0200;    sfDefault     = $0400;    sfExposed     = $0800;
  31.  
  32.   sfBuffer      = $1000;
  33.  
  34. { TView Option masks }
  35.  
  36.   ofSelectable  = $0001;    ofTopSelect   = $0002;    ofFirstClick  = $0004;
  37.   ofFramed      = $0008;    ofPreProcess  = $0010;    ofPostProcess = $0020;
  38.   ofBuffer      = $0040;    ofTileable    = $0080;    ofCenterX     = $0100;
  39.   ofCenterY     = $0200;    ofCentered    = $0300;
  40.   ofClip        = $0400;    ofMetaFile    = $0800;    ofValidate    = $1000;
  41.  
  42. { Standard command codes }
  43.  
  44.   cmValid   = 0;            cmQuit    = 1;            cmError   = 2;
  45.   cmMenu    = 3;            cmClose   = 4;            cmZoom    = 5;
  46.   cmResize  = 6;            cmNext    = 7;            cmPrev    = 8;
  47.   cmHelp    = 9;
  48.  
  49. { TDialog standard commands }
  50.  
  51.   cmOK      = 10;           cmCancel  = 11;           cmYes     = 12;
  52.   cmNo      = 13;           cmDefault = 14;
  53.  
  54. { TButton message commands }
  55.  
  56.  cmGrabDefault = 15;        cmReleaseDefault = 16;
  57.  
  58. { TWindow message commands }
  59.  
  60.  cmRestoreBackground = 17;
  61.  
  62. { Standard messages }
  63.  
  64.   cmReceivedFocus     = 50;
  65.   cmReleasedFocus     = 51;
  66.   cmCommandSetChanged = 52;
  67.  
  68. { Standard mouse cursors }
  69.  
  70.   mcInput      = 50;
  71.   mcMove       = 51;
  72.   mcResizeDnRi = 52;
  73.   mcResizeDnLe = 53;
  74.   mcResizeVert = 54;
  75.   mcResizeHori = 55;
  76.  
  77. { TButton flags }
  78.  
  79.   bfNormal    = $00;
  80.   bfDefault   = $01;
  81.   bfLeftJust  = $02;
  82.   bfBroadcast = $04;
  83.   bfGrabFocus = $08;
  84.  
  85. { StandardScrollbar flags }
  86.  
  87.   sbHorizontal     = $0001;
  88.   sbVertical       = $0002;
  89.   sbHandleKeyBoard = $0004;
  90.   sbDoScrolling    = $0008;
  91.  
  92. { ScrollBar flags }
  93.  
  94.   sbLeftArrow  = 0;  sbRightArrow = 1;  sbPageLeft   = 2;  sbPageRight  = 3;
  95.   sbUpArrow    = 4;  sbDownArrow  = 5;  sbPageUp     = 6;  sbPageDown   = 7;
  96.   sbIndicator  = 8;
  97.  
  98. { TWindow palette entries }
  99.  
  100.   wpWhiteWindow = 0;
  101.   wpGrayWindow  = 1;
  102.   wpCyanWindow  = 2;
  103.  
  104. { ResMode values }
  105.  
  106.   rmDnRi  = 1;  rmUpRi  = 2;  rmDnLe  = 3;  rmUpLe  = 4;  rmLeft  = 5;
  107.   rmRight = 6;  rmUp    = 7;  rmDown  = 8;
  108.  
  109. { Minimal window size }
  110.  
  111.   GMinWinSize : TPoint = (X: 170; Y: 100);
  112.  
  113. { Window field size }
  114.  
  115.   IconSize = 20;
  116.  
  117. { Window dragging add constant }
  118.  
  119.   WinDragAdd = 5;
  120.  
  121. { Window commands to enable/disable }
  122.  
  123.   WindowCmds: TCommandSet = [cmNext, cmPrev, cmTile, cmCascade];
  124.  
  125. var
  126.  
  127. { Window message rectangle }
  128.  
  129.   msgClip: TRect;
  130.  
  131. Type
  132.  
  133.   PVRect = ^TVRect;
  134.   TVRect = record
  135.              Count: Byte;
  136.              Next: PVRect;
  137.              R: Array [0..0] Of TRect;
  138.            end;
  139.  
  140.   PGGroup = ^TGGroup;
  141.   PGView = ^TGView;
  142.  
  143.   TGView = Object (TView)
  144.     GOwner:PGGroup;
  145.     GNext:PGView;
  146.     CursorSize: TPoint;
  147.     CursorFlag, Restore: Boolean;
  148.     constructor Init (var Bounds: TRect);
  149.     destructor Done; virtual;
  150.     constructor Load (var S: TStream);
  151.     procedure ChangeBounds (var R: TRect); virtual;
  152.     procedure ChMCursor; virtual;
  153.     procedure DeleteRectList (var RectList: PVRect);
  154.     procedure Draw; virtual;
  155.     procedure DrawCursor;
  156.     procedure DrawRectList (var RectList: PVRect);
  157.     procedure DrawView;
  158.     procedure EndModal (Command: Word); virtual;
  159.     function Exposed: Boolean;
  160.     function Focus: Boolean;
  161.     function GetColor (Color:Word):Word;
  162.     procedure GetPeerViewPtr (var S:TStream; var P);
  163.               { procedure GetBGIPoint (GVPoint: TPoint; var BGIPoint: TPoint); }
  164.     procedure GetVisibleRect (var RectList: PVRect);
  165.     procedure GetInVisibleRect (var RectList: PVRect);
  166.     function GetStandardFont: Word;
  167.     procedure KeyEvent (var Event: TEvent);
  168.     procedure Locate (var Bounds: TRect); virtual;
  169.     function MouseEvent (var Event: TEvent; Mask: Word): Boolean;
  170.     function NextView: PGView;
  171.     function Prev: PGView;
  172.     function PrevView: PGView;
  173.     procedure PutInFrontOf (Target: PGView); virtual;
  174.     procedure PutPeerViewPtr (var S:TStream; P: PGView);
  175.     procedure SetViewPort; virtual;
  176.     procedure RestoreViewPort; virtual;
  177.     procedure HandleEvent (var Event:TEvent); virtual;
  178.     procedure Select;
  179.     procedure SetCursor (X, Y: Integer);
  180.     procedure SetState (AState: Word; Enable: Boolean); virtual;
  181.     procedure Store (var S: TStream);
  182.   private
  183.     OldOrigin: TPoint;
  184.     OldClipRect: TRect;
  185.     OldCriticalArea: TRect;
  186.     SetManual: Boolean;
  187.   End;
  188.  
  189. { TFrame object }
  190.  
  191.   { Palette layout }
  192.   { 1  = Selected frame }
  193.   { 2  = Normal frame }
  194.   { 3  = Modal frame }
  195.   { 4  = Zoomfield }
  196.   { 5  = Normal background }
  197.   { 6  = Selected background }
  198.   { 7  = Normal title }
  199.   { 8  = Selected title }
  200.   { 9  = Close-/Zoomfield outside }
  201.   { 10 = Closefield frame }
  202.   { 11 = Closefield inside }
  203.   { 12 = Closefield shadow }
  204.  
  205.   PFrame = ^TFrame;
  206.   TFrame = Object (TGView)
  207.     TitleSize:Integer;
  208.     Zoomed: Boolean;
  209.     constructor Init (var Bounds:TRect; AFlags: Byte);
  210.     constructor Load (var S: TStream);
  211.     procedure Store (var S: TStream);
  212.     procedure ChMCursor; virtual;
  213.     function GetPalette:PPalette; virtual;
  214.     procedure Draw; virtual;
  215.     procedure DrawZoomField (Down: Boolean); virtual;
  216.     procedure HandleEvent (var Event: TEvent); virtual;
  217.     procedure SetState (AState: Word; Enable: Boolean); virtual;
  218.     function Valid (Command: Word): Boolean; virtual;
  219.   private
  220.     OldC: Integer;
  221.   End;
  222.  
  223. { TBackGround object }
  224.  
  225.   PBackGround = ^TBackGround;
  226.   TBackGround = Object (TGView)
  227.     constructor Init (var Bounds:TRect);
  228.     constructor Load (var S: TStream);
  229.     procedure Store (var S: TStream);
  230.     procedure draw; virtual;
  231.   End;
  232.  
  233. { TScrollBar object }
  234.  
  235.   { Palette layout }
  236.   { 1 = Background }
  237.   { 2 = Frame }
  238.   { 3 = Buttons }
  239.   { 4 = Button shadows }
  240.   { 5 = Page area }
  241.  
  242.   PScrollBar = ^TScrollBar;
  243.   TScrollBar = object(TGView)
  244.     ButtonSize: Byte;
  245.     Flags: Byte;
  246.     Value: Integer;
  247.     Min: Integer;
  248.     Max: Integer;
  249.     PgStep: Integer;
  250.     ArStep: Integer;
  251.     constructor Init(var Bounds: TRect);
  252.     constructor Load(var S: TStream);
  253.      { procedure ChangeBounds (var Bounds: TRect); virtual; }
  254.     procedure Draw; virtual;
  255.     procedure DrawUpButton (Down: Boolean); virtual;
  256.     procedure DrawDnButton (Down: Boolean); virtual;
  257.     procedure DrawIndicator (V: Integer; Down: Boolean); virtual;
  258.     function GetPalette: PPalette; virtual;
  259.     function GetPosition (V: Integer): Integer; virtual;
  260.     procedure HandleEvent (var Event: TEvent); virtual;
  261.     procedure RestoreIndicator (OldV: Integer);
  262.     procedure ScrollDraw; virtual;
  263.     function ScrollStep (Part: Integer): Integer; virtual;
  264.     procedure SetParams (AValue, AMin, AMax, APgStep, AArStep: Integer);
  265.     procedure SetRange (AMin, AMax: Integer);
  266.     procedure SetState (AState: Word; Enable: Boolean); virtual;
  267.     procedure SetStep (APgStep, AArStep: Integer);
  268.     procedure SetValue (AValue: Integer);
  269.     procedure Store (var S: TStream);
  270.   end;
  271.  
  272. { TScroller object }
  273.  
  274.   { Palette Layout }
  275.   { 1 = Normal text }
  276.   { 2 = Selected text }
  277.   { 3 = Normal background }
  278.   { 4 = Selected background }
  279.  
  280.   PScroller = ^TScroller;
  281.   TScroller = object(TGView)
  282.     HScrollBar: PScrollBar;
  283.     VScrollBar: PScrollBar;
  284.     Delta: TPoint;
  285.     Limit: TPoint;
  286.     TextSize: TPoint;
  287.     constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  288.     constructor Load(var S: TStream);
  289.     procedure ChangeBounds(var Bounds: TRect); virtual;
  290.     function GetPalette: PPalette; virtual;
  291.     procedure HandleEvent(var Event: TEvent); virtual;
  292.     procedure ScrollDraw; virtual;
  293.     procedure ScrollTo(X, Y: Integer);
  294.     procedure SetLimit(X, Y: Integer);
  295.     procedure Store(var S: TStream);
  296.   private
  297.     DrawLock: Byte;
  298.     DrawFlag: Boolean;
  299.     procedure CheckDraw;
  300.     procedure HelpDraw (LnCol1, Line: Boolean);
  301.   end;
  302.  
  303. { TListViewer object }
  304.  
  305.   { Palette layout }
  306.   { 1 = Background }
  307.   { 2 = Frame }
  308.   { 3 = Normal Text }
  309.   { 4 = Selected Text }
  310.   { 5 = Normal Background }
  311.   { 6 = Selected Background }
  312.  
  313.   PListViewer = ^TListViewer;
  314.   TListViewer = object(TGView)
  315.     ScrollBar: PScrollBar;
  316.     TopItem: Integer;
  317.     Focused: Integer;
  318.     Range: Integer;
  319.     constructor Init(var Bounds: TRect; AScrollBar: PScrollBar);
  320.     constructor Load(var S: TStream);
  321.     procedure ChangeBounds(var Bounds: TRect); virtual;
  322.     procedure Draw; virtual;
  323.     procedure DrawItem (Item: Integer); virtual;
  324.     procedure FocusItem(Item: Integer); virtual;
  325.     function GetPalette: PPalette; virtual;
  326.     function GetText(Item: Integer; MaxLen: Integer): String; virtual;
  327.     function IsSelected(Item: Integer): Boolean; virtual;
  328.     procedure HandleEvent(var Event: TEvent); virtual;
  329.     procedure SelectItem(Item: Integer); virtual;
  330.     procedure SetRange(ARange: Integer);
  331.     procedure SetState(AState: Word; Enable: Boolean); virtual;
  332.     procedure Store(var S: TStream);
  333.   end;
  334.  
  335. { TPeerList record }
  336.  
  337.   PPeerList = ^TPeerList;
  338.   TPeerList = record
  339.     Number: Integer;
  340.     Master: ^PGView;
  341.     Next: PPeerList
  342.   End;
  343.  
  344. { TGGroup object }
  345.  
  346.   TGGroup = object(TGView)
  347.     Last: PGView;
  348.     Current: PGView;
  349.     AlreadyDrawn: Boolean;
  350.     Phase: (phFocused, phPreProcess, phPostProcess);
  351.     StandardFont: Word;
  352.     constructor Init(var Bounds: TRect);
  353.     constructor Load (var S: TStream);
  354.     destructor Done; virtual;
  355.     procedure ChangeBounds(var Bounds: TRect); virtual;
  356.     procedure ChMCursor; virtual;
  357.     function DataSize: Word; virtual;
  358.     procedure Delete(P: PGView);
  359.     procedure Draw; virtual;
  360.     procedure EndModal(Command: Word); virtual;
  361.     procedure EventError(var Event: TEvent); virtual;
  362.     function ExecView(P: PGView): Word;
  363.     function Execute: Word; virtual;
  364.     function First: PGView;
  365.     function FirstThat (Test: Pointer): PGView;
  366.     procedure ForEach (Action: Pointer);
  367.     procedure GetData(var Rec); virtual;
  368.     function GetHelpCtx: Word; virtual;
  369.     procedure GetSubViewPtr (var S: TStream; var P);
  370.     procedure HandleEvent(var Event: TEvent); virtual;
  371.     procedure Insert(P: PGView);
  372.          {procedure InsertBefore(P, Target: PGView);}
  373.     procedure Lock;
  374.     procedure PutSubViewPtr (var S: TStream; P: PGView);
  375.     procedure Redraw;
  376.     procedure SelectNext(Forwards: Boolean);
  377.     procedure SetData(var Rec); virtual;
  378.     procedure SetState(AState: Word; Enable: Boolean); virtual;
  379.     procedure Store (var S: TStream);
  380.     procedure UnLock;
  381.     function Valid(Command: Word): Boolean; virtual;
  382.   private
  383.     EndState: Word;
  384.     PeerList: PPeerList;
  385.     LockFlag: Byte;
  386.     function NextSelectable(P: PGView): PGView;
  387.   end;
  388.  
  389. { TWindow object }
  390.  
  391.   { Palette layout }
  392.   { 1  = Background }
  393.   { 2  = Frame active }
  394.   { 3  = Frame not active }
  395.   { 4  = Frame modal }
  396.   { 5  = Zoomfield }
  397.   { 6  = Title background normal}
  398.   { 7  = Title background selected }
  399.   { 8  = Title normal}
  400.   { 9  = Title selected }
  401.   { 10 = Close- and Zoomfield outside }
  402.   { 11 = Closefield frame }
  403.   { 12 = Closefield inside }
  404.   { 13 = Closefield shadow }
  405.   { 14 = Scrollbar background }
  406.   { 15 = Scrollbar frame }
  407.   { 16 = Scrollbar buttons }
  408.   { 17 = Scrollbar button shadows }
  409.   { 18 = Scrollbar page area }
  410.   { 19 = Scroller normal text }
  411.   { 20 = Scroller selected text }
  412.   { 21 = Scroller normal background }
  413.   { 22 = Scroller selected background }
  414.  
  415.   PWindow = ^TWindow;
  416.   TWindow = Object (TGGroup)
  417.     Title: PString;
  418.     Frame:PFrame;
  419.     BackGround:PBackGround;
  420.     Palette: Integer;
  421.     ZoomRect: TRect;
  422.     Flags: Byte;
  423.     Constructor Init (var Bounds:TRect; ATitle:String);
  424.     constructor Load (var S: TStream);
  425.     procedure Store (var S: TStream);
  426.     destructor Done; virtual;
  427.     procedure ChangeBounds (var Bounds: TRect); virtual;
  428.     procedure Close; virtual;
  429.     procedure DragView (Event: TEvent; Mode: Byte; var Limits: TRect;
  430.        MinSize, MaxSize: TPoint; ResMode: Byte);
  431.     procedure Draw; virtual;
  432.     procedure EndModal (Command: Word); virtual;
  433.     Function GetPalette:PPalette; virtual;
  434.     Function GetTitle (MaxSize: Integer): TTitleStr; virtual;
  435.     Procedure HandleEvent (var Event: TEvent); virtual;
  436.     Procedure InitFrame; virtual;
  437.     Procedure InitBackGround; virtual;
  438.     procedure RestoreBackground; virtual;
  439.     procedure SetState (AState: Word; Enable: Boolean); virtual;
  440.     procedure SizeLimits (var Min, Max: TPoint); virtual;
  441.     function StandardScrollBar (AOptions: Word): PScrollBar;
  442.     procedure Zoom; virtual;
  443.   private
  444.     ScrBBck: PBackground;
  445.   End;
  446.  
  447. { GVViews registration procedure }
  448.  
  449.   procedure RegisterGVViews;
  450.  
  451. { GVViews MouseCursor procedure }
  452.  
  453.   procedure GetGVViewsCursor (n: Integer);
  454.  
  455. { Stream registration records }
  456.  
  457. const
  458.  
  459.   RGView: TStreamRec = (
  460.     ObjType: 2;
  461.     VmtLink: Ofs(TypeOf(TGView)^);
  462.     Load: @TGView.Load;
  463.     Store: @TGView.Store);
  464.  
  465.   RFrame: TStreamRec = (
  466.     ObjType: 3;
  467.     VmtLink: Ofs(TypeOf(TFrame)^);
  468.     Load: @TFrame.Load;
  469.     Store: @TFrame.Store);
  470.  
  471.   RBackground: TStreamRec = (
  472.     ObjType: 4;
  473.     VmtLink: Ofs(TypeOf(TBackground)^);
  474.     Load: @TBackground.Load;
  475.     Store: @TBackground.Store);
  476.  
  477.   RScrollBar: TStreamRec = (
  478.     ObjType: 5;
  479.     VmtLink: Ofs(TypeOf(TScrollBar)^);
  480.     Load: @TScrollBar.Load;
  481.     Store: @TScrollBar.Store);
  482.  
  483.   RScroller: TStreamRec = (
  484.     ObjType: 6;
  485.     VmtLink: Ofs(TypeOf(TScroller)^);
  486.     Load: @TScroller.Load;
  487.     Store: @TScroller.Store);
  488.  
  489.   RListViewer: TStreamRec = (
  490.     ObjType: 7;
  491.     VmtLink: Ofs(TypeOf(TListViewer)^);
  492.     Load: @TListViewer.Load;
  493.     Store: @TListViewer.Store);
  494.  
  495.   RGGroup: TStreamRec = (
  496.     ObjType: 8;
  497.     VmtLink: Ofs(TypeOf(TGGroup)^);
  498.     Load: @TGGroup.Load;
  499.     Store: @TGGroup.Store);
  500.  
  501.   RWindow: TStreamRec = (
  502.     ObjType: 9;
  503.     VmtLink: Ofs(TypeOf(TWindow)^);
  504.     Load: @TWindow.Load;
  505.     Store: @TWindow.Store);
  506.  
  507. implementation
  508.