home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / PInterfaces / Controls.p < prev    next >
Encoding:
Text File  |  1994-11-11  |  11.8 KB  |  482 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Controls.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT Controls;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __CONTROLS__}
  27. {$SETC __CONTROLS__ := 1}
  28.  
  29. {$I+}
  30. {$SETC ControlsIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __QUICKDRAW__}
  40. {$I Quickdraw.p}
  41. {$ENDC}
  42. {    MixedMode.p                                                    }
  43. {    QuickdrawText.p                                                }
  44.  
  45. {$IFC UNDEFINED __MENUS__}
  46. {$I Menus.p}
  47. {$ENDC}
  48. {    Memory.p                                                    }
  49. {    Events.p                                                    }
  50. {        OSUtils.p                                                }
  51.  
  52. {$PUSH}
  53. {$ALIGN MAC68K}
  54. {$LibExport+}
  55. {$IFC UNDEFINED STRICT_CONTROLS }
  56. {$SETC STRICT_CONTROLS := 0}
  57. {$ENDC}
  58.  
  59. CONST
  60.     pushButProc                    = 0;
  61.     checkBoxProc                = 1;
  62.     radioButProc                = 2;
  63.     scrollBarProc                = 16;
  64.     popupMenuProc                = 1008;
  65.  
  66. {}
  67. { Standard System 7 CDEF variant codes for use in control creation API's}
  68. {}
  69.     useWFont                    = 8;
  70.  
  71. {$IFC OLDROUTINENAMES }
  72.     inLabel                        = 1;
  73.     inMenu                        = 2;
  74.     inTriangle                    = 4;
  75.     inButton                    = 10;
  76.     inCheckBox                    = 11;
  77.     inUpButton                    = 20;
  78.     inDownButton                = 21;
  79.     inPageUp                    = 22;
  80.     inPageDown                    = 23;
  81.     inThumb                        = 129;
  82.  
  83. {$ENDC}
  84.     
  85. TYPE
  86.     ControlPartCode = UInt8;
  87.  
  88.     ControlHiliteValue = UInt8;
  89.  
  90.  
  91. CONST
  92.     kNoHiliteControlPart        = 0;
  93.     kInLabelControlPart            = 1;
  94.     kInMenuControlPart            = 2;
  95.     kInTriangleControlPart        = 4;
  96.     kInButtonControlPart        = 10;
  97.     kInCheckBoxControlPart        = 11;
  98.     kInUpButtonControlPart        = 20;
  99.     kInDownButtonControlPart    = 21;
  100.     kInPageUpControlPart        = 22;
  101.     kInPageDownControlPart        = 23;
  102.     kInIndicatorControlPart        = 129;
  103.     kReservedControlPart        = 254;
  104.     kControlInactiveControlPart    = 255;
  105.  
  106. {}
  107. { System 7 Pop-up menu variants}
  108. {}
  109.     popupFixedWidth                = 1 * (2**(0));
  110.     popupVariableWidth            = 1 * (2**(1));
  111.     popupUseAddResMenu            = 1 * (2**(2));
  112.     popupUseWFont                = 1 * (2**(3));
  113.  
  114. {}
  115. { System 7 Pop-up menu title styles}
  116. {}
  117.     popupTitleBold                = 1 * (2**(8));
  118.     popupTitleItalic            = 1 * (2**(9));
  119.     popupTitleUnderline            = 1 * (2**(10));
  120.     popupTitleOutline            = 1 * (2**(11));
  121.     popupTitleShadow            = 1 * (2**(12));
  122.     popupTitleCondense            = 1 * (2**(13));
  123.     popupTitleExtend            = 1 * (2**(14));
  124.     popupTitleNoStyle            = 1 * (2**(15));
  125.  
  126. {}
  127. { System 7 Pop-up menu label justifications}
  128. {}
  129.     popupTitleLeftJust            = $00000000;
  130.     popupTitleCenterJust        = $00000001;
  131.     popupTitleRightJust            = $000000FF;
  132.  
  133. {}
  134. { Axis constraints for DragGrayRgn call}
  135. {}
  136.     noConstraint                = kNoConstraint;
  137.     hAxisOnly                    = 1;
  138.     vAxisOnly                    = 2;
  139.  
  140. {}
  141. { Messages for the control defproc}
  142. {}
  143.     
  144. TYPE
  145.     ControlDefProcMessage = SInt16;
  146.  
  147.  
  148. CONST
  149.     drawCntl                    = 0;
  150.     testCntl                    = 1;
  151.     calcCRgns                    = 2;
  152.     initCntl                    = 3;
  153.     dispCntl                    = 4;
  154.     posCntl                        = 5;
  155.     thumbCntl                    = 6;
  156.     dragCntl                    = 7;
  157.     autoTrack                    = 8;
  158.     calcCntlRgn                    = 10;
  159.     calcThumbRgn                = 11;
  160.     drawThumbOutline            = 12;
  161.  
  162. {}
  163. { Control color table part codes}
  164. {}
  165.     cFrameColor                    = 0;
  166.     cBodyColor                    = 1;
  167.     cTextColor                    = 2;
  168.     cThumbColor                    = 3;
  169.  
  170. {$IFC STRICT_CONTROLS }
  171.     
  172. TYPE
  173.     ControlRef = Ptr;
  174.  
  175.     ControlHandle = ControlRef;
  176.  
  177. {$ELSEC}
  178.     
  179. TYPE
  180.     ControlPtr = ^ControlRecord;
  181.     ControlHandle = ^ControlPtr;
  182.  
  183.     ControlRef = ControlHandle;
  184.  
  185. {$ENDC}
  186. {}
  187. { Define the main entry point to the standard action proc pointer}
  188. {}
  189.     ControlDefProcPtr = ProcPtr;  { FUNCTION ControlDef(varCode: INTEGER; theControl: ControlRef; message: INTEGER; param: LONGINT): LONGINT; }
  190.     ControlActionProcPtr = ProcPtr;  { PROCEDURE ControlAction(theControl: ControlRef; partCode: INTEGER); }
  191.     ControlDefUPP = UniversalProcPtr;
  192.     ControlActionUPP = UniversalProcPtr;
  193.  
  194.     CtlCTab = RECORD
  195.         ccSeed:                    LONGINT;
  196.         ccRider:                INTEGER;
  197.         ctSize:                    INTEGER;
  198.         ctTable:                ARRAY [0..3] OF ColorSpec;
  199.     END;
  200.     CCTabPtr = ^CtlCTab;
  201.     CCTabHandle = ^CCTabPtr;
  202.  
  203. {$IFC NOT STRICT_CONTROLS }
  204.     ControlRecord = PACKED RECORD
  205.         nextControl:            ControlRef;
  206.         contrlOwner:            WindowRef;
  207.         contrlRect:                Rect;
  208.         contrlVis:                UInt8;
  209.         contrlHilite:            UInt8;
  210.         contrlValue:            INTEGER;
  211.         contrlMin:                INTEGER;
  212.         contrlMax:                INTEGER;
  213.         contrlDefProc:            Handle;
  214.         contrlData:                Handle;
  215.         contrlAction:            ControlActionUPP;
  216.         contrlRfCon:            LONGINT;
  217.         contrlTitle:            Str255;
  218.     END;
  219. {}
  220. { Define private pop-up menu storage (hung off contrlData field in ControlRecord).}
  221. {}
  222.     PopupPrivateData = RECORD
  223.         mHandle:                MenuHandle;
  224.         mID:                    INTEGER;
  225.     END;
  226.     PopupPrivateDataPtr = ^PopupPrivateData;
  227.     PopupPrivateDataHandle = ^PopupPrivateDataPtr;
  228.  
  229. {$ENDC}
  230.     AuxCtlRec = RECORD
  231.         acNext:                    Handle;
  232.         acOwner:                ControlRef;
  233.         acCTable:                CCTabHandle;
  234.         acFlags:                INTEGER;
  235.         acReserved:                LONGINT;
  236.         acRefCon:                LONGINT;
  237.     END;
  238.     AuxCtlPtr = ^AuxCtlRec;
  239.     AuxCtlHandle = ^AuxCtlPtr;
  240.  
  241. {}
  242. { Structure used in __TrackControl() - See IM I-332}
  243. {}
  244.     IndicatorDragConstraint = RECORD
  245.         limitRect:                Rect;
  246.         slopRect:                Rect;
  247.         axis:                    DragConstraint;
  248.     END;
  249.     IndicatorDragConstraintPtr = ^IndicatorDragConstraint;
  250.     IndicatorDragConstraintHandle = ^IndicatorDragConstraintPtr;
  251.  
  252. CONST
  253.     uppControlDefProcInfo = $00003BB0; { FUNCTION (2 byte param, 4 byte param, 2 byte param, 4 byte param): 4 byte result; }
  254.     uppControlActionProcInfo = $000002C0; { PROCEDURE (4 byte param, 2 byte param); }
  255.  
  256. FUNCTION NewControlDefProc(userRoutine: ControlDefProcPtr): ControlDefUPP;
  257.     {$IFC NOT GENERATINGCFM }
  258.     INLINE $2E9F;
  259.     {$ENDC}
  260.  
  261. FUNCTION NewControlActionProc(userRoutine: ControlActionProcPtr): ControlActionUPP;
  262.     {$IFC NOT GENERATINGCFM }
  263.     INLINE $2E9F;
  264.     {$ENDC}
  265.  
  266. FUNCTION CallControlDefProc(varCode: INTEGER; theControl: ControlRef; message: INTEGER; param: LONGINT; userRoutine: ControlDefUPP): LONGINT;
  267.     {$IFC NOT GENERATINGCFM}
  268.     INLINE $205F, $4E90;
  269.     {$ENDC}
  270.  
  271. PROCEDURE CallControlActionProc(theControl: ControlRef; partCode: INTEGER; userRoutine: ControlActionUPP);
  272.     {$IFC NOT GENERATINGCFM}
  273.     INLINE $205F, $4E90;
  274.     {$ENDC}
  275.  
  276. FUNCTION NewControl(theWindow: WindowRef; {CONST}VAR boundsRect: Rect; title: ConstStr255Param; visible: BOOLEAN; value: INTEGER; min: INTEGER; max: INTEGER; procID: INTEGER; refCon: LONGINT): ControlRef;
  277.     {$IFC NOT GENERATINGCFM}
  278.     INLINE $A954;
  279.     {$ENDC}
  280. PROCEDURE SetControlTitle(theControl: ControlRef; title: ConstStr255Param);
  281.     {$IFC NOT GENERATINGCFM}
  282.     INLINE $A95F;
  283.     {$ENDC}
  284. PROCEDURE GetControlTitle(theControl: ControlRef; VAR title: Str255);
  285.     {$IFC NOT GENERATINGCFM}
  286.     INLINE $A95E;
  287.     {$ENDC}
  288. FUNCTION GetNewControl(controlID: INTEGER; owner: WindowRef): ControlRef;
  289.     {$IFC NOT GENERATINGCFM}
  290.     INLINE $A9BE;
  291.     {$ENDC}
  292. PROCEDURE DisposeControl(theControl: ControlRef);
  293.     {$IFC NOT GENERATINGCFM}
  294.     INLINE $A955;
  295.     {$ENDC}
  296. PROCEDURE KillControls(theWindow: WindowRef);
  297.     {$IFC NOT GENERATINGCFM}
  298.     INLINE $A956;
  299.     {$ENDC}
  300. PROCEDURE HideControl(theControl: ControlRef);
  301.     {$IFC NOT GENERATINGCFM}
  302.     INLINE $A958;
  303.     {$ENDC}
  304. PROCEDURE ShowControl(theControl: ControlRef);
  305.     {$IFC NOT GENERATINGCFM}
  306.     INLINE $A957;
  307.     {$ENDC}
  308. PROCEDURE DrawControls(theWindow: WindowRef);
  309.     {$IFC NOT GENERATINGCFM}
  310.     INLINE $A969;
  311.     {$ENDC}
  312. PROCEDURE Draw1Control(theControl: ControlRef);
  313.     {$IFC NOT GENERATINGCFM}
  314.     INLINE $A96D;
  315.     {$ENDC}
  316. PROCEDURE HiliteControl(theControl: ControlRef; hiliteState: INTEGER);
  317.     {$IFC NOT GENERATINGCFM}
  318.     INLINE $A95D;
  319.     {$ENDC}
  320. PROCEDURE UpdateControls(theWindow: WindowRef; updateRgn: RgnHandle);
  321.     {$IFC NOT GENERATINGCFM}
  322.     INLINE $A953;
  323.     {$ENDC}
  324. PROCEDURE MoveControl(theControl: ControlRef; h: INTEGER; v: INTEGER);
  325.     {$IFC NOT GENERATINGCFM}
  326.     INLINE $A959;
  327.     {$ENDC}
  328. PROCEDURE SizeControl(theControl: ControlRef; w: INTEGER; h: INTEGER);
  329.     {$IFC NOT GENERATINGCFM}
  330.     INLINE $A95C;
  331.     {$ENDC}
  332. PROCEDURE SetControlValue(theControl: ControlRef; theValue: INTEGER);
  333.     {$IFC NOT GENERATINGCFM}
  334.     INLINE $A963;
  335.     {$ENDC}
  336. FUNCTION GetControlValue(theControl: ControlRef): INTEGER;
  337.     {$IFC NOT GENERATINGCFM}
  338.     INLINE $A960;
  339.     {$ENDC}
  340. PROCEDURE SetControlMinimum(theControl: ControlRef; minValue: INTEGER);
  341.     {$IFC NOT GENERATINGCFM}
  342.     INLINE $A964;
  343.     {$ENDC}
  344. FUNCTION GetControlMinimum(theControl: ControlRef): INTEGER;
  345.     {$IFC NOT GENERATINGCFM}
  346.     INLINE $A961;
  347.     {$ENDC}
  348. PROCEDURE SetControlMaximum(theControl: ControlRef; maxValue: INTEGER);
  349.     {$IFC NOT GENERATINGCFM}
  350.     INLINE $A965;
  351.     {$ENDC}
  352. FUNCTION GetControlMaximum(theControl: ControlRef): INTEGER;
  353.     {$IFC NOT GENERATINGCFM}
  354.     INLINE $A962;
  355.     {$ENDC}
  356. {$IFC NOT STRICT_CONTROLS }
  357. FUNCTION GetAuxiliaryControlRecord(theControl: ControlRef; VAR acHndl: AuxCtlHandle): BOOLEAN;
  358.     {$IFC NOT GENERATINGCFM}
  359.     INLINE $AA44;
  360.     {$ENDC}
  361. {$ENDC}
  362. PROCEDURE SetControlReference(theControl: ControlRef; data: LONGINT);
  363.     {$IFC NOT GENERATINGCFM}
  364.     INLINE $A95B;
  365.     {$ENDC}
  366. FUNCTION GetControlReference(theControl: ControlRef): LONGINT;
  367.     {$IFC NOT GENERATINGCFM}
  368.     INLINE $A95A;
  369.     {$ENDC}
  370. PROCEDURE SetControlAction(theControl: ControlRef; actionProc: ControlActionUPP);
  371.     {$IFC NOT GENERATINGCFM}
  372.     INLINE $A96B;
  373.     {$ENDC}
  374. FUNCTION GetControlAction(theControl: ControlRef): ControlActionUPP;
  375.     {$IFC NOT GENERATINGCFM}
  376.     INLINE $A96A;
  377.     {$ENDC}
  378. PROCEDURE DragControl(theControl: ControlRef; startPt: Point; {CONST}VAR limitRect: Rect; {CONST}VAR slopRect: Rect; axis: INTEGER);
  379.     {$IFC NOT GENERATINGCFM}
  380.     INLINE $A967;
  381.     {$ENDC}
  382. FUNCTION TestControl(theControl: ControlRef; thePt: Point): INTEGER;
  383.     {$IFC NOT GENERATINGCFM}
  384.     INLINE $A966;
  385.     {$ENDC}
  386. FUNCTION FindControl(thePoint: Point; theWindow: WindowRef; VAR theControl: ControlRef): INTEGER;
  387.     {$IFC NOT GENERATINGCFM}
  388.     INLINE $A96C;
  389.     {$ENDC}
  390. PROCEDURE SetControlColor(theControl: ControlRef; newColorTable: CCTabHandle);
  391.     {$IFC NOT GENERATINGCFM}
  392.     INLINE $AA43;
  393.     {$ENDC}
  394. FUNCTION GetControlVariant(theControl: ControlRef): INTEGER;
  395.     {$IFC NOT GENERATINGCFM}
  396.     INLINE $A809;
  397.     {$ENDC}
  398. {
  399.     When using the TrackControl() call when tracking an indicator, the
  400.     actionProc parameter (type ControlActionUPP) should be replaced by
  401.     a parameter of type DragGrayRgnUPP (defined in Quickdraw.<header>).
  402. }
  403. FUNCTION TrackControl(theControl: ControlRef; thePoint: Point; actionProc: ControlActionUPP): INTEGER;
  404.     {$IFC NOT GENERATINGCFM}
  405.     INLINE $A968;
  406.     {$ENDC}
  407. {$IFC OLDROUTINENAMES }
  408. PROCEDURE SetCTitle(theControl: ControlRef; title: ConstStr255Param);
  409.     {$IFC NOT GENERATINGCFM}
  410.     INLINE $A95F;
  411.     {$ENDC}
  412. PROCEDURE GetCTitle(theControl: ControlRef; VAR title: Str255);
  413.     {$IFC NOT GENERATINGCFM}
  414.     INLINE $A95E;
  415.     {$ENDC}
  416. PROCEDURE UpdtControl(theWindow: WindowRef; updateRgn: RgnHandle);
  417.     {$IFC NOT GENERATINGCFM}
  418.     INLINE $A953;
  419.     {$ENDC}
  420. {$IFC NOT STRICT_CONTROLS }
  421. PROCEDURE SetCtlValue(theControl: ControlRef; theValue: INTEGER);
  422.     {$IFC NOT GENERATINGCFM}
  423.     INLINE $A963;
  424.     {$ENDC}
  425. FUNCTION GetCtlValue(theControl: ControlRef): INTEGER;
  426.     {$IFC NOT GENERATINGCFM}
  427.     INLINE $A960;
  428.     {$ENDC}
  429. PROCEDURE SetCtlMin(theControl: ControlRef; minValue: INTEGER);
  430.     {$IFC NOT GENERATINGCFM}
  431.     INLINE $A964;
  432.     {$ENDC}
  433. FUNCTION GetCtlMin(theControl: ControlRef): INTEGER;
  434.     {$IFC NOT GENERATINGCFM}
  435.     INLINE $A961;
  436.     {$ENDC}
  437. PROCEDURE SetCtlMax(theControl: ControlRef; maxValue: INTEGER);
  438.     {$IFC NOT GENERATINGCFM}
  439.     INLINE $A965;
  440.     {$ENDC}
  441. FUNCTION GetCtlMax(theControl: ControlRef): INTEGER;
  442.     {$IFC NOT GENERATINGCFM}
  443.     INLINE $A962;
  444.     {$ENDC}
  445. {$ENDC}
  446. PROCEDURE SetCRefCon(theControl: ControlRef; data: LONGINT);
  447.     {$IFC NOT GENERATINGCFM}
  448.     INLINE $A95B;
  449.     {$ENDC}
  450. FUNCTION GetCRefCon(theControl: ControlRef): LONGINT;
  451.     {$IFC NOT GENERATINGCFM}
  452.     INLINE $A95A;
  453.     {$ENDC}
  454. PROCEDURE SetCtlAction(theControl: ControlRef; actionProc: ControlActionUPP);
  455.     {$IFC NOT GENERATINGCFM}
  456.     INLINE $A96B;
  457.     {$ENDC}
  458. FUNCTION GetCtlAction(theControl: ControlRef): ControlActionUPP;
  459.     {$IFC NOT GENERATINGCFM}
  460.     INLINE $A96A;
  461.     {$ENDC}
  462. PROCEDURE SetCtlColor(theControl: ControlRef; newColorTable: CCTabHandle);
  463.     {$IFC NOT GENERATINGCFM}
  464.     INLINE $AA43;
  465.     {$ENDC}
  466. FUNCTION GetCVariant(theControl: ControlRef): INTEGER;
  467.     {$IFC NOT GENERATINGCFM}
  468.     INLINE $A809;
  469.     {$ENDC}
  470. {$ENDC}
  471.  
  472. {$ALIGN RESET}
  473. {$POP}
  474.  
  475. {$SETC UsingIncludes := ControlsIncludes}
  476.  
  477. {$ENDC} {__CONTROLS__}
  478.  
  479. {$IFC NOT UsingIncludes}
  480.  END.
  481. {$ENDC}
  482.