2016-07-31 10:43:49 +02:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* MIT License:
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016 Borja Lorente
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use,
|
|
|
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following
|
|
|
|
* conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-07-29 10:27:30 +02:00
|
|
|
#include "common/system.h"
|
|
|
|
|
2016-07-31 11:16:09 +02:00
|
|
|
#include "graphics/macgui/macwindowborder.h"
|
2016-07-29 10:27:30 +02:00
|
|
|
#include "graphics/macgui/macwindowmanager.h"
|
|
|
|
|
2016-06-02 19:02:32 +02:00
|
|
|
namespace Graphics {
|
|
|
|
|
2016-07-29 10:27:30 +02:00
|
|
|
using namespace Graphics::MacGUIConstants;
|
|
|
|
|
2016-06-03 20:49:54 +02:00
|
|
|
MacWindowBorder::MacWindowBorder() : _activeInitialized(false), _inactiveInitialized(false) {
|
2016-06-02 19:02:32 +02:00
|
|
|
_activeBorder = nullptr;
|
2016-07-29 12:16:08 +02:00
|
|
|
_inactiveBorder = nullptr;
|
|
|
|
_hasOffsets = false;
|
2016-06-02 19:02:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MacWindowBorder::~MacWindowBorder() {
|
|
|
|
if (_activeBorder)
|
|
|
|
delete _activeBorder;
|
|
|
|
if (_inactiveBorder)
|
|
|
|
delete _inactiveBorder;
|
|
|
|
}
|
|
|
|
|
2016-07-29 12:16:08 +02:00
|
|
|
bool MacWindowBorder::hasBorder(bool active) {
|
|
|
|
return active ? _activeInitialized : _inactiveInitialized;
|
2016-06-03 20:49:54 +02:00
|
|
|
}
|
2016-07-29 12:14:19 +02:00
|
|
|
|
2016-08-25 13:03:46 +02:00
|
|
|
void MacWindowBorder::addActiveBorder(TransparentSurface *source) {
|
2016-06-03 20:49:54 +02:00
|
|
|
assert(!_activeBorder);
|
2016-08-25 13:03:46 +02:00
|
|
|
_activeBorder = new NinePatchBitmap(source, true);
|
2016-06-03 20:49:54 +02:00
|
|
|
_activeInitialized = true;
|
2016-06-02 19:02:32 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 13:03:46 +02:00
|
|
|
void MacWindowBorder::addInactiveBorder(TransparentSurface *source) {
|
2016-06-03 20:49:54 +02:00
|
|
|
assert(!_inactiveBorder);
|
2016-08-25 13:03:46 +02:00
|
|
|
_inactiveBorder = new NinePatchBitmap(source, true);
|
2016-06-03 20:49:54 +02:00
|
|
|
_inactiveInitialized = true;
|
2016-06-02 19:02:32 +02:00
|
|
|
}
|
|
|
|
|
2016-07-29 12:16:08 +02:00
|
|
|
bool MacWindowBorder::hasOffsets() {
|
|
|
|
return _hasOffsets;
|
|
|
|
}
|
|
|
|
|
2016-07-29 10:27:30 +02:00
|
|
|
void MacWindowBorder::setOffsets(int left, int right, int top, int bottom) {
|
2016-07-29 12:16:08 +02:00
|
|
|
_borderOffsets[0] = left;
|
|
|
|
_borderOffsets[1] = right;
|
|
|
|
_borderOffsets[2] = top;
|
|
|
|
_borderOffsets[3] = bottom;
|
|
|
|
_hasOffsets = true;
|
|
|
|
}
|
|
|
|
|
2016-07-29 10:27:30 +02:00
|
|
|
int MacWindowBorder::getOffset(MacBorderOffset offset) {
|
2016-07-29 12:16:08 +02:00
|
|
|
return _borderOffsets[offset];
|
|
|
|
}
|
|
|
|
|
2016-06-02 19:02:32 +02:00
|
|
|
void MacWindowBorder::blitBorderInto(ManagedSurface &destination, bool active) {
|
|
|
|
|
|
|
|
TransparentSurface srf;
|
|
|
|
NinePatchBitmap *src = active ? _activeBorder : _inactiveBorder;
|
|
|
|
|
2016-07-29 10:27:30 +02:00
|
|
|
srf.create(destination.w, destination.h, destination.format);
|
|
|
|
srf.fillRect(Common::Rect(0, 0, srf.w, srf.h), kColorGreen2);
|
|
|
|
|
|
|
|
byte palette[kColorCount];
|
|
|
|
g_system->getPaletteManager()->grabPalette(palette, 0, kColorCount);
|
2016-06-02 19:02:32 +02:00
|
|
|
|
2016-07-29 10:27:30 +02:00
|
|
|
src->blit(srf, 0, 0, srf.w, srf.h, palette, kColorCount);
|
|
|
|
destination.transBlitFrom(srf, kColorGreen2);
|
2016-08-25 13:21:42 +02:00
|
|
|
srf.free();
|
2016-06-02 19:02:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Graphics
|