home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xhyper10.zip / XHyper_v1.0 / src / docsup / PageBorder.c < prev    next >
C/C++ Source or Header  |  1992-12-08  |  3KB  |  70 lines

  1. /*
  2.  * Copyright (c) 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * PageBorder - a fancy Border
  25.  */
  26.  
  27. #include "PageBorder.h"
  28.  
  29. #include <InterViews/canvas.h>
  30. #include <InterViews/color.h>
  31.  
  32. PageBorder::PageBorder(Glyph* body, const Color* c) : MonoGlyph(body) {
  33.     color_ = c;
  34.     Resource::ref(color_);
  35. }
  36.  
  37. PageBorder::~PageBorder() {
  38.     Resource::unref(color_);
  39. }
  40.  
  41. void PageBorder::draw(Canvas* c, const Allocation& a) const {
  42.     MonoGlyph::draw(c, a);
  43.     if (c != nil) {
  44.         Coord left = a.left();
  45.         Coord bottom = a.bottom();
  46.         Coord right = a.right();
  47.         Coord top = a.top();
  48.         if (c->damaged(left, bottom + 5, left + 1, top)) {
  49.             c->fill_rect(left + 1, bottom + 5, left, top, color_);
  50.         }
  51.         if (c->damaged(left + 1, top - 1, right - 4, top)) {
  52.             c->fill_rect(left + 1, top - 1, right - 4, top, color_);
  53.         }
  54.         if (c->damaged(right - 5, bottom, right, top - 1)) {
  55.             c->fill_rect(right - 5, top - 1, right - 4, bottom + 4, color_);
  56.             c->fill_rect(right - 4, top - 3, right - 2, top - 2, color_);
  57.             c->fill_rect(right - 3, top - 3, right - 2, bottom + 2, color_);
  58.             c->fill_rect(right - 2, top - 5, right, top - 4, color_);
  59.             c->fill_rect(right - 1, top - 5, right, bottom, color_);
  60.         }
  61.         if (c->damaged(left, bottom, right - 1, bottom + 5)) {
  62.             c->fill_rect(right - 5, bottom + 5, left, bottom + 4, color_);
  63.             c->fill_rect(right - 3, bottom + 3, left + 2, bottom + 2, color_);
  64.             c->fill_rect(left + 3, bottom + 3, left + 2, bottom + 4, color_);
  65.             c->fill_rect(right - 1, bottom + 1, left + 4, bottom, color_);
  66.             c->fill_rect(left + 5, bottom + 1, left + 4, bottom + 2, color_);
  67.         }
  68.     }
  69. }
  70.