/* * Copyright (c) 2018-2020, Andreas Kling * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include namespace WindowServer { static const int window_titlebar_height = 19; static const char* s_close_button_bitmap_data = { "## ##" "### ###" " ###### " " #### " " ## " " #### " " ###### " "### ###" "## ##" }; static Gfx::CharacterBitmap* s_close_button_bitmap; static const int s_close_button_bitmap_width = 8; static const int s_close_button_bitmap_height = 9; static const char* s_minimize_button_bitmap_data = { " " " " " " " ###### " " #### " " ## " " " " " " " }; static Gfx::CharacterBitmap* s_minimize_button_bitmap; static const int s_minimize_button_bitmap_width = 8; static const int s_minimize_button_bitmap_height = 9; static const char* s_maximize_button_bitmap_data = { " " " " " " " ## " " #### " " ###### " " " " " " " }; static Gfx::CharacterBitmap* s_maximize_button_bitmap; static const int s_maximize_button_bitmap_width = 8; static const int s_maximize_button_bitmap_height = 9; static const char* s_unmaximize_button_bitmap_data = { " " " ## " " #### " " ###### " " " " ###### " " #### " " ## " " " }; static Gfx::CharacterBitmap* s_unmaximize_button_bitmap; static const int s_unmaximize_button_bitmap_width = 8; static const int s_unmaximize_button_bitmap_height = 9; WindowFrame::WindowFrame(Window& window) : m_window(window) { if (!s_close_button_bitmap) s_close_button_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_close_button_bitmap_data, s_close_button_bitmap_width, s_close_button_bitmap_height).leak_ref(); if (!s_minimize_button_bitmap) s_minimize_button_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_minimize_button_bitmap_data, s_minimize_button_bitmap_width, s_minimize_button_bitmap_height).leak_ref(); if (!s_maximize_button_bitmap) s_maximize_button_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_maximize_button_bitmap_data, s_maximize_button_bitmap_width, s_maximize_button_bitmap_height).leak_ref(); if (!s_unmaximize_button_bitmap) s_unmaximize_button_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_unmaximize_button_bitmap_data, s_unmaximize_button_bitmap_width, s_unmaximize_button_bitmap_height).leak_ref(); m_buttons.append(make