00001 /* 00002 * The Mana World 00003 * Copyright (C) 2004 The Mana World Development Team 00004 * 00005 * This file is part of The Mana World. 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 #include "gui/widgets/resizegrip.h" 00023 00024 #include "configuration.h" 00025 #include "graphics.h" 00026 00027 #include "resources/image.h" 00028 #include "resources/resourcemanager.h" 00029 00030 #include <guichan/graphics.hpp> 00031 00032 Image *ResizeGrip::gripImage = 0; 00033 int ResizeGrip::mInstances = 0; 00034 float ResizeGrip::mAlpha = 1.0; 00035 00036 ResizeGrip::ResizeGrip(const std::string &image) 00037 { 00038 if (mInstances == 0) 00039 { 00040 // Load the grip image 00041 ResourceManager *resman = ResourceManager::getInstance(); 00042 gripImage = resman->getImage(image); 00043 gripImage->setAlpha(mAlpha); 00044 } 00045 00046 mInstances++; 00047 00048 setWidth(gripImage->getWidth() + 2); 00049 setHeight(gripImage->getHeight() + 2); 00050 } 00051 00052 ResizeGrip::~ResizeGrip() 00053 { 00054 mInstances--; 00055 00056 if (mInstances == 0) 00057 gripImage->decRef(); 00058 } 00059 00060 void ResizeGrip::draw(gcn::Graphics *graphics) 00061 { 00062 if (config.getValue("guialpha", 0.8) != mAlpha) 00063 { 00064 mAlpha = config.getValue("guialpha", 0.8); 00065 gripImage->setAlpha(mAlpha); 00066 } 00067 00068 static_cast<Graphics*>(graphics)->drawImage(gripImage, 0, 0); 00069 }