home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / ColorSync 2.5.1 SDK / Sample Code / CSDemo 2.5 / CSDemoSources / winPictDocGetSet.c < prev    next >
Encoding:
Text File  |  1998-09-09  |  12.8 KB  |  492 lines  |  [TEXT/CWIE]

  1. // A pict file window
  2. //
  3. // David Hayward 
  4. // Developer Technical Support
  5. // AppleLink: DEVSUPPORT
  6. //
  7. // Copyrite 1995, Apple Computer,Inc
  8. //
  9. // This file contains the getter/setter routines for
  10. // the PictDocDataHdl fields of a pict file window.
  11. // 
  12. // 9/13/94    nick    first cut
  13. // 12/13/94    david    several modifications
  14. //  9/25/97    ebb        mods to get and set times and pixel counts
  15.  
  16.  
  17. #include <QDOffScreen.h>
  18.  
  19. #include "win.h"
  20. #include "winPictDoc.h"
  21. #include "winPictDocGetSet.h"
  22. #include "colorsyncUtils.h"
  23.  
  24.  
  25. /*------------------------------------------------------------------------------*\
  26.     GetPictDocPict / SetPictDocPict
  27.  *------------------------------------------------------------------------------*
  28.         These routines get and set the Pict field of the PictDocDataHdl
  29.         of the winHandle.
  30. \*------------------------------------------------------------------------------*/
  31. PicHandle GetPictDocPict ( winHandle win, short which )
  32. {
  33.     PictDocDataHdl    data ;
  34.     data = (PictDocDataHdl) GetWinData ( win ) ;
  35.     if ( data==nil ) return nil ;
  36.     
  37.     switch (which)
  38.     {
  39.         case kOriginal:
  40.             return (**data).Pict ;
  41.             break ;
  42.         case kMatched:
  43.             return (**data).PictMatched ;
  44.             break ;
  45.         case kProofed:
  46.             return (**data).PictProofed ;
  47.             break ;
  48.         case kChecked:
  49.             return (**data).PictChecked ;
  50.             break ;
  51.     }
  52.     return nil ;
  53. }
  54. void SetPictDocPict ( winHandle win, short which, PicHandle thePict )
  55. {    
  56.     PictDocDataHdl    data ;
  57.     data = (PictDocDataHdl) GetWinData ( win ) ;
  58.     if ( data==nil ) return ;
  59.  
  60.     switch (which)
  61.     {
  62.         case kOriginal:
  63.             (**data).Pict = thePict ;
  64.             break ;
  65.         case kMatched:
  66.             (**data).PictMatched = thePict ;
  67.             break ;
  68.         case kProofed:
  69.             (**data).PictProofed = thePict ;
  70.             break ;
  71.         case kChecked:
  72.             (**data).PictChecked = thePict ;
  73.             break ;
  74.     }
  75. }
  76.  
  77.  
  78. /*------------------------------------------------------------------------------*\
  79.     GetPictDocNeedsUpdate / SetPictDocNeedsUpdate
  80.  *------------------------------------------------------------------------------*
  81.         These routines get and set the PictNeedsUpdate field of the PictDocDataHdl
  82.         of the winHandle.
  83. \*------------------------------------------------------------------------------*/
  84. Boolean GetPictDocNeedsUpdate ( winHandle win, short which )
  85. {
  86.     PictDocDataHdl    data ;
  87.     data = (PictDocDataHdl) GetWinData ( win ) ;
  88.     
  89.     switch (which)
  90.     {
  91.         case kOriginal:
  92.             return false ;
  93.             break ;
  94.         case kMatched:
  95.             return (**data).PictMatchedNeedsUpdate ;
  96.             break ;
  97.         case kProofed:
  98.             return (**data).PictProofedNeedsUpdate ;
  99.             break ;
  100.         case kChecked:
  101.             return (**data).PictCheckedNeedsUpdate ;
  102.             break ;
  103.     }
  104.     return false ;
  105. }
  106. void SetPictDocNeedsUpdate ( winHandle win, short which, Boolean b )
  107. {    
  108.     PictDocDataHdl    data ;
  109.     data = (PictDocDataHdl) GetWinData ( win ) ;
  110.     if ( data==nil ) return ;
  111.  
  112.     switch (which)
  113.     {
  114.         case kOriginal:
  115.             break ;
  116.         case kMatched:
  117.             (**data).PictMatchedNeedsUpdate = b ;
  118.             break ;
  119.         case kProofed:
  120.             (**data).PictProofedNeedsUpdate = b ;
  121.             break ;
  122.         case kChecked:
  123.             (**data).PictCheckedNeedsUpdate = b ;
  124.             break ;
  125.     }
  126. }
  127.  
  128.  
  129. /*------------------------------------------------------------------------------*\
  130.     GetPictDocDrawTime / SetPictDocDrawTime
  131.  *------------------------------------------------------------------------------*
  132.         These routines get and set the DrawTime field of the PictDocDataHdl
  133.         of the winHandle.
  134. \*------------------------------------------------------------------------------*/
  135. unsigned long GetPictDocDrawTime ( winHandle win, short which )
  136. {
  137.     PictDocDataHdl    data ;
  138.         data = (PictDocDataHdl) GetWinData ( win ) ;
  139.     if ( data==nil ) return nil;
  140.  
  141.     switch (which)
  142.     {
  143.         case kOriginal:
  144.             return 0L ;
  145.             break ;
  146.         case kMatched:
  147.             return (**data).MatchTime ;
  148.             break ;
  149.         case kProofed:
  150.             return (**data).ProofTime ;
  151.             break ;
  152.         case kChecked:
  153.             return (**data).CheckTime ;
  154.             break ;
  155.         case kTotal+kMatched:
  156.             return (**data).MatchTotalTime ;
  157.             break ;
  158.         case kTotal+kProofed:
  159.             return (**data).ProofTotalTime ;
  160.             break ;
  161.         case kTotal+kChecked:
  162.             return (**data).CheckTotalTime ;
  163.             break ;
  164.     }
  165.     return 0L ;
  166. }
  167. void SetPictDocDrawTime ( winHandle win, short which, unsigned long ticks )
  168. {    
  169.     PictDocDataHdl    data ;
  170.     data = (PictDocDataHdl) GetWinData ( win ) ;
  171.     if ( data==nil ) return ;
  172.  
  173.     switch (which)
  174.     {
  175.         case kOriginal:
  176.             break ;
  177.         case kMatched:
  178.             (**data).MatchTime = ticks ;
  179.             break ;
  180.         case kProofed:
  181.             (**data).ProofTime = ticks ;
  182.             break ;
  183.         case kChecked:
  184.             (**data).CheckTime = ticks ;
  185.             break ;
  186.         case kTotal+kMatched:
  187.             (**data).MatchTotalTime = ticks ;
  188.             break ;
  189.         case kTotal+kProofed:
  190.             (**data).ProofTotalTime = ticks ;
  191.             break ;
  192.         case kTotal+kChecked:
  193.             (**data).CheckTotalTime = ticks ;
  194.             break ;
  195.     }
  196. }
  197.  
  198. /*------------------------------------------------------------------------------*\
  199.     GetPictDocDrawCount / SetPictDocDrawCount
  200.  *------------------------------------------------------------------------------*
  201.         These routines get and set the DrawCount field of the PictDocDataHdl
  202.         of the winHandle.
  203. \*------------------------------------------------------------------------------*/
  204. unsigned long GetPictDocDrawCount ( winHandle win )
  205. {
  206.     PictDocDataHdl    data ;
  207.     unsigned long    count = 0;
  208.     
  209.     data = (PictDocDataHdl) GetWinData ( win ) ;
  210.         
  211.     if ( data != nil )
  212.         count = (**data).PixelCount ;
  213.     
  214.     return count;
  215. }
  216. void SetPictDocDrawCount ( winHandle win, unsigned long count )
  217. {    
  218.     PictDocDataHdl    data ;
  219.     data = (PictDocDataHdl) GetWinData ( win ) ;
  220.     
  221.     if ( data != nil )
  222.         (**data).PixelCount = count ;
  223. }
  224.  
  225.  
  226.  
  227. /*------------------------------------------------------------------------------*\
  228.     GetPictDocPictRect / SetPictDocPictRect
  229.  *------------------------------------------------------------------------------*
  230.         These routines get and set the PictRect field of the PictDocDataHdl
  231.         of the winHandle.
  232. \*------------------------------------------------------------------------------*/
  233. Rect GetPictDocPictRect ( winHandle win )
  234. {
  235.     PictDocDataHdl    data ;
  236.     Rect            nilRect = {0,0,0,0} ;
  237.     data = (PictDocDataHdl) GetWinData ( win ) ;
  238.     if ( data==nil ) return nilRect;
  239.     return (**data).PictRect ;
  240. }
  241. void SetPictDocPictRect ( winHandle win, Rect theRect )
  242. {    
  243.     PictDocDataHdl    data ;
  244.     data = (PictDocDataHdl) GetWinData ( win ) ;
  245.     if ( data==nil ) return ;
  246.     (**data).PictRect = theRect ;
  247. }
  248.  
  249.  
  250. /*------------------------------------------------------------------------------*\
  251.     GetPictDocPaneRect / SetPictDocPaneRect
  252.  *------------------------------------------------------------------------------*
  253.         These routines get and set the PaneRect field of the PictDocDataHdl
  254.         of the winHandle.
  255. \*------------------------------------------------------------------------------*/
  256. Rect GetPictDocPaneRect ( winHandle win )
  257. {
  258.     PictDocDataHdl    data ;
  259.     Rect            nilRect = {0,0,0,0} ;
  260.     data = (PictDocDataHdl) GetWinData ( win ) ;
  261.     if ( data==nil ) return nilRect;
  262.     return (**data).PaneRect ;
  263. }
  264. void SetPictDocPaneRect ( winHandle win, Rect theRect )
  265. {    
  266.     PictDocDataHdl    data ;
  267.     data = (PictDocDataHdl) GetWinData ( win ) ;
  268.     if ( data==nil ) return ;
  269.     (**data).PaneRect = theRect ;
  270. }
  271.  
  272.  
  273.  
  274. /*------------------------------------------------------------------------------*\
  275.     GetPictDocPalette / SetPictDocPalette
  276.  *------------------------------------------------------------------------------*
  277.         These routines get and set the Palette field of the PictDocDataHdl
  278.         of the winHandle.
  279. \*------------------------------------------------------------------------------*/
  280. PaletteHandle GetPictDocPalette ( winHandle win )
  281. {
  282.     PictDocDataHdl    data ;
  283.     data = (PictDocDataHdl) GetWinData ( win ) ;
  284.     if ( data==nil ) return nil;
  285.     return (**data).Palette ;
  286. }
  287. void SetPictDocPalette ( winHandle win, PaletteHandle thePalette )
  288. {    
  289.     PictDocDataHdl    data ;
  290.     data = (PictDocDataHdl) GetWinData ( win ) ;
  291.     if ( data==nil ) return ;
  292.     (**data).Palette = thePalette ;
  293. }
  294.  
  295.  
  296.  
  297. /*------------------------------------------------------------------------------*\
  298.     GetPictDocCntl / SetPictDocCntl / GetPictDocCntlValue
  299.  *------------------------------------------------------------------------------*
  300.         These routines get and set the ControlHandle fields of the PictDocDataHdl
  301.         of the winHandle.
  302. \*------------------------------------------------------------------------------*/
  303. ControlHandle GetPictDocCntl ( winHandle win, short id )
  304. {
  305.     PictDocDataHdl    data ;
  306.     ControlHandle    cntl ;
  307.     
  308.     data = (PictDocDataHdl) GetWinData ( win ) ;
  309.     if ( data==nil ) return nil;
  310.     
  311.     switch (id)
  312.     {
  313.         case rPictDocHorzScrollID :
  314.             cntl = (**data).HorzScroll ;
  315.             break ;
  316.         case rPictDocVertScrollID :
  317.             cntl = (**data).VertScroll ;
  318.             break ;
  319.         case rPictDocMatchOnOffID :
  320.             cntl = (**data).MatchOnOff ;
  321.             break ;
  322.         case rPictDocMatchPopupID :
  323.             cntl = (**data).MatchPopup ;
  324.             break ;
  325.     }
  326.     return cntl ;
  327. }
  328. void SetPictDocCntl ( winHandle win, short id, ControlHandle cntl )
  329. {    
  330.     PictDocDataHdl    data ;
  331.  
  332.     data = (PictDocDataHdl) GetWinData ( win ) ;
  333.     if ( data==nil ) return ;
  334.     
  335.     switch (id)
  336.     {
  337.         case rPictDocHorzScrollID :
  338.             (**data).HorzScroll = cntl ;
  339.             break ;
  340.         case rPictDocVertScrollID :
  341.             (**data).VertScroll = cntl ;
  342.             break ;
  343.         case rPictDocMatchOnOffID :
  344.             (**data).MatchOnOff = cntl ;
  345.             break ;
  346.         case rPictDocMatchPopupID :
  347.             (**data).MatchPopup = cntl ;
  348.             break ;
  349.     }
  350. }
  351. short GetPictDocCntlValue ( winHandle win, short id )
  352. {
  353.     ControlHandle    cntl ;
  354.     cntl = GetPictDocCntl ( win, id ) ;
  355.     if ( cntl==nil ) return nil;
  356.     return GetControlValue( cntl ) ;
  357. }
  358. void SetPictDocCntlValue ( winHandle win, short id, short val )
  359. {
  360.     ControlHandle    cntl ;
  361.     cntl = GetPictDocCntl ( win, id ) ;
  362.     if ( cntl==nil ) return ;
  363.     SetControlValue( cntl, val ) ;
  364. }
  365.  
  366.  
  367.  
  368. /*------------------------------------------------------------------------------*\
  369.     GetPictDocProfile / SetPictDocProfile
  370.  *------------------------------------------------------------------------------*
  371.         These routines get and set the SrceProf, DestProf or PrevProf field of 
  372.         the PictDocDataHdl of the winHandle.  The which field is not validated
  373.         and must be kSrceProf, kDestProf, or kPrevProf
  374. \*------------------------------------------------------------------------------*/
  375. CMProfileRef GetPictDocProfile ( winHandle win, short which )
  376. {
  377.     PictDocDataHdl    data ;
  378.     CMProfileRef    prof = nil ;
  379.     
  380.     data = (PictDocDataHdl) GetWinData ( win ) ;
  381.     if ( data==nil ) return nil;
  382.     
  383.     switch (which)
  384.     {
  385.         case kSrceProf :
  386.             prof = (**data).SrceProf ;
  387.             break ;
  388.         case kDestProf :
  389.             prof = (**data).DestProf ;
  390.             break ;
  391.         case kPrevProf :
  392.             prof = (**data).PrevProf ;
  393.             break ;
  394.     }
  395.     return prof ;
  396. }
  397.  
  398. void SetPictDocProfile ( winHandle win, short which, CMProfileRef prof )
  399. {    
  400.     PictDocDataHdl        data ;
  401.     
  402.     data = (PictDocDataHdl) GetWinData ( win ) ;
  403.     if ( data==nil ) return ;
  404.     
  405.     HLock( (Handle)data ) ;
  406.     
  407.     switch (which)
  408.     {
  409.         case kSrceProf :
  410.             (**data).SrceProf = prof ;
  411.             break ;
  412.         case kDestProf :
  413.             (**data).DestProf = prof ;
  414.             break ;
  415.         case kPrevProf :
  416.             (**data).PrevProf = prof ;
  417.             break ;
  418.     }
  419. }
  420.  
  421.  
  422. /*------------------------------------------------------------------------------*\
  423.     GetPictDocProfList / SetPictDocProfList
  424.  *------------------------------------------------------------------------------*
  425.         These routines get and set the ProfList field of the ProfListDataHdl
  426.         of the winRecord.
  427. \*------------------------------------------------------------------------------*/
  428. ListHandle GetPictDocProfList ( winHandle win )
  429. {
  430.     PictDocDataHdl    data ;
  431.         data = (PictDocDataHdl) GetWinData ( win ) ;
  432.     if ( data==nil ) return nil;
  433.     return (**data).ProfList ;
  434. }
  435. void SetPictDocProfList ( winHandle win, ListHandle list )
  436. {    
  437.     PictDocDataHdl    data ;
  438.     data = (PictDocDataHdl) GetWinData ( win ) ;
  439.     if ( data==nil ) return ;
  440.     (**data).ProfList = list ;
  441. }
  442.  
  443.  
  444. /*------------------------------------------------------------------------------*\
  445.     GetPictDocListCount / SetPictDocListCount
  446.  *------------------------------------------------------------------------------*
  447.         These routines get and set the ListCount field of the ProfListDataHdl
  448.         of the winRecord.
  449. \*------------------------------------------------------------------------------*/
  450. unsigned long GetPictDocListCount ( winHandle win )
  451. {
  452.     PictDocDataHdl    data ;
  453.         data = (PictDocDataHdl) GetWinData ( win ) ;
  454.     if ( data==nil ) return nil;
  455.     return (**data).ListCount ;
  456. }
  457. void SetPictDocListCount ( winHandle win, unsigned long count )
  458. {    
  459.     PictDocDataHdl    data ;
  460.     data = (PictDocDataHdl) GetWinData ( win ) ;
  461.     if ( data==nil ) return ;
  462.     (**data).ListCount = count ;
  463. }
  464.  
  465.  
  466. /*------------------------------------------------------------------------------*\
  467.     GetPictDocDragZones / SetPictDocDragZones
  468.  *------------------------------------------------------------------------------*
  469.         These routines get and set the DragZones field of the DragZonesHdl
  470.         of the winHandle.
  471. \*------------------------------------------------------------------------------*/
  472. DragZonesHdl GetPictDocDragZones ( winHandle win )
  473. {
  474.     PictDocDataHdl    data ;
  475.     data = (PictDocDataHdl) GetWinData ( win ) ;
  476.     if ( data==nil ) return nil ;
  477.     
  478.     return (**data).DragZones ;
  479. }
  480. void SetPictDocDragZones ( winHandle win, DragZonesHdl theDragZones )
  481. {    
  482.     PictDocDataHdl    data ;
  483.     data = (PictDocDataHdl) GetWinData ( win ) ;
  484.     if ( data==nil ) return ;
  485.  
  486.     (**data).DragZones = theDragZones ;
  487. }
  488.  
  489.  
  490.  
  491.  
  492.