home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / aplusplus-1.01-src.lha / GNU / src / amiga / APlusPlus-1.01 / libsource / GBorder.cxx < prev    next >
C/C++ Source or Header  |  1994-05-08  |  5KB  |  171 lines

  1. /******************************************************************************
  2.  **
  3.  **    C++ Class Library for the Amiga© system software.
  4.  **
  5.  **    Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  6.  **    All Rights Reserved.
  7.  **
  8.  **    $Source: apphome:APlusPlus/RCS/libsource/GBorder.cxx,v $
  9.  **    $Revision: 1.7 $
  10.  **    $Date: 1994/05/08 13:40:47 $
  11.  **    $Author: Armin_Vogt $
  12.  **    
  13.  ******************************************************************************/
  14.  
  15.  
  16. extern "C" {
  17. #ifdef __GNUG__
  18. #include <inline/graphics.h>
  19. #endif
  20.  
  21. #ifdef __SASC
  22. #include <proto/graphics.h>
  23. #endif
  24. }
  25.  
  26. #include <APlusPlus/graphics/GBorder.h>
  27. #include <APlusPlus/intuition/GWindow.h>
  28.  
  29.  
  30. volatile static char rcs_id[] = "$Id: GBorder.cxx,v 1.7 1994/05/08 13:40:47 Armin_Vogt Exp Armin_Vogt $";
  31.  
  32.  
  33. void GBorder::drawBorder(GraphicObject *graphicObj,GWindow *homeWindow)
  34. {
  35.     ULONG bgCol;
  36.     if (graphicObj->getAttribute(GOB_BackgroundColor,bgCol))
  37.     {
  38.         homeWindow->setAPen(bgCol);
  39.         homeWindow->setOPen(bgCol);
  40.         homeWindow->setDrMd(JAM1);
  41.         homeWindow->rectFill(NORM_X(graphicObj->left()), NORM_Y(graphicObj->top()),
  42.                                     NORM_X(graphicObj->right()), NORM_Y(graphicObj->bottom()));
  43.  
  44.     }
  45. }
  46.  
  47. BevelBox::BevelBox(BOOL recessed) : drawRecessed(recessed)
  48. {
  49. }
  50.  
  51. void BevelBox::makeBorder(GraphicObject *graphicObj)
  52. {
  53.     graphicObj->setBorders(2,1,2,1);
  54. }
  55.  
  56. void BevelBox::drawBorder(GraphicObject *graphicObj,GWindow *homeWindow)
  57. {
  58.     GBorder::drawBorder(graphicObj,homeWindow);
  59.     
  60.     homeWindow->setStdClip();
  61.     homeWindow->drawBevelBox(NORM_X(graphicObj->left()),
  62.                                      NORM_Y(graphicObj->top()),
  63.                                      graphicObj->width(),graphicObj->height(),drawRecessed);
  64.     homeWindow->resetStdClip();
  65. }
  66.  
  67.  
  68. void LineBorder::makeBorder(GraphicObject *graphicObj)
  69. {
  70.     graphicObj->setBorders(1,1,1,1);
  71. }
  72.  
  73. void LineBorder::drawBorder(GraphicObject *graphicObj,GWindow *homeWindow)
  74. {
  75.     GBorder::drawBorder(graphicObj,homeWindow);
  76.  
  77.     WORD polyTable[5][2];
  78.         polyTable[0][0] = (WORD)NORM_X(graphicObj->left());
  79.         polyTable[0][1] = (WORD)NORM_Y(graphicObj->top());
  80.         polyTable[1][0] = (WORD)NORM_X(graphicObj->right());
  81.         polyTable[1][1] = (WORD)NORM_Y(graphicObj->top());
  82.         polyTable[2][0] = (WORD)NORM_X(graphicObj->right());
  83.         polyTable[2][1] = (WORD)NORM_Y(graphicObj->bottom());
  84.         polyTable[3][0] = (WORD)NORM_X(graphicObj->left());
  85.         polyTable[3][1] = (WORD)NORM_Y(graphicObj->bottom());
  86.         polyTable[4][0] = (WORD)NORM_X(graphicObj->left());
  87.         polyTable[4][1] = (WORD)NORM_Y(graphicObj->top());
  88.     homeWindow->setStdClip();
  89.     homeWindow->setAPen(1);
  90.     homeWindow->move(polyTable[0][0],polyTable[0][1]);
  91.     homeWindow->polyDraw(5,&polyTable[0][0]);
  92.     homeWindow->resetStdClip();
  93. }
  94.  
  95.  
  96. NeXTBorder::NeXTBorder(UBYTE *titleFontName,UBYTE titleFontSize) 
  97.     : titleFont(titleFontName,titleFontSize)
  98. {
  99. }
  100.  
  101. void NeXTBorder::makeBorder(GraphicObject *graphicObj)
  102. {
  103.     UBYTE fontHeight = titleFont.ySize();
  104.     graphicObj->setBorders(fontHeight,fontHeight,fontHeight,fontHeight);
  105. }
  106.  
  107. void NeXTBorder::drawBorder(GraphicObject *graphicObj,GWindow *homeWindow)
  108. {    
  109.     GBorder::drawBorder(graphicObj,homeWindow);
  110.  
  111.     WORD bWidth = titleFont.ySize(),bHeight = titleFont.ySize();
  112.     #define X 0
  113.     #define Y 1
  114.     
  115.     homeWindow->setStdClip();
  116.     homeWindow->setDrMd(JAM1);
  117.  
  118.  
  119.     WORD polyTable[3][2];
  120.     WORD startX,endX;
  121.     STRPTR title=NULL;
  122.     if (graphicObj->getAttribute(GOB_BorderTitle,(ULONG&)title))
  123.     {
  124.         _dout("bordertext: "<<(char*)title<<"\n");
  125.         homeWindow->setFont(titleFont);
  126.         // the title is placed in a gap of the top borderline with no space left
  127.         WORD titlePixLen = 1+TextLength(homeWindow->rp(),title,strlen(title));
  128.         startX = (WORD)NORM_X((LONG)graphicObj->left()+(graphicObj->width()-titlePixLen)/2);
  129.         endX = startX+titlePixLen;
  130.         homeWindow->setDrMd(JAM1);
  131.         homeWindow->setAPen(1);
  132.         homeWindow->moveTx(startX+1,(WORD)NORM_Y(graphicObj->top()+1));
  133.         homeWindow->text((UBYTE*)title);
  134.     }
  135.     else startX = endX = (WORD)NORM_X((LONG)graphicObj->left()+bWidth);
  136.     
  137.     polyTable[0][X] = startX;
  138.     polyTable[0][Y] = (WORD)NORM_Y((LONG)graphicObj->top()+bHeight/2);
  139.     polyTable[1][X] = (WORD)NORM_X((LONG)graphicObj->left()+bWidth/2);
  140.     polyTable[1][Y] = polyTable[0][Y];
  141.     polyTable[2][X] = polyTable[1][X];
  142.     polyTable[2][Y] = (WORD)NORM_Y((LONG)graphicObj->bottom()-bHeight/2);
  143.     homeWindow->setAPen(1);
  144.     homeWindow->polyDraw(3,&polyTable[0][0]);
  145.     polyTable[0][Y]++; polyTable[1][Y]++; polyTable[1][X]++; polyTable[2][X]++;
  146.     homeWindow->setAPen(2);
  147.     homeWindow->polyDraw(3,&polyTable[0][0]);
  148.     
  149.     polyTable[0][X] = polyTable[2][X]+1;
  150.     polyTable[0][Y] = polyTable[2][Y];
  151.     polyTable[1][X] = (WORD)NORM_X((LONG)graphicObj->right()-bWidth/2);
  152.     polyTable[1][Y] = polyTable[0][Y];
  153.     polyTable[2][X] = polyTable[1][X];
  154.     polyTable[2][Y] = (WORD)NORM_Y((LONG)graphicObj->top()+bHeight/2+1);
  155.     homeWindow->polyDraw(3,&polyTable[0][0]);
  156.     homeWindow->setAPen(1);
  157.     polyTable[0][Y]--; polyTable[1][Y]--; polyTable[1][X]--; polyTable[2][X]--;
  158.     homeWindow->polyDraw(3,&polyTable[0][0]);
  159.  
  160.     polyTable[0][X] = polyTable[2][X]+1;
  161.     polyTable[0][Y] = polyTable[2][Y]-1;
  162.     polyTable[1][X] = endX;
  163.     polyTable[1][Y] = polyTable[0][Y];
  164.     homeWindow->polyDraw(2,&polyTable[0][0]);
  165.     polyTable[0][Y]++; polyTable[1][Y]++; 
  166.     homeWindow->setAPen(2);
  167.     homeWindow->polyDraw(2,&polyTable[0][0]);
  168.  
  169.     homeWindow->resetStdClip();
  170. }
  171.