diff options
Diffstat (limited to 'graphics/macgui/macwindow.cpp')
-rw-r--r-- | graphics/macgui/macwindow.cpp | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp index dbb600ba82..2a6e191ded 100644 --- a/graphics/macgui/macwindow.cpp +++ b/graphics/macgui/macwindow.cpp @@ -8,41 +8,16 @@ * 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) 2009 Alexei Svitkine, Eugene Sandulenko - * - * 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. - * */ #include "graphics/font.h" @@ -69,6 +44,9 @@ MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, Mac _active = false; _borderIsDirty = true; + _pattern = 0; + _hasPattern = false; + _highlightedPart = kBorderNone; _scrollPos = _scrollSize = 0.0; @@ -108,6 +86,10 @@ void MacWindow::resize(int w, int h) { _surface.free(); _surface.create(w, h, PixelFormat::createFormatCLUT8()); + + if (_hasPattern) + drawPattern(); + _borderSurface.free(); _borderSurface.create(w, h, PixelFormat::createFormatCLUT8()); _composeSurface.free(); @@ -140,6 +122,13 @@ void MacWindow::setDimensions(const Common::Rect &r) { _contentIsDirty = true; } +void MacWindow::setBackgroundPattern(int pattern) { + _pattern = pattern; + _hasPattern = true; + drawPattern(); + _contentIsDirty = true; +} + bool MacWindow::draw(ManagedSurface *g, bool forceRedraw) { if (!_borderIsDirty && !_contentIsDirty && !forceRedraw) return false; @@ -298,6 +287,19 @@ void MacWindow::drawSimpleBorder(ManagedSurface *g) { } } +void MacWindow::drawPattern() { + byte *pat = _wm->getPatterns()[_pattern - 1]; + for (int y = 0; y < _surface.h; y++) { + for (int x = 0; x < _surface.w; x++) { + byte *dst = (byte *)_surface.getBasePtr(x, y); + if (pat[y % 8] & (1 << (7 - (x % 8)))) + *dst = kColorBlack; + else + *dst = kColorWhite; + } + } +} + void MacWindow::setHighlight(WindowClick highlightedPart) { if (_highlightedPart == highlightedPart) return; @@ -317,26 +319,27 @@ void MacWindow::setScroll(float scrollPos, float scrollSize) { void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo, int ro, int to, int bo) { Image::BitmapDecoder bmpDecoder; - Graphics::Surface source; + Graphics::Surface *source; Graphics::TransparentSurface *surface = new Graphics::TransparentSurface(); bmpDecoder.loadStream(file); - source = *(bmpDecoder.getSurface()); + source = bmpDecoder.getSurface()->convertTo(surface->getSupportedPixelFormat(), bmpDecoder.getPalette()); - source.convertToInPlace(surface->getSupportedPixelFormat(), bmpDecoder.getPalette()); - surface->create(source.w, source.h, source.format); - surface->copyFrom(source); + surface->create(source->w, source->h, surface->getSupportedPixelFormat()); + surface->copyFrom(*source); surface->applyColorKey(255, 0, 255, false); if (active) - _macBorder.addActiveBorder(*surface); + _macBorder.addActiveBorder(surface); else - _macBorder.addInactiveBorder(*surface); + _macBorder.addInactiveBorder(surface); if (!_macBorder.hasOffsets()) _macBorder.setOffsets(lo, ro, to, bo); updateInnerDims(); + source->free(); + delete source; } void MacWindow::setCloseable(bool closeable) { |