view libclient/malikania/theme.hpp @ 70:58444cf5f227

Client: add minimalist label
author David Demelier <markand@malikania.fr>
date Mon, 19 Dec 2016 13:12:32 +0100
parents 4bc4732fa1dd
children 858621081b95
line wrap: on
line source

/*
 * theme.hpp -- theming support for gui elements
 *
 * Copyright (c) 2013-2016 Malikania Authors
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef MALIKANIA_CLIENT_THEME_HPP
#define MALIKANIA_CLIENT_THEME_HPP

/**
 * \file theme.hpp
 * \brief Theming support for gui elements.
 */

#include "color.hpp"
#include "font.hpp"
#include "size.hpp"

namespace mlk {

class button;
class frame;
class label;
class rectangle;
class point;
class window;

/**
 * \brief Reimplement this class to provide your own theme.
 */
class theme {
private:
    font m_font;
    color m_background_color;
    color m_border_color;
    color m_text_color;
    size m_frame_padding;

public:
    /**
     * Default constructor.
     */
    theme();

    /**
     * Virtual destructor defaulted.
     */
    virtual ~theme() noexcept = default;

    inline const color& background_color() const noexcept
    {
        return m_background_color;
    }

    inline const color& border_color() const noexcept
    {
        return m_border_color;
    }

    inline const color& text_color() const noexcept
    {
        return m_text_color;
    }

    /**
     * Get the required bounding rectangle size for this button.
     *
     * \param b the button
     * \return the size
     */
    virtual size size_button(const button& b);

    /**
     * Get the required bouding rectangle size for this label.
     *
     * \param l the label
     * \return the size
     */
    virtual size size_label(const label& l);

    /**
     * Draw the frame.
     *
     * \param w the main window
     * \param f the frame
     */
    virtual void draw_frame(window& w, const frame& f);

    /**
     * Draw a button.
     *
     * \param w the main window
     * \param b the button
     */
    virtual void draw_button(window& w, const button& b, const rectangle& rect);

    /**
     * Draw a label.
     *
     * \param w the main window
     * \param l the label
     * \param rect the bounding rectangle.
     */
    virtual void draw_label(window& w, const label& l, const rectangle& rect);
};

} // !mlk

#endif // !MALIKANIA_CLIENT_THEME_HPP