home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / Pict2Ascii 1.03 / Panes / CGreyCaption.cp < prev    next >
Encoding:
Text File  |  1997-05-22  |  4.1 KB  |  143 lines  |  [TEXT/CWIE]

  1. // =================================================================================
  2. //    CGreyCaption.cp                         ©1997 BB's Team Inc. All rights reserved
  3. // =================================================================================
  4. #include "CGreyCaption.h"
  5.  
  6. #include <UDrawingState.h>
  7. #include <UDrawingUtils.h>
  8. #include <UGWorld.h>
  9. #include <UTextTraits.h>
  10.  
  11.  
  12. // ---------------------------------------------------------------------------------
  13. //        • CreateGreyCaptionStream [static]
  14. // ---------------------------------------------------------------------------------
  15. CGreyCaption *
  16. CGreyCaption::CreateGreyCaptionStream(
  17.     LStream    *inStream )
  18. {
  19.     return new CGreyCaption (inStream);
  20. }
  21.  
  22.  
  23. // ---------------------------------------------------------------------------------
  24. //        • CGreyCaption
  25. // ---------------------------------------------------------------------------------
  26. CGreyCaption::CGreyCaption()
  27.     : LCaption()
  28. {
  29. }
  30.  
  31.  
  32. // ---------------------------------------------------------------------------------
  33. //        • CGreyCaption(SPaneInfo&)
  34. // ---------------------------------------------------------------------------------
  35. CGreyCaption::CGreyCaption(
  36.     const SPaneInfo    &inPaneInfo,
  37.     ConstStringPtr    inString,
  38.     ResIDT            inTextTraitsID)
  39.     : LCaption (inPaneInfo, inString, inTextTraitsID)
  40. {
  41. }
  42.  
  43.  
  44. // ---------------------------------------------------------------------------------
  45. //        • CGreyCaption(const CGreyCaption&)
  46. // ---------------------------------------------------------------------------------
  47. CGreyCaption::CGreyCaption(
  48.     const CGreyCaption    &inOriginal )
  49.         : LCaption ( inOriginal )
  50. {
  51. }
  52.  
  53.  
  54. // ---------------------------------------------------------------------------------
  55. //        • CGreyCaption(LStream*)
  56. // ---------------------------------------------------------------------------------
  57. CGreyCaption::CGreyCaption(
  58.     LStream    *inStream )
  59.         : LCaption (inStream)
  60. {
  61. }
  62.  
  63.  
  64. // ---------------------------------------------------------------------------------
  65. //        • ~CGreyCaption
  66. // ---------------------------------------------------------------------------------
  67. CGreyCaption::~CGreyCaption()
  68. {
  69. }
  70.  
  71.  
  72. // ---------------------------------------------------------------------------------
  73. //        • Refresh
  74. // ---------------------------------------------------------------------------------
  75. void CGreyCaption::Refresh()
  76. {
  77.     Draw (nil);
  78. }
  79.  
  80.  
  81. // ---------------------------------------------------------------------------------
  82. //        • DrawSelf
  83. // ---------------------------------------------------------------------------------
  84. void
  85. CGreyCaption::DrawSelf()
  86. {
  87.     const RGBColor Col1 = { 222*256, 222*256, 222*256 };
  88.     const RGBColor Col2 = { 189*256, 189*256, 189*256 };
  89.     const RGBColor Col3 = { 140*256, 140*256, 140*256 };
  90.     const RGBColor Col4 = {  82*256,  82*256,  82*256 };
  91.     const RGBColor ColB = {   0*256,   0*256,   0*256 };
  92.     const RGBColor ColW = { 255*256, 255*256, 255*256 };
  93.  
  94.     // Calculate the frame rect.
  95.     Rect theFrame;
  96.     CalcLocalFrameRect (theFrame);
  97.     
  98.  
  99.     // enough to make it draw offscreen !
  100.     StOffscreenGWorld offWorld (theFrame, 8);
  101.     StColorState::Normalize();
  102.  
  103.  
  104.     // Fill with Grey
  105.     ::RGBBackColor (&Col1);
  106.     ::EraseRect (&theFrame);
  107.     
  108.     // Draw Text asap to avoid flickering
  109.     Int16    just = UTextTraits::SetPortTextTraits(mTxtrID);
  110.     
  111.     RGBColor    textColor;
  112.     ::GetForeColor(&textColor);
  113.     
  114.     ApplyForeAndBackColors();
  115.     ::RGBForeColor(&textColor);
  116.  
  117.     Rect textRect = theFrame;        // Modify the frame not to write against the border
  118.     ::InsetRect (&textRect, 2, 2);
  119.     ::OffsetRect (&textRect, 3, 1);
  120.  
  121.     UTextDrawing::DrawWithJustification((Ptr)&mText[1], mText[0], textRect, just);
  122.  
  123.     // Light (white)
  124.     ::RGBForeColor (&ColW);
  125.     ::MoveTo (theFrame.left, theFrame.top);        // above
  126.     ::Line (theFrame.right-theFrame.left-2, 0);
  127.     ::MoveTo (theFrame.left, theFrame.top);        // and left
  128.     ::Line (0, theFrame.bottom-theFrame.top-2);
  129.     
  130.     // Shadow
  131.     ::RGBForeColor (&Col3);
  132.     ::MoveTo (theFrame.left+1, theFrame.bottom-1);    // below
  133.     ::Line (theFrame.right-theFrame.left, 0);
  134.     ::MoveTo (theFrame.right-1, theFrame.top+1);    // and right
  135.     ::Line (0, theFrame.bottom-theFrame.top-2);
  136.     
  137.     // Black separator underneath
  138.     ::RGBForeColor (&ColB);
  139.     ::MoveTo (theFrame.left, theFrame.bottom);
  140.     ::Line (theFrame.right-theFrame.left, 0);
  141.  
  142. }
  143.