2012-10-27 13:05:00 +00:00
|
|
|
/*
|
|
|
|
ChibiOS/GFX - Copyright (C) 2012
|
|
|
|
Joel Bodenmann aka Tectu <joel@unormal.org>
|
|
|
|
|
|
|
|
This file is part of ChibiOS/GFX.
|
|
|
|
|
|
|
|
ChibiOS/GFX 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
ChibiOS/GFX 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
/**
|
2012-12-06 08:45:54 +00:00
|
|
|
* @file include/gwin/gwin.h
|
2012-10-27 13:05:00 +00:00
|
|
|
* @brief GWIN Graphic window subsystem header file.
|
|
|
|
*
|
2012-12-18 22:15:47 +00:00
|
|
|
* @defgroup Window Window
|
2012-12-18 21:34:22 +00:00
|
|
|
* @ingroup GWIN
|
|
|
|
*
|
2012-12-18 21:49:01 +00:00
|
|
|
* @details GWIN provides a basic window manager which allows it to easily
|
|
|
|
* create and destroy different windows on runtime. Each window
|
|
|
|
* will have it's own properties such as colors, brushes as well as
|
|
|
|
* it's own drawing origin.
|
|
|
|
* Moving the windows around is not supported yet.
|
|
|
|
*
|
|
|
|
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
|
|
|
|
*
|
2012-10-27 13:05:00 +00:00
|
|
|
* @{
|
|
|
|
*/
|
2012-12-18 21:34:22 +00:00
|
|
|
|
2012-10-27 13:05:00 +00:00
|
|
|
#ifndef _GWIN_H
|
|
|
|
#define _GWIN_H
|
|
|
|
|
2012-12-06 08:45:54 +00:00
|
|
|
#include "gfx.h"
|
2012-10-27 13:05:00 +00:00
|
|
|
|
|
|
|
#if GFX_USE_GWIN || defined(__DOXYGEN__)
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Type definitions */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2012-11-26 08:45:26 +00:00
|
|
|
typedef uint16_t GWindowType;
|
|
|
|
#define GW_WINDOW 0x0000
|
|
|
|
#define GW_FIRST_USER_WINDOW 0x8000
|
2012-10-30 08:18:29 +00:00
|
|
|
|
|
|
|
// A basic window
|
|
|
|
typedef struct GWindowObject_t {
|
|
|
|
GWindowType type; // What type of window is this
|
|
|
|
uint16_t flags; // Internal flags
|
|
|
|
coord_t x, y; // Screen relative position
|
|
|
|
coord_t width, height; // Dimensions of this window
|
|
|
|
color_t color, bgcolor; // Current drawing colors
|
2012-10-27 13:05:00 +00:00
|
|
|
#if GDISP_NEED_TEXT
|
2012-10-30 08:18:29 +00:00
|
|
|
font_t font; // Current font
|
|
|
|
#endif
|
|
|
|
} GWindowObject, * GHandle;
|
|
|
|
|
2012-10-27 13:05:00 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* External declarations. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Base Functions */
|
2012-10-30 08:18:29 +00:00
|
|
|
GHandle gwinCreateWindow(GWindowObject *gw, coord_t x, coord_t y, coord_t width, coord_t height);
|
|
|
|
void gwinDestroyWindow(GHandle gh);
|
2012-10-27 13:05:00 +00:00
|
|
|
|
2012-11-20 22:12:09 +00:00
|
|
|
/**
|
|
|
|
* @brief Get the X coordinate of the window
|
|
|
|
* @details Returns the X coordinate of the origin of the window.
|
|
|
|
* The coordinate is relative to the physical screen zero point.
|
|
|
|
*
|
|
|
|
* @param[in] gh The window
|
|
|
|
*/
|
2012-10-30 08:18:29 +00:00
|
|
|
#define gwinGetScreenX(gh) ((gh)->x)
|
2012-11-20 22:12:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the Y coordinate of the window
|
|
|
|
* @details Returns the Y coordinate of the origin of the window.
|
|
|
|
* The coordinate is relative to the physical screen zero point.
|
|
|
|
*
|
|
|
|
* @param[in] gh The window
|
|
|
|
*/
|
2012-10-30 08:18:29 +00:00
|
|
|
#define gwinGetScreenY(gh) ((gh)->y)
|
2012-11-20 22:12:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the width of the window
|
|
|
|
*
|
|
|
|
* @param[in] gh The window
|
|
|
|
*/
|
2012-10-30 08:18:29 +00:00
|
|
|
#define gwinGetWidth(gh) ((gh)->width)
|
2012-11-20 22:12:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the height of the window
|
|
|
|
*
|
|
|
|
* @param[in] gh The window
|
|
|
|
*/
|
2012-10-30 08:18:29 +00:00
|
|
|
#define gwinGetHeight(gh) ((gh)->height)
|
2012-10-27 13:05:00 +00:00
|
|
|
|
2012-11-20 22:12:09 +00:00
|
|
|
/**
|
|
|
|
* @brief Set foreground color
|
|
|
|
* @details Set the color which will be used to draw
|
|
|
|
*
|
|
|
|
* @param[in] gh The window
|
|
|
|
* @param[in] clr The color to be set
|
|
|
|
*/
|
2012-10-30 08:18:29 +00:00
|
|
|
#define gwinSetColor(gh, clr) (gh)->color = (clr)
|
2012-11-20 22:12:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set background color
|
|
|
|
* @details Set the color which will be used as background
|
|
|
|
* @note gwinClear() must be called to set the background color
|
|
|
|
*
|
|
|
|
* @param[in] gh The window
|
|
|
|
* @param[in] bgclr The background color
|
|
|
|
*/
|
2012-10-30 08:18:29 +00:00
|
|
|
#define gwinSetBgColor(gh, bgclr) (gh)->bgcolor = (bgclr)
|
2012-10-27 13:05:00 +00:00
|
|
|
|
|
|
|
/* Set up for text */
|
|
|
|
#if GDISP_NEED_TEXT
|
2012-12-06 08:45:54 +00:00
|
|
|
void gwinSetFont(GHandle gh, font_t font);
|
2012-10-27 13:05:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Drawing Functions */
|
2012-10-30 08:18:29 +00:00
|
|
|
void gwinClear(GHandle gh);
|
|
|
|
void gwinDrawPixel(GHandle gh, coord_t x, coord_t y);
|
|
|
|
void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1);
|
|
|
|
void gwinDrawBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy);
|
|
|
|
void gwinFillArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy);
|
|
|
|
void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer);
|
2012-10-27 13:05:00 +00:00
|
|
|
|
|
|
|
/* Circle Functions */
|
|
|
|
#if GDISP_NEED_CIRCLE
|
2012-11-26 08:45:26 +00:00
|
|
|
void gwinDrawCircle(GHandle gh, coord_t x, coord_t y, coord_t radius);
|
|
|
|
void gwinFillCircle(GHandle gh, coord_t x, coord_t y, coord_t radius);
|
2012-10-27 13:05:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Ellipse Functions */
|
|
|
|
#if GDISP_NEED_ELLIPSE
|
2012-11-26 08:45:26 +00:00
|
|
|
void gwinDrawEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b);
|
|
|
|
void gwinFillEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b);
|
2012-10-27 13:05:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Arc Functions */
|
|
|
|
#if GDISP_NEED_ARC
|
2012-11-26 08:45:26 +00:00
|
|
|
void gwinDrawArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle);
|
|
|
|
void gwinFillArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle);
|
2012-10-27 13:05:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Read a pixel Function */
|
|
|
|
#if GDISP_NEED_PIXELREAD
|
2012-11-26 08:45:26 +00:00
|
|
|
color_t gwinGetPixelColor(GHandle gh, coord_t x, coord_t y);
|
2012-10-27 13:05:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Extra Text Functions */
|
|
|
|
#if GDISP_NEED_TEXT
|
2012-11-26 08:45:26 +00:00
|
|
|
void gwinDrawChar(GHandle gh, coord_t x, coord_t y, char c);
|
|
|
|
void gwinFillChar(GHandle gh, coord_t x, coord_t y, char c);
|
|
|
|
void gwinDrawString(GHandle gh, coord_t x, coord_t y, const char *str);
|
|
|
|
void gwinFillString(GHandle gh, coord_t x, coord_t y, const char *str);
|
|
|
|
void gwinDrawStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify);
|
|
|
|
void gwinFillStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify);
|
2012-10-27 13:05:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-11-26 08:45:26 +00:00
|
|
|
/* Include extra window types */
|
2012-12-06 08:45:54 +00:00
|
|
|
#include "gwin/console.h"
|
|
|
|
#include "gwin/button.h"
|
|
|
|
#include "gwin/graph.h"
|
2012-11-26 08:45:26 +00:00
|
|
|
|
2012-10-27 13:05:00 +00:00
|
|
|
#endif /* GFX_USE_GWIN */
|
|
|
|
|
|
|
|
#endif /* _GWIN_H */
|
|
|
|
/** @} */
|