#include "Border.h" #include "Image.h" #include "Point.h" #include "Scroll.h" #include "Text.h" #include "ToolTip.h" using namespace Framework; // Contents of the Border class from Border.h // Constructor Border::Border() : Drawable(), br(1), farbe(0xFF000000), alpha(0), breaks(0) {} // Destructor Border::~Border() {} // non-constant void Border::setRamenBreite(int br) // sets the width of the border { this->br = br; rend = 1; } // when this flag is set, the border is drawn dashed // br: 1 -> dashed, 0 -> solid void Border::setBreaks(bool br, int brOff, int brLength, int lineLength) { breaks = br; breakOffset = brOff; breakLength = brLength; this->lineLength = lineLength; rend = 1; } void Border::setAlpha( bool a) // Sets whether the alpha value of the color should be considered { alpha = a; rend = 1; } void Border::setFarbe(int f) // Sets the color of the border { farbe = f; rend = 1; } int Border::getFarbe() const // Returns the color of the border { return farbe; } bool Border::hatAlpha() const // Returns whether the alpha value of the color is considered { return alpha; } int Border::getRBreite() const // Returns the width of the border { return br; } // Returns 1 if the border is drawn dashed bool Border::hasBreaks() const { return breaks; } // starting point of the first line segment int Border::getBreakOffset() const { return breakOffset; } // length of a gap int Border::getBreakLength() const { return breakLength; } // length of a line int Border::getLineLength() const { return lineLength; } // Contents of the LBorder class from Border.h // Constructor LBorder::LBorder() : Border() {} // Destructor LBorder::~LBorder() {} void LBorder::render(Image& Obj) // Draws the border into the render object { Drawable::render(Obj); int x = 0; int y = 0; int b = gr.x - 1; int h = gr.y - 1; if (!Obj.setDrawOptions(pos.x, pos.y, gr.x, gr.y)) return; if (!breaks) { if (alpha) { for (int i = 0; i < br; ++i) { Obj.drawLinieHAlpha(x + i + 1, y + i, gr.x - i * 2 - 1, farbe); Obj.drawLinieVAlpha(b - i, y + i + 1, gr.y - i * 2 - 2, farbe); Obj.drawLinieHAlpha(x + i + 1, h - i, gr.x - i * 2 - 1, farbe); Obj.drawLinieVAlpha(x + i, y + i, gr.y - i * 2, farbe); } } else { for (int i = 0; i < br; ++i) { Obj.drawLinieH(x + i + 1, y + i, gr.x - i * 2 - 1, farbe); Obj.drawLinieV(b - i, y + i + 1, gr.y - i * 2 - 2, farbe); Obj.drawLinieH(x + i + 1, h - i, gr.x - i * 2 - 1, farbe); Obj.drawLinieV(x + i, y + i, gr.y - i * 2, farbe); } } } else { if (alpha) { for (int i = 0; i < br; ++i) { for (int x = breakOffset; x < gr.x; x += lineLength + breakLength) Obj.drawLinieHAlpha(x + i + 1, y + i, lineLength - (x + i + 1 + lineLength > gr.x - i - 1 ? gr.x - i - 1 - (x + i + 1 + lineLength) : 0), farbe); for (int x = gr.x - breakOffset - lineLength; x >= 0; x -= lineLength + breakLength) Obj.drawLinieHAlpha(MAX(x + i + 1, i + 1), h - i, lineLength - (x + i + 1 < i + 1 ? i + 1 - (x + i + 1) : 0), farbe); for (int y = breakOffset; y < gr.y; y += lineLength + breakLength) Obj.drawLinieVAlpha(b - i, y + i + 1, lineLength - (y + i + 1 + lineLength > gr.y - i - 1 ? gr.y - i - 1 - (y + i + 1 + lineLength) : 0), farbe); for (int y = gr.y - breakOffset - lineLength; y >= 0; y -= lineLength + breakLength) Obj.drawLinieVAlpha(x + i, MAX(y + i, i), lineLength - (y + i < i ? i - (y + i) : 0), farbe); } } else { for (int i = 0; i < br; ++i) { for (int x = breakOffset; x < gr.x; x += lineLength + breakLength) Obj.drawLinieH(x + i + 1, y + i, lineLength - (x + i + 1 + lineLength > gr.x - i - 1 ? gr.x - i - 1 - (x + i + 1 + lineLength) : 0), farbe); for (int x = gr.x - breakOffset - lineLength; x >= 0; x -= lineLength + breakLength) Obj.drawLinieH(MAX(x + i + 1, i + 1), h - i, lineLength - (x + i + 1 < i + 1 ? i + 1 - (x + i + 1) : 0), farbe); for (int y = breakOffset; y < gr.y; y += lineLength + breakLength) Obj.drawLinieV(b - i, y + i + 1, lineLength - (y + i + 1 + lineLength > gr.y - i - 1 ? gr.y - i - 1 - (y + i + 1 + lineLength) : 0), farbe); for (int y = gr.y - breakOffset - lineLength; y >= 0; y -= lineLength + breakLength) Obj.drawLinieV(x + i, MAX(y + i, i), lineLength - (y + i < i ? i - (y + i) : 0), farbe); } } } Obj.releaseDrawOptions(); } Drawable* LBorder::dublizieren() const // Copies the drawing { Border* obj = new LBorder(); obj->setPosition(pos); obj->setSize(gr); obj->setMouseEventParameter(makParam); obj->setKeyboardEventParameter(takParam); obj->setMouseEvent(mak); obj->setKeyboardEvent(tak); if (toolTip) obj->setToolTipZ((ToolTip*)toolTip->dublizieren()); obj->setBreaks(breaks); obj->setAlpha(alpha); obj->setFarbe(farbe); obj->setRamenBreite(br); return obj; } // Contents of the Border3D class from Border.h // Constructor Border3D::Border3D() : Border() { alpha = 1; farbe = 0x70FFFFFF; br = 5; } // Destructor Border3D::~Border3D() {} void Border3D::render(Image& Obj) // Draws the border into the render object { Drawable::render(Obj); int x = 0; int y = 0; int b = gr.x - 1; int h = gr.y - 1; int fcomp = (farbe & 0xFF000000) | (~farbe & 0x00FFFFFF); if (!Obj.setDrawOptions(pos.x, pos.y, gr.x, gr.y)) return; if (!breaks) { if (alpha) { for (int i = 0; i < br; ++i) { Obj.drawLinieHAlpha(x + i + 1, y + i, gr.x - i * 2 - 1, farbe); Obj.drawLinieVAlpha(b - i, y + i + 1, gr.y - i * 2 - 2, farbe); Obj.drawLinieHAlpha(x + i + 1, h - i, gr.x - i * 2 - 1, fcomp); Obj.drawLinieVAlpha(x + i, y + i, gr.y - i * 2, fcomp); } } else { for (int i = 0; i < br; ++i) { Obj.drawLinieH(x + i + 1, y + i, gr.x - i * 2 - 1, farbe); Obj.drawLinieV(b - i, y + i + 1, gr.y - i * 2 - 2, farbe); Obj.drawLinieH(x + i + 1, h - i, gr.x - i * 2 - 1, fcomp); Obj.drawLinieV(x + i, y + i, gr.y - i * 2, fcomp); } } } else { if (alpha) { for (int i = 0; i < br; ++i) { for (int x = breakOffset; x < gr.x; x += lineLength + breakLength) Obj.drawLinieHAlpha(x + i + 1, y + i, lineLength - (x + i + 1 + lineLength > gr.x - i - 1 ? gr.x - i - 1 - (x + i + 1 + lineLength) : 0), farbe); for (int x = gr.x - breakOffset - lineLength; x >= 0; x -= lineLength + breakLength) Obj.drawLinieHAlpha(MAX(x + i + 1, i + 1), h - i, lineLength - (x + i + 1 < i + 1 ? i + 1 - (x + i + 1) : 0), fcomp); for (int y = breakOffset; y < gr.y; y += lineLength + breakLength) Obj.drawLinieVAlpha(b - i, y + i + 1, lineLength - (y + i + 1 + lineLength > gr.y - i - 1 ? gr.y - i - 1 - (y + i + 1 + lineLength) : 0), farbe); for (int y = gr.y - breakOffset - lineLength; y >= 0; y -= lineLength + breakLength) Obj.drawLinieVAlpha(x + i, MAX(y + i, i), lineLength - (y + i < i ? i - (y + i) : 0), fcomp); } } else { for (int i = 0; i < br; ++i) { for (int x = breakOffset; x < gr.x; x += lineLength + breakLength) Obj.drawLinieH(x + i + 1, y + i, lineLength - (x + i + 1 + lineLength > gr.x - i - 1 ? gr.x - i - 1 - (x + i + 1 + lineLength) : 0), farbe); for (int x = gr.x - breakOffset - lineLength; x >= 0; x -= lineLength + breakLength) Obj.drawLinieH(MAX(x + i + 1, i + 1), h - i, lineLength - (x + i + 1 < i + 1 ? i + 1 - (x + i + 1) : 0), fcomp); for (int y = breakOffset; y < gr.y; y += lineLength + breakLength) Obj.drawLinieV(b - i, y + i + 1, lineLength - (y + i + 1 + lineLength > gr.y - i - 1 ? gr.y - i - 1 - (y + i + 1 + lineLength) : 0), farbe); for (int y = gr.y - breakOffset - lineLength; y >= 0; y -= lineLength + breakLength) Obj.drawLinieV(x + i, MAX(y + i, i), lineLength - (y + i < i ? i - (y + i) : 0), fcomp); } } } Obj.releaseDrawOptions(); } Drawable* Border3D::dublizieren() const // Copies the drawing { Border* obj = new Border3D(); obj->setPosition(pos); obj->setSize(gr); obj->setMouseEventParameter(makParam); obj->setKeyboardEventParameter(takParam); obj->setMouseEvent(mak); obj->setKeyboardEvent(tak); if (toolTip) obj->setToolTipZ((ToolTip*)toolTip->dublizieren()); obj->setBreaks(breaks); obj->setAlpha(alpha); obj->setFarbe(farbe); obj->setRamenBreite(br); return obj; }