home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / CFDFront / TPctsView.cp < prev    next >
Encoding:
Text File  |  1992-02-21  |  4.7 KB  |  119 lines  |  [TEXT/MPS ]

  1. #pragma segment UIFlow
  2. // **********************************************************************
  3. //    TPctsView & TOpPict - Methods
  4. //     TPctsView & TOpPict together provide the palette functionality.
  5. //     The superview contains the entire palette, and the components of the palette also
  6. //     have their own class and functionality
  7. // **********************************************************************
  8. // --------------------------------------------------------------------------------------------------
  9. //    Do the mouse command.
  10. // --------------------------------------------------------------------------------------------------
  11. pascal struct TCommand * TOpPict::DoMouseCommand(Point * /*theMouse*/, EventInfo * /*info*/,
  12.                             Point * /*hysteresis*/)
  13.     {
  14.     IDType dataPic    = (IDType) 'Ops6';                                                            // the data icon
  15.     IDType fineGrid    = (IDType) 'Ops7';                                                            // fine grid icon
  16.     short oldIcon;
  17.     
  18.     oldIcon = ((TCFDFrontDocument *) fDocument)->GetMouseAction();
  19.     ((TPctsView *) fSuperView)->TurnAllOff();
  20.     ((TCFDFrontDocument *) fDocument)->SetMouseAction ((IDType) fIdentifier);
  21.     HiliteState (true, true);                                                                            // hilite the picture.
  22.     
  23.     if ((IDType) fIdentifier == dataPic)
  24.         {
  25.         if (! ((TCFDFrontDocument *) fDocument)->fDataView->IsShown())
  26.             ((TCFDFrontDocument *) fDocument)->fDataView->ShowIt();
  27.         }
  28.     else if (oldIcon == 5)
  29.         if (((TCFDFrontDocument *) fDocument)->fDataView->IsShown())
  30.             ((TCFDFrontDocument *) fDocument)->fDataView->HideIt();
  31.  
  32.     if ((IDType) fIdentifier == fineGrid && oldIcon != 6)
  33.         {
  34.         ((TCFDFrontDocument *) fDocument)->fPointMatrix->SetFineGrid(true);
  35.         ((TCFDFrontDocument *) fDocument)->fPointMatrix->ShowFineGrid();
  36.         }
  37.     else if ((IDType) fIdentifier != fineGrid && oldIcon == 6)
  38.         {
  39.         ((TCFDFrontDocument *) fDocument)->fPointMatrix->SetFineGrid(false);
  40.         ((TCFDFrontDocument *) fDocument)->fPointMatrix->ShowFineGrid();
  41.         }
  42.     return gNoChanges;                                                                                    // no command.
  43.     }
  44.     
  45. // --------------------------------------------------------------------------------------------------
  46. //    init this from our own resource.
  47. // --------------------------------------------------------------------------------------------------
  48. pascal void TOpPict::IRes (TDocument * itsDocument, TView * itsSuperView, Ptr * itsParams)
  49.     {
  50.     TPicture::IRes(itsDocument, itsSuperView, itsParams);
  51.     fDocument    = itsDocument;
  52.     fGeom            =    (TGeomView *) itsSuperView;
  53.     }
  54.     
  55. // --------------------------------------------------------------------------------------------------
  56. //        TPctsView stuff
  57. //    init this from our own resource.
  58. // --------------------------------------------------------------------------------------------------
  59. pascal void TPctsView::IRes (TDocument * itsDocument, TView * itsSuperView, Ptr * itsParams)
  60.     {
  61.     TView::IRes(itsDocument, itsSuperView, itsParams);
  62.     fDocument    = itsDocument;
  63.     }
  64.  
  65. // --------------------------------------------------------------------------------------------------
  66. //    Turn off the picture for the currently active mouse action mode. 
  67. // --------------------------------------------------------------------------------------------------
  68. void TPctsView::TurnAllOff (void)
  69.     {
  70.     TOpPict * activeOpPict;
  71.     IDType itsIdentifier = (IDType) 'Ops1';
  72.     
  73.     // get the identifier for the currently active mouse action picture
  74.     itsIdentifier += ((TCFDFrontDocument*)fDocument)->GetMouseAction();
  75.     activeOpPict = (TOpPict*) FindSubView(itsIdentifier);
  76.     activeOpPict->HiliteState(false, true);                                                    // unhilite it
  77.     }
  78.  
  79. // --------------------------------------------------------------------------------------------------
  80. //    Draw the View 
  81. // --------------------------------------------------------------------------------------------------
  82. pascal void TPctsView::Draw(Rect * /*thisRect*/)                                            // Draws the view seen in the window. 
  83.     {    
  84.     Point pen;
  85.     Rect  tRect;
  86.     pen.v = 1;     pen.h = 1;
  87.     tRect.top = 0;
  88.     tRect.left = 0;
  89.     tRect.right = (short) fSize.h;
  90.     tRect.bottom = (short) fSize.v;
  91.  
  92.     HLock((Handle) this);
  93.     RGBForeColor(&GridLineColor);                                                                    // set color
  94.     PenPixPat(GridLinePat);
  95.     
  96.     this->Adorn(&tRect,pen,adnLineBottom);
  97.     this->Adorn(&tRect,pen,adnLineRight);
  98.     HUnlock((Handle) this);
  99.     this->Focus();
  100.     return;
  101.     } 
  102.  
  103. // --------------------------------------------------------------------------------------------------
  104. //    If the SuperView is changed want to move TinformationView
  105. // --------------------------------------------------------------------------------------------------
  106. pascal void TPctsView::SuperViewChangedSize(VPoint *delta, Boolean /*invalidate*/)
  107.     {
  108.     VPoint newLoc;
  109.     
  110.     newLoc.h = fLocation.h;
  111.     newLoc.v = fLocation.v;
  112.     this->Locate(newLoc.h,newLoc.v,true);
  113.     newLoc.h = fSize.h;
  114.     newLoc.v = fSize.v + delta->v;
  115.     this->Resize(newLoc.h,newLoc.v,true);
  116.     return;    
  117.     }
  118.  
  119.