Package Name: windows

Return to: Package List


with Interfaces.C.Extensions; use Interfaces.C.Extensions;
with Types; use Types;
with Quickdraw; use Quickdraw;
with Events; use Events;
with Controls; use Controls;

with Unchecked_Conversion;

package Windows is
   --  
   --  File:       Windows.h
   --  
   --  Contains:   Window Manager Interfaces.
   --  
   --  Version:    Technology: System 7.5
   --              Package:    Universal Interfaces 2.1 in ÒMPW LatestÓ on ETO #18
   --  
   --  Copyright:  © 1984-1995 by Apple Computer, Inc.
   --              All rights reserved.
   --
   function Convert is new
      Unchecked_Conversion(Integer, QuickDraw.WindowRef);

   FrontMost : constant QuickDraw.WindowRef := Convert (-1);
   -- Old-style procIDs.  For use only with New(C)Window
   documentProc          : constant Short_Integer :=  0;
   dBoxProc              : constant Short_Integer :=  1;
   plainDBox             : constant Short_Integer :=  2;
   altDBoxProc           : constant Short_Integer :=  3;
   noGrowDocProc         : constant Short_Integer :=  4;
   movableDBoxProc       : constant Short_Integer :=  5;
   zoomDocProc           : constant Short_Integer :=  8;
   zoomNoGrow            : constant Short_Integer :=  12;

   rDocProc              : constant Short_Integer :=  16;
   -- floating window defproc ids
   floatProc             : constant Short_Integer :=  1985;
   floatGrowProc         : constant Short_Integer :=  1987;
   floatZoomProc         : constant Short_Integer :=  1989;
   floatZoomGrowProc     : constant Short_Integer :=  1991;
   floatSideProc         : constant Short_Integer :=  1993;
   floatSideGrowProc     : constant Short_Integer :=  1995;
   floatSideZoomProc     : constant Short_Integer :=  1997;


   floatSideZoomGrowProc : constant Short_Integer :=  1999;
   -- Standard window kinds
	dialogKind             : constant Short_Integer := 2;
	userKind               : constant Short_Integer := 8;
	kDialogWindowKind      : constant Short_Integer := 2;

	kApplicationWindowKind : constant Short_Integer := 8;
   -- FindWindow result codes
	inDesk      : constant Short_Integer := 0;
	inMenuBar   : constant Short_Integer := 1;
	inSysWindow : constant Short_Integer := 2;
	inContent   : constant Short_Integer := 3;
	inDrag      : constant Short_Integer := 4;
	inGrow      : constant Short_Integer := 5;
	inGoAway    : constant Short_Integer := 6;
	inZoomIn    : constant Short_Integer := 7;

	inZoomOut   : constant Short_Integer := 8;
	wDraw      : constant Short_Integer := 0;
	wHit       : constant Short_Integer := 1;
	wCalcRgns  : constant Short_Integer := 2;
	wNew       : constant Short_Integer := 3;
	wDispose   : constant Short_Integer := 4;
	wGrow      : constant Short_Integer := 5;

	wDrawGIcon : constant Short_Integer := 6;

	deskPatID  : constant Short_Integer := 16;
   -- Window Definition hit test result codes ("WindowPart")
	wNoHit     : constant Short_Integer := 0;
	wInContent : constant Short_Integer := 1;
	wInDrag    : constant Short_Integer := 2;
	wInGrow    : constant Short_Integer := 3;
	wInGoAway  : constant Short_Integer := 4;
	wInZoomIn  : constant Short_Integer := 5;

	wInZoomOut : constant Short_Integer := 6;
   type WindowDefProcPtr is access function
      (varCode   : in     Short_Integer;
       theWindow : in     WindowRef;
       message   : in     Short_Integer;
       param     : in     Long_Integer)

       return Long_Integer;
   subtype WindowDefUPP is UniversalProcPtr;

   subtype DeskHookUPP is UniversalProcPtr;
   function GetGrayRgn
      return                      RgnHandle;

   pragma Import (C, GetGrayRgn, "GetGrayRgn", "GetGrayRgn");
   type WinCTab is 
      record
         wCSeed : Long_Integer;                   --  reserved
         wCReserved : Short_Integer;              --  reserved
         ctSize : Short_Integer;                  --  usually 4 for windows
         ctTable : ColorSpec_Vec_5;
      end record;
   type WCTabPtr is Access WinCTab;

   type WCTabHandle is Access WCTabPtr;
   procedure InitWindows;

   pragma Import (C, InitWindows, "InitWindows", "InitWindows");
   procedure GetWMgrPort
     (wPort              : access GrafPtr);

   pragma Import (C, GetWMgrPort, "GetWMgrPort", "GetWMgrPort");
   function NewWindow
     (wStorage           : in     Void_Ptr;
      boundsRect         : access Rect;
      title              : access Str255;
      visible            : in     Boolean;
      theProc            : in     Short_Integer;
      behind             : in     WindowRef;
      goAwayFlag         : in     Boolean;
      refCon             : in     Long_Integer)
      return                      WindowRef;

   pragma Import (C, NewWindow, "NewWindow", "NewWindow");
   function GetNewWindow
     (windowID           : in     Short_Integer;
      wStorage           : in     Void_Ptr;
      behind             : in     WindowRef)
      return                      WindowRef;

   pragma Import (C, GetNewWindow, "GetNewWindow", "GetNewWindow");
   procedure CloseWindow
     (theWindow          : in     WindowRef);

   pragma Import (C, CloseWindow, "CloseWindow", "CloseWindow");
   procedure DisposeWindow
     (theWindow          : in     WindowRef);

   pragma Import (C, DisposeWindow, "DisposeWindow", "DisposeWindow");
   procedure GetWTitle
     (theWindow          : in     WindowRef;
      title              : access Str255);
   pragma Import (C, GetWTitle, "GetWTitle", "GetWTitle");
   
   procedure SetWTitle
     (theWindow          : in     WindowRef;
      title              : access Str255);
   pragma Import (C, SetWTitle, "SetWTitle", "SetWTitle");
   
   procedure SelectWindow
     (theWindow          : in     WindowRef);
   pragma Import (C, SelectWindow, "SelectWindow", "SelectWindow");
   
   procedure HideWindow
     (theWindow          : in     WindowRef);
   pragma Import (C, HideWindow, "HideWindow", "HideWindow");
   
   procedure ShowWindow
     (theWindow          : in     WindowRef);
   pragma Import (C, ShowWindow, "ShowWindow", "ShowWindow");
   
   procedure ShowHide
     (theWindow          : in     WindowRef;
      showFlag           : in     Boolean);
   pragma Import (C, ShowHide, "ShowHide", "ShowHide");
   
   procedure HiliteWindow
     (theWindow          : in     WindowRef;
      fHilite            : in     Boolean);
   pragma Import (C, HiliteWindow, "HiliteWindow", "HiliteWindow");
   
   procedure BringToFront
     (theWindow          : in     WindowRef);
   pragma Import (C, BringToFront, "BringToFront", "BringToFront");
   
   procedure SendBehind
     (theWindow          : in     WindowRef;
      behindWindow       : in     WindowRef);
   pragma Import (C, SendBehind, "SendBehind", "SendBehind");
   
   function FrontWindow
      return                      WindowRef;
   pragma Import (C, FrontWindow, "FrontWindow", "FrontWindow");
   
   procedure DrawGrowIcon
     (theWindow          : in     WindowRef);
   pragma Import (C, DrawGrowIcon, "DrawGrowIcon", "DrawGrowIcon");
   
   procedure MoveWindow
     (theWindow          : in     WindowRef;
      hGlobal            : in     Short_Integer;
      vGlobal            : in     Short_Integer;
      front              : in     Boolean);
   pragma Import (C, MoveWindow, "MoveWindow", "MoveWindow");
   
   procedure SizeWindow
     (theWindow          : in     WindowRef;
      w                  : in     Short_Integer;
      h                  : in     Short_Integer;
      fUpdate            : in     Boolean);
   pragma Import (C, SizeWindow, "SizeWindow", "SizeWindow");
   
   procedure ZoomWindow
     (theWindow          : in     WindowRef;
      partCode           : in     Short_Integer;
      front              : in     Boolean);
   pragma Import (C, ZoomWindow, "ZoomWindow", "ZoomWindow");
   
   procedure InvalRect
     (badRect            : access Rect);
   pragma Import (C, InvalRect, "InvalRect", "InvalRect");
   
   procedure InvalRgn
     (badRgn             : in     RgnHandle);
   pragma Import (C, InvalRgn, "InvalRgn", "InvalRgn");
   
   procedure ValidRect
     (goodRect           : access Rect);
   pragma Import (C, ValidRect, "ValidRect", "ValidRect");
   
   procedure ValidRgn
     (goodRgn            : in     RgnHandle);
   pragma Import (C, ValidRgn, "ValidRgn", "ValidRgn");
   
   procedure BeginUpdate
     (theWindow          : in     WindowRef);
   pragma Import (C, BeginUpdate, "BeginUpdate", "BeginUpdate");
   
   procedure EndUpdate
     (theWindow          : in     WindowRef);
   pragma Import (C, EndUpdate, "EndUpdate", "EndUpdate");
   
   procedure SetWRefCon
     (theWindow          : in     WindowRef;
      data               : in     Long_Integer);
   pragma Import (C, SetWRefCon, "SetWRefCon", "SetWRefCon");
   
   function GetWRefCon
     (theWindow          : in     WindowRef)
      return                      Long_Integer;
   pragma Import (C, GetWRefCon, "GetWRefCon", "GetWRefCon");
   
   procedure SetWindowPic
     (theWindow          : in     WindowRef;
      pic                : in     PicHandle);
   pragma Import (C, SetWindowPic, "SetWindowPic", "SetWindowPic");
   
   function GetWindowPic
     (theWindow          : in     WindowRef)
      return                      PicHandle;
   pragma Import (C, GetWindowPic, "GetWindowPic", "GetWindowPic");
   
   function CheckUpdate
     (theEvent           : access EventRecord)
      return                      Boolean;
   pragma Import (C, CheckUpdate, "CheckUpdate", "CheckUpdate");
   
   procedure ClipAbove
     (window             : in     WindowRef);
   pragma Import (C, ClipAbove, "ClipAbove", "ClipAbove");
   
   procedure SaveOld
     (window             : in     WindowRef);
   pragma Import (C, SaveOld, "SaveOld", "SaveOld");
   
   procedure DrawNew
     (window             : in     WindowRef;
      update             : in     Boolean);
   pragma Import (C, DrawNew, "DrawNew", "DrawNew");
   
   procedure PaintOne
     (window             : in     WindowRef;
      clobberedRgn       : in     RgnHandle);
   pragma Import (C, PaintOne, "PaintOne", "PaintOne");
   
   procedure PaintBehind
     (startWindow        : in     WindowRef;
      clobberedRgn       : in     RgnHandle);
   pragma Import (C, PaintBehind, "PaintBehind", "PaintBehind");
   
   procedure CalcVis
     (window             : in     WindowRef);
   pragma Import (C, CalcVis, "CalcVis", "CalcVis");
   
   procedure CalcVisBehind
     (startWindow        : in     WindowRef;
      clobberedRgn       : in     RgnHandle);
   pragma Import (C, CalcVisBehind, "CalcVisBehind", "CalcVisBehind");
   
   function GrowWindow
     (theWindow          : in     WindowRef;
      startPt            : in     Point;
      bBox               : access Rect)
      return                      Long_Integer;
   pragma Import (C, GrowWindow, "GrowWindow", "GrowWindow");
   
   function FindWindow
     (thePoint           : in     Point;
      theWindow          : access WindowRef)
      return                      Short_Integer;
   pragma Import (C, FindWindow, "FindWindow", "FindWindow");
   
   function PinRect
     (theRect            : access Rect;
      thePt              : in     Point)
      return                      Long_Integer;
   pragma Import (C, PinRect, "PinRect", "PinRect");
   
   function DragGrayRgn
     (theRgn             : in     RgnHandle;
      startPt            : in     Point;
      limitRect          : access Rect;
      slopRect           : access Rect;
      axis               : in     Short_Integer;
      actionProc         : in     DragGrayRgnUPP)
      return                      Long_Integer;
   pragma Import (C, DragGrayRgn, "DragGrayRgn", "DragGrayRgn");
   
   function DragTheRgn
     (theRgn             : in     RgnHandle;
      startPt            : in     Point;
      limitRect          : access Rect;
      slopRect           : access Rect;
      axis               : in     Short_Integer;
      actionProc         : in     DragGrayRgnUPP)
      return                      Long_Integer;
   pragma Import (C, DragTheRgn, "DragTheRgn", "DragTheRgn");
   
   function TrackBox
     (theWindow          : in     WindowRef;
      thePt              : in     Point;
      partCode           : in     Short_Integer)
      return                      Boolean;
   pragma Import (C, TrackBox, "TrackBox", "TrackBox");
   
   procedure GetCWMgrPort
     (wMgrCPort          : access CGrafPtr);
   pragma Import (C, GetCWMgrPort, "GetCWMgrPort", "GetCWMgrPort");
   
   procedure SetWinColor
     (theWindow          : in     WindowRef;
      newColorTable      : in     WCTabHandle);
   pragma Import (C, SetWinColor, "SetWinColor", "SetWinColor");
   
   procedure SetDeskCPat
     (deskPixPat         : in     PixPatHandle);
   pragma Import (C, SetDeskCPat, "SetDeskCPat", "SetDeskCPat");
   
   function NewCWindow
     (wStorage           : in     Void_Ptr;
      boundsRect         : access Rect;
      title              : access Str255;
      visible            : in     Boolean;
      procID             : in     Short_Integer;
      behind             : in     WindowRef;
      goAwayFlag         : in     Boolean;
      refCon             : in     Long_Integer)
      return                      WindowRef;
   pragma Import (C, NewCWindow, "NewCWindow", "NewCWindow");
   
   function GetNewCWindow
     (windowID           : in     Short_Integer;
      wStorage           : in     Void_Ptr;
      behind             : in     WindowRef)
      return                      WindowRef;
   pragma Import (C, GetNewCWindow, "GetNewCWindow", "GetNewCWindow");
   
   function GetWVariant
     (theWindow          : in     WindowRef)
      return                      Short_Integer;
   pragma Import (C, GetWVariant, "GetWVariant", "GetWVariant");
   
   function TrackGoAway
     (theWindow          : in     WindowRef;
      thePt              : in     Point)
      return                      Boolean;
   pragma Import (C, TrackGoAway, "TrackGoAway", "TrackGoAway");
   
   procedure DragWindow
     (theWindow          : in     WindowRef;
      startPt            : in     Point;
      boundsRect         : access Rect);
   pragma Import (C, DragWindow, "DragWindow", "DragWindow");
   
   procedure SetWTitle
     (theWindow          : in     WindowRef;

      title              : in     String);
   function NewWindow
     (wStorage           : in     Void_Ptr;
      boundsRect         : access Rect;
      title              : in     String;
      visible            : in     Boolean;
      theProc            : in     Short_Integer;
      behind             : in     WindowRef;
      goAwayFlag         : in     Boolean;
      refCon             : in     Long_Integer)

      return                      WindowRef;
   function NewCWindow
     (wStorage           : in     Void_Ptr;
      boundsRect         : access Rect;
      title              : in     String;
      visible            : in     Boolean;
      procID             : in     Short_Integer;
      behind             : in     WindowRef;
      goAwayFlag         : in     Boolean;
      refCon             : in     Long_Integer)

      return                      WindowRef;
   type WindowRecord;
   type WindowPeek is Access WindowRecord;
   type WindowRecord is 
      record
         port : GrafPort;
         windowKind : Short_Integer;
         visible : Boolean;
         hilited : Boolean;
         goAwayFlag : Boolean;
         spareFlag : Boolean;
         strucRgn : RgnHandle;
         contRgn : RgnHandle;
         updateRgn : RgnHandle;
         windowDefProc : Handle;
         dataHandle : Handle;
         titleHandle : StringHandle;
         titleWidth : Short_Integer;
         controlList : ControlRef;
         nextWindow : WindowPeek;
         windowPic : PicHandle;
         refCon : Long_Integer;

      end record;
   type CWindowRecord;
   type CWindowPeek is Access CWindowRecord;
   type CWindowRecord is 
      record
         port : CGrafPort;
         windowKind : Short_Integer;
         visible : Boolean;
         hilited : Boolean;
         goAwayFlag : Boolean;
         spareFlag : Boolean;
         strucRgn : RgnHandle;
         contRgn : RgnHandle;
         updateRgn : RgnHandle;
         windowDefProc : Handle;
         dataHandle : Handle;
         titleHandle : StringHandle;
         titleWidth : Short_Integer;
         controlList : ControlRef;
         nextWindow : CWindowPeek;
         windowPic : PicHandle;
         refCon : Long_Integer;

      end record;
   type WStateData is 
      record
         userState : Rect;                        --  user stat
         stdState : Rect;                         --  standard stat
      end record;
   type WStateDataPtr is Access WStateData;

   type WStateDataHandle is Access WStateDataPtr;
   type AuxWinRec;
   type AuxWinPtr is Access AuxWinRec;
   type AuxWinHandle is Access AuxWinPtr;
   type AuxWinRec is 
      record
         awNext : AuxWinHandle;                   --  handle to next AuxWinRec
         awOwner : WindowRef;                     --  ptr to window
         awCTable : CTabHandle;                   --  color table for this window
         reserved : UInt32;                       --  
         awFlags : Long_Integer;                  --  reserved for expansion
         awReserved : CTabHandle;                 --  reserved for expansion
         awRefCon : Long_Integer;                 --  user Constant

      end record;
   function GetAuxWin
     (theWindow          : in     WindowRef;
      awHndl             : access AuxWinHandle)
      return                      Boolean;

   pragma Import (C, GetAuxWin, "GetAuxWin", "GetAuxWin");
end Windows;