/* _______ __ __ __ ______ __ __ _______ __ __ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ * * Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson * * Js_./ * Per Larsson a.k.a finalman _RqZ{a<^_aa * Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a// * _Qhm`] _f "'c 1!5m * Visit: http://guichan.darkbits.org )Qk

ws?a-?' ._/L #' * binary forms, with or without )4d[#7r, . ' )d`)[ * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' * that the following conditions are met: j<. a J@\ * this list of conditions and the j(]1uw, mTarget->h)); } void AllegroGraphics::_endDraw() { // pop the clip area pushed in _beginDraw popClipArea(); } bool AllegroGraphics::pushClipArea(Rectangle area) { bool result = Graphics::pushClipArea(area); ClipRectangle cr = mClipStack.top(); // Allegro won't let you set clip areas // that have zero width or height // so we have to check for that. if (cr.width == 0 || cr.height == 0) { mClipNull = true; } else { mClipNull = false; #if ALLEGRO_VERSION == 4 && ALLEGRO_SUB_VERSION == 0 set_clip(mTarget, cr.x, cr.y, cr.x + cr.width - 1, cr.y + cr.height - 1); #else set_clip_rect(mTarget, cr.x, cr.y, cr.x + cr.width - 1, cr.y + cr.height - 1); #endif } return result; } void AllegroGraphics::popClipArea() { Graphics::popClipArea(); if (mClipStack.empty()) { return; } ClipRectangle cr = mClipStack.top(); // Allegro won't let you set clip areas //that have zero width or height // so we have to check for that. if (cr.width == 0 || cr.height == 0) { mClipNull = true; } else { mClipNull = false; #if ALLEGRO_VERSION == 4 && ALLEGRO_SUB_VERSION == 0 set_clip(mTarget, cr.x, cr.y, cr.x + cr.width - 1, cr.y + cr.height - 1); #else set_clip_rect(mTarget, cr.x, cr.y, cr.x + cr.width - 1, cr.y + cr.height - 1); #endif } } void AllegroGraphics::drawImage(const Image* image, int srcX, int srcY, int dstX, int dstY, int width, int height) { if (mClipNull) { return; } dstX += mClipStack.top().xOffset; dstY += mClipStack.top().yOffset; const AllegroImage* srcImage = dynamic_cast(image); if (srcImage == NULL) { throw GCN_EXCEPTION("Trying to draw an image of unknown format, must be an AllegroImage."); } masked_blit(srcImage->getBitmap(), mTarget, srcX, srcY, dstX, dstY, width, height); } void AllegroGraphics::drawPoint(int x, int y) { if (mClipNull) { return; } int xOffset = mClipStack.top().xOffset; int yOffset = mClipStack.top().yOffset; putpixel(mTarget, x + xOffset, y + yOffset, mAlColor); } void AllegroGraphics::drawLine(int x1, int y1, int x2, int y2) { if (mClipNull) { return; } int xOffset = mClipStack.top().xOffset; int yOffset = mClipStack.top().yOffset; line(mTarget, x1 + xOffset, y1 + yOffset, x2 + xOffset, y2 + yOffset, mAlColor); } void AllegroGraphics::drawRectangle(const Rectangle& rectangle) { if (mClipNull) { return; } int xOffset = mClipStack.top().xOffset; int yOffset = mClipStack.top().yOffset; rect(mTarget, rectangle.x + xOffset, rectangle.y + yOffset, rectangle.x + rectangle.width - 1 + xOffset, rectangle.y + rectangle.height - 1 + yOffset, mAlColor); } void AllegroGraphics::fillRectangle(const Rectangle& rectangle) { if (mClipNull) { return; } int xOffset = mClipStack.top().xOffset; int yOffset = mClipStack.top().yOffset; rectfill(mTarget, rectangle.x + xOffset, rectangle.y + yOffset, rectangle.x + rectangle.width - 1 + xOffset, rectangle.y + rectangle.height - 1 + yOffset, mAlColor); } void AllegroGraphics::setColor(const Color& color) { mColor = color; mAlColor = makecol(color.r, color.g, color.b); if (color.a != 255) { set_trans_blender(255, 255, 255, color.a); drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); } else { solid_mode(); } } const Color& AllegroGraphics::getColor() { return mColor; } }