Added ability to compile ugfx as a single file (excluding driver and board files).

Simply compile src/gfx_mk.c
This commit is contained in:
inmarket 2015-06-08 14:14:40 +10:00
parent e850c344b8
commit ccde54722f
47 changed files with 578 additions and 322 deletions

30
gfx.mk
View File

@ -4,20 +4,24 @@
# http://ugfx.org/license.html
GFXINC += $(GFXLIB)
GFXSRC += $(GFXLIB)/src/gfx.c
include $(GFXLIB)/src/gos/gos.mk
include $(GFXLIB)/src/gdriver/gdriver.mk
include $(GFXLIB)/src/gqueue/gqueue.mk
include $(GFXLIB)/src/gdisp/gdisp.mk
include $(GFXLIB)/src/gevent/gevent.mk
include $(GFXLIB)/src/gtimer/gtimer.mk
include $(GFXLIB)/src/gwin/gwin.mk
include $(GFXLIB)/src/ginput/ginput.mk
include $(GFXLIB)/src/gadc/gadc.mk
include $(GFXLIB)/src/gaudio/gaudio.mk
include $(GFXLIB)/src/gmisc/gmisc.mk
include $(GFXLIB)/src/gfile/gfile.mk
ifeq ($(GFXSINGLEMAKE),yes)
GFXSRC += $(GFXLIB)/src/gfx_mk.c
else
GFXSRC += $(GFXLIB)/src/gfx.c
include $(GFXLIB)/src/gos/gos.mk
include $(GFXLIB)/src/gdriver/gdriver.mk
include $(GFXLIB)/src/gqueue/gqueue.mk
include $(GFXLIB)/src/gdisp/gdisp.mk
include $(GFXLIB)/src/gevent/gevent.mk
include $(GFXLIB)/src/gtimer/gtimer.mk
include $(GFXLIB)/src/gwin/gwin.mk
include $(GFXLIB)/src/ginput/ginput.mk
include $(GFXLIB)/src/gadc/gadc.mk
include $(GFXLIB)/src/gaudio/gaudio.mk
include $(GFXLIB)/src/gmisc/gmisc.mk
include $(GFXLIB)/src/gfile/gfile.mk
endif
# Include the boards and drivers
ifneq ($(GFXBOARD),)

8
src/gadc/gadc_mk.c Normal file
View File

@ -0,0 +1,8 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "gadc.c"

8
src/gaudio/gaudio_mk.c Normal file
View File

@ -0,0 +1,8 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "gaudio.c"

View File

@ -65,7 +65,7 @@ build fixed_10x20.bdf fixed_10x20 bwfont
build fixed_7x14.bdf fixed_7x14 bwfont
build fixed_5x8.bdf fixed_5x8 bwfont
echo '#include "gfx.h"' > fonts.h
echo '// This file is generated by build_fonts.sh' > fonts.h
for file in *.c; do
echo >> fonts.h
noext="${file%.*}"

View File

@ -1,4 +1,4 @@
#include "gfx.h"
// This file is generated by build_fonts.sh
#if defined(GDISP_INCLUDE_FONT_DEJAVUSANS10) && GDISP_INCLUDE_FONT_DEJAVUSANS10
#define GDISP_FONT_FOUND

View File

@ -0,0 +1,15 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
/* This is a stub file to prevent having to include the mcufont
* directory in the include path for funny compilers such as arduino
* which don't support a user specified include path.
*
* It is not needed anyway as the files are already included.
*
* New versions of the font generator do not generate these include lines.
*/

View File

@ -0,0 +1,15 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
/* This is a stub file to prevent having to include the mcufont
* directory in the include path for funny compilers such as arduino
* which don't support a user specified include path.
*
* It is not needed anyway as the files are already included.
*
* New versions of the font generator do not generate these include lines.
*/

View File

@ -0,0 +1,15 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
/* This is a stub file to prevent having to include the mcufont
* directory in the include path for funny compilers such as arduino
* which don't support a user specified include path.
*
* It is not needed anyway as the files are already included.
*
* New versions of the font generator do not generate these include lines.
*/

View File

@ -501,7 +501,7 @@ static void line_clip(GDisplay *g) {
}
#if GDISP_STARTUP_LOGO_TIMEOUT > 0
static bool_t initDone;
static bool_t gdispInitDone;
static void StartupLogoDisplay(GDisplay *g) {
coord_t x, y, w;
const coord_t * p;
@ -604,7 +604,7 @@ void _gdispInit(void)
#endif
}
initDone = TRUE;
gdispInitDone = TRUE;
}
#endif
@ -660,7 +660,7 @@ void _gdispPostInitDriver(GDriver *g) {
// Display the startup logo if this is a static initialised display
#if GDISP_STARTUP_LOGO_TIMEOUT > 0
if (!initDone)
if (!gdispInitDone)
StartupLogoDisplay(gd);
#endif

View File

@ -15,5 +15,5 @@ GFXSRC += $(GFXLIB)/src/gdisp/gdisp.c \
MFDIR = $(GFXLIB)/src/gdisp/mcufont
include $(GFXLIB)/src/gdisp/mcufont/mcufont.mk
GFXINC += $(MFDIR)
#GFXINC += $(MFDIR)
GFXSRC += $(MFSRC)

29
src/gdisp/gdisp_mk.c Normal file
View File

@ -0,0 +1,29 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
/* The very first thing that has to be compiled here is mf_font.c so that
* inclusion of the font header files does not stop the inclusion of the
* implementation specific parts of the font files.
*/
#include "mcufont/mf_font.c"
#include "mcufont/mf_rlefont.c"
#include "mcufont/mf_bwfont.c"
#include "mcufont/mf_scaledfont.c"
#include "mcufont/mf_encoding.c"
#include "mcufont/mf_justify.c"
#include "mcufont/mf_kerning.c"
#include "mcufont/mf_wordwrap.c"
#include "gdisp.c"
#include "gdisp_fonts.c"
#include "gdisp_pixmap.c"
#include "gdisp_image.c"
#include "gdisp_image_native.c"
#include "gdisp_image_gif.c"
#include "gdisp_image_bmp.c"
#include "gdisp_image_jpg.c"
#include "gdisp_image_png.c"

View File

@ -73,12 +73,12 @@ struct mf_bwfont_s
/* Internal functions, don't use these directly. */
MF_EXTERN uint8_t mf_bwfont_render_character(const struct mf_font_s *font,
int16_t x0, int16_t y0,
mf_char character,
uint16_t character,
mf_pixel_callback_t callback,
void *state);
MF_EXTERN uint8_t mf_bwfont_character_width(const struct mf_font_s *font,
mf_char character);
uint16_t character);
#endif
#endif

View File

@ -159,7 +159,7 @@
#ifdef __cplusplus
#define MF_EXTERN extern "C"
#else
#define MF_EXTERN extern
#define MF_EXTERN
#endif
#endif

View File

@ -19,9 +19,11 @@
/* Type used to represent characters internally. */
#if MF_ENCODING == MF_ENCODING_ASCII
typedef char mf_char;
typedef char mf_char;
#define MFCHAR2UINT16(c) ((uint16_t)(uint8_t)(c))
#else
typedef uint16_t mf_char;
typedef uint16_t mf_char;
#define MFCHAR2UINT16(c) (c)
#endif
/* Type used to represent input strings. */

View File

@ -5,10 +5,18 @@
* http://ugfx.org/license.html
*/
#include "mf_font.h"
#include "mf_config.h"
#ifndef MF_NO_COMPILE
#define MF_BWFONT_INTERNALS
#define MF_RLEFONT_INTERNALS
#define MF_SCALEDFONT_INTERNALS
#include "mf_font.h"
#include "mf_rlefont.h"
#include "mf_bwfont.h"
#include "mf_scaledfont.h"
#include <stdbool.h>
/* This will be made into a list of included fonts using macro magic. */
@ -40,7 +48,7 @@ uint8_t mf_character_width(const struct mf_font_s *font,
mf_char character)
{
uint8_t width;
width = font->character_width(font, character);
width = font->character_width(font, MFCHAR2UINT16(character));
if (!width)
{

View File

@ -53,17 +53,17 @@ struct mf_font_s
uint8_t flags;
/* Fallback character to use for missing glyphs. */
mf_char fallback_character;
uint16_t fallback_character;
/* Function to get character width. Should return 0 if character is
* not found. */
uint8_t (*character_width)(const struct mf_font_s *font, mf_char character);
uint8_t (*character_width)(const struct mf_font_s *font, uint16_t character);
/* Function to render a character. Returns the character width or 0 if
* character is not found. */
uint8_t (*render_character)(const struct mf_font_s *font,
int16_t x0, int16_t y0,
mf_char character,
uint16_t character,
mf_pixel_callback_t callback,
void *state);
};

View File

@ -297,7 +297,7 @@ void mf_render_justified(const struct mf_font_s *font,
{
int16_t x, tmp;
uint16_t c1 = 0, c2;
mf_char c1 = 0, c2;
x = x0 - font->baseline_x;
while (count--)

View File

@ -267,7 +267,7 @@ uint8_t mf_rlefont_render_character(const struct mf_font_s *font,
rstate.callback = callback;
rstate.state = state;
p = find_glyph((struct mf_rlefont_s*)font, character);
p = find_glyph((struct mf_rlefont_s*)font, character);
if (!p)
return 0;

View File

@ -70,12 +70,12 @@ struct mf_rlefont_s
/* Internal functions, don't use these directly. */
MF_EXTERN uint8_t mf_rlefont_render_character(const struct mf_font_s *font,
int16_t x0, int16_t y0,
mf_char character,
uint16_t character,
mf_pixel_callback_t callback,
void *state);
MF_EXTERN uint8_t mf_rlefont_character_width(const struct mf_font_s *font,
mf_char character);
uint16_t character);
#endif
#endif

View File

@ -36,7 +36,7 @@ static void scaled_pixel_callback(int16_t x, int16_t y, uint8_t count,
}
uint8_t mf_scaled_character_width(const struct mf_font_s *font,
mf_char character)
uint16_t character)
{
struct mf_scaledfont_s *sfont = (struct mf_scaledfont_s*)font;
uint8_t basewidth;
@ -48,7 +48,7 @@ uint8_t mf_scaled_character_width(const struct mf_font_s *font,
uint8_t mf_scaled_render_character(const struct mf_font_s *font,
int16_t x0, int16_t y0,
mf_char character,
uint16_t character,
mf_pixel_callback_t callback,
void *state)
{

View File

@ -31,12 +31,12 @@ MF_EXTERN void mf_scale_font(struct mf_scaledfont_s *newfont,
/* Internal functions, don't use these directly. */
MF_EXTERN uint8_t mf_scaled_render_character(const struct mf_font_s *font,
int16_t x0, int16_t y0,
mf_char character,
uint16_t character,
mf_pixel_callback_t callback,
void *state);
MF_EXTERN uint8_t mf_scaled_character_width(const struct mf_font_s *font,
mf_char character);
uint16_t character);
#endif
#endif

8
src/gdriver/gdriver_mk.c Normal file
View File

@ -0,0 +1,8 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "gdriver.c"

8
src/gevent/gevent_mk.c Normal file
View File

@ -0,0 +1,8 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "gevent.c"

23
src/gfile/gfile_mk.c Normal file
View File

@ -0,0 +1,23 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "gfile.c"
#include "gfile_fs_native.c"
#include "gfile_fs_ram.c"
#include "gfile_fs_rom.c"
#include "gfile_fs_fatfs.c"
#include "gfile_fs_petitfs.c"
#include "gfile_fs_mem.c"
#include "gfile_fs_chibios.c"
#include "gfile_fs_strings.c"
#include "gfile_printg.c"
#include "gfile_scang.c"
#include "gfile_stdio.c"
#include "gfile_fatfs_wrapper.c"
#include "gfile_fatfs_diskio_chibios.c"
#include "gfile_petitfs_wrapper.c"
#include "gfile_petitfs_diskio_chibios.c"

View File

@ -15,7 +15,7 @@
#include "gfx.h"
static bool_t initDone = FALSE;
static bool_t gfxInitDone = FALSE;
/* These init functions are defined by each module but not published */
extern void _gosInit(void);
@ -74,9 +74,9 @@ extern void _gosDeinit(void);
void gfxInit(void)
{
/* Ensure we only initialise once */
if (initDone)
if (gfxInitDone)
return;
initDone = TRUE;
gfxInitDone = TRUE;
// These must be initialised in the order of their dependancies
@ -121,9 +121,9 @@ void gfxInit(void)
void gfxDeinit(void)
{
if (!initDone)
if (!gfxInitDone)
return;
initDone = FALSE;
gfxInitDone = FALSE;
// We deinitialise the opposite way as we initialised
#if GFX_USE_GWIN

20
src/gfx_mk.c Normal file
View File

@ -0,0 +1,20 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "gfx.c"
#include "gos/gos_mk.c"
#include "gdriver/gdriver_mk.c"
#include "gqueue/gqueue_mk.c"
#include "gdisp/gdisp_mk.c"
#include "gevent/gevent_mk.c"
#include "gtimer/gtimer_mk.c"
#include "gwin/gwin_mk.c"
#include "ginput/ginput_mk.c"
#include "gadc/gadc_mk.c"
#include "gaudio/gaudio_mk.c"
#include "gmisc/gmisc_mk.c"
#include "gfile/gfile_mk.c"

13
src/ginput/ginput_mk.c Normal file
View File

@ -0,0 +1,13 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "ginput.c"
#include "ginput_mouse.c"
#include "ginput_keyboard.c"
#include "ginput_keyboard_microcode.c"
#include "ginput_toggle.c"
#include "ginput_dial.c"

11
src/gmisc/gmisc_mk.c Normal file
View File

@ -0,0 +1,11 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "gmisc.c"
#include "gmisc_arrayops.c"
#include "gmisc_matrix2d.c"
#include "gmisc_trig.c"

16
src/gos/gos_mk.c Normal file
View File

@ -0,0 +1,16 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "gos_arduino.c"
#include "gos_chibios.c"
#include "gos_ecos.c"
#include "gos_freertos.c"
#include "gos_linux.c"
#include "gos_osx.c"
#include "gos_raw32.c"
#include "gos_rawrtos.c"
#include "gos_win32.c"

8
src/gqueue/gqueue_mk.c Normal file
View File

@ -0,0 +1,8 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "gqueue.c"

8
src/gtimer/gtimer_mk.c Normal file
View File

@ -0,0 +1,8 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "gtimer.c"

View File

@ -17,25 +17,25 @@
#include "gwin_class.h"
// Parameters for various shapes
#define RND_CNR_SIZE 5 // Rounded corner size for rounded buttons
#define ARROWHEAD_DIVIDER 0 // What fraction of the length for the arrow head. Use 0 for 45 degree arrow head.
#define ARROWBODY_DIVIDER 2 // What fraction of the width for the arrow body
#define TOP_FADE 50 // (TOP_FADE/255)% fade to white for top of button
#define BOTTOM_FADE 25 // (BOTTOM_FADE/255)% fade to black for bottom of button
#define BTN_CNR_SIZE 5 // Rounded corner size for rounded buttons
#define BTN_ARROWHEAD_DIV 0 // What fraction of the length for the arrow head. Use 0 for 45 degree arrow head.
#define BTN_ARROWBODY_DIV 2 // What fraction of the width for the arrow body
#define BTN_TOP_FADE 50 // (BTN_TOP_FADE/255)% fade to white for top of button
#define BTN_BOTTOM_FADE 25 // (BTN_BOTTOM_FADE/255)% fade to black for bottom of button
// Our pressed state
#define GBUTTON_FLG_PRESSED (GWIN_FIRST_CONTROL_FLAG<<0)
#if GINPUT_NEED_MOUSE
// A mouse down has occurred over the button
static void MouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
static void ButtonMouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
(void) x; (void) y;
gw->g.flags |= GBUTTON_FLG_PRESSED;
_gwinUpdate((GHandle)gw);
}
// A mouse up has occurred (it may or may not be over the button)
static void MouseUp(GWidgetObject *gw, coord_t x, coord_t y) {
static void ButtonMouseUp(GWidgetObject *gw, coord_t x, coord_t y) {
(void) x; (void) y;
gw->g.flags &= ~GBUTTON_FLG_PRESSED;
_gwinUpdate((GHandle)gw);
@ -52,14 +52,14 @@
#if GINPUT_NEED_TOGGLE
// A toggle off has occurred
static void ToggleOff(GWidgetObject *gw, uint16_t role) {
static void ButtonToggleOff(GWidgetObject *gw, uint16_t role) {
(void) role;
gw->g.flags &= ~GBUTTON_FLG_PRESSED;
_gwinUpdate((GHandle)gw);
}
// A toggle on has occurred
static void ToggleOn(GWidgetObject *gw, uint16_t role) {
static void ButtonToggleOn(GWidgetObject *gw, uint16_t role) {
(void) role;
gw->g.flags |= GBUTTON_FLG_PRESSED;
_gwinUpdate((GHandle)gw);
@ -67,12 +67,12 @@
_gwinSendEvent(&gw->g, GEVENT_GWIN_BUTTON);
}
static void ToggleAssign(GWidgetObject *gw, uint16_t role, uint16_t instance) {
static void ButtonToggleAssign(GWidgetObject *gw, uint16_t role, uint16_t instance) {
(void) role;
((GButtonObject *)gw)->toggle = instance;
}
static uint16_t ToggleGet(GWidgetObject *gw, uint16_t role) {
static uint16_t ButtonToggleGet(GWidgetObject *gw, uint16_t role) {
(void) role;
return ((GButtonObject *)gw)->toggle;
}
@ -90,18 +90,18 @@ static const gwidgetVMT buttonVMT = {
gwinButtonDraw_Normal, // The default drawing routine
#if GINPUT_NEED_MOUSE
{
MouseDown, // Process mouse down events
MouseUp, // Process mouse up events
ButtonMouseDown, // Process mouse down events
ButtonMouseUp, // Process mouse up events
0, // Process mouse move events (NOT USED)
},
#endif
#if GINPUT_NEED_TOGGLE
{
1, // 1 toggle role
ToggleAssign, // Assign Toggles
ToggleGet, // Get Toggles
ToggleOff, // Process toggle off events
ToggleOn, // Process toggle on events
ButtonToggleAssign, // Assign Toggles
ButtonToggleGet, // Get Toggles
ButtonToggleOff, // Process toggle off events
ButtonToggleOn, // Process toggle on events
},
#endif
#if GINPUT_NEED_DIAL
@ -136,7 +136,7 @@ bool_t gwinButtonIsPressed(GHandle gh) {
* Custom Draw Routines
*----------------------------------------------------------*/
static const GColorSet *getDrawColors(GWidgetObject *gw) {
static const GColorSet *getButtonColors(GWidgetObject *gw) {
if (!(gw->g.flags & GWIN_FLG_SYSENABLED)) return &gw->pstyle->disabled;
if ((gw->g.flags & GBUTTON_FLG_PRESSED)) return &gw->pstyle->pressed;
return &gw->pstyle->enabled;
@ -148,7 +148,7 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
(void) param;
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
pcol = getButtonColors(gw);
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
@ -164,11 +164,11 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
(void) param;
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
pcol = getButtonColors(gw);
/* Fill the box blended from variants of the fill color */
tcol = gdispBlendColor(White, pcol->fill, TOP_FADE);
bcol = gdispBlendColor(Black, pcol->fill, BOTTOM_FADE);
tcol = gdispBlendColor(White, pcol->fill, BTN_TOP_FADE);
bcol = gdispBlendColor(Black, pcol->fill, BTN_BOTTOM_FADE);
dalpha = FIXED(255)/gw->g.height;
for(alpha = 0, i = 0; i < gw->g.height; i++, alpha += dalpha)
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+i, gw->g.x+gw->g.width-2, gw->g.y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha)));
@ -185,13 +185,13 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
(void) param;
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
pcol = getButtonColors(gw);
gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
if (gw->g.width >= 2*RND_CNR_SIZE+10) {
gdispGFillRoundedBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, RND_CNR_SIZE-1, pcol->fill);
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+RND_CNR_SIZE, gw->g.width-2, gw->g.height-(2*RND_CNR_SIZE), gw->text, gw->g.font, pcol->text, justifyCenter);
gdispGDrawRoundedBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, RND_CNR_SIZE, pcol->edge);
if (gw->g.width >= 2*BTN_CNR_SIZE+10) {
gdispGFillRoundedBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, BTN_CNR_SIZE-1, pcol->fill);
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+BTN_CNR_SIZE, gw->g.width-2, gw->g.height-(2*BTN_CNR_SIZE), gw->text, gw->g.font, pcol->text, justifyCenter);
gdispGDrawRoundedBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, BTN_CNR_SIZE, pcol->edge);
} else {
gdispGFillStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, pcol->edge);
@ -205,7 +205,7 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
(void) param;
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
pcol = getButtonColors(gw);
gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
gdispGFillEllipse(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width/2-1, gw->g.height/2-1, pcol->fill);
@ -221,13 +221,13 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
point arw[7];
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
pcol = getButtonColors(gw);
// Create the arrow polygon
arw[0].x = (gw->g.width-1)/2; // Point center
arw[0].y = 0; // Arrow start
arw[3].y = gw->g.height-1; // Arrow end
#if ARROWHEAD_DIVIDER == 0
#if BTN_ARROWHEAD_DIV == 0
if (gw->g.height <= arw[0].x) {
arw[1].y = arw[3].y; // End of head
arw[1].x = arw[0].x+arw[3].y; // Width of head (side 1)
@ -237,15 +237,15 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
} else {
arw[1].y = arw[0].x;
arw[1].x = arw[0].x << 1;
arw[2].x = arw[0].x + arw[0].x/ARROWBODY_DIVIDER;
arw[4].x = arw[0].x - arw[0].x/ARROWBODY_DIVIDER;
arw[2].x = arw[0].x + arw[0].x/BTN_ARROWBODY_DIV;
arw[4].x = arw[0].x - arw[0].x/BTN_ARROWBODY_DIV;
arw[6].x = 0;
}
#else
arw[1].y = gw->g.height/ARROWHEAD_DIVIDER;
arw[1].y = gw->g.height/BTN_ARROWHEAD_DIV;
arw[1].x = arw[0].x << 1;
arw[2].x = arw[0].x + arw[0].x/ARROWBODY_DIVIDER;
arw[4].x = arw[0].x - arw[0].x/ARROWBODY_DIVIDER;
arw[2].x = arw[0].x + arw[0].x/BTN_ARROWBODY_DIV;
arw[4].x = arw[0].x - arw[0].x/BTN_ARROWBODY_DIV;
arw[6].x = 0;
#endif
@ -271,13 +271,13 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
point arw[7];
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
pcol = getButtonColors(gw);
// Create the arrow polygon
arw[0].x = (gw->g.width-1)/2; // Point center
arw[0].y = gw->g.height-1; // Arrow start
arw[3].y = 0; // Arrow end
#if ARROWHEAD_DIVIDER == 0
#if BTN_ARROWHEAD_DIV == 0
if (gw->g.height <= arw[0].x) {
arw[1].y = arw[3].y; // End of head
arw[1].x = arw[0].x+arw[0].y; // Width of head (side 1)
@ -287,15 +287,15 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
} else {
arw[1].y = arw[0].y - arw[0].x;
arw[1].x = arw[0].x << 1;
arw[2].x = arw[0].x + arw[0].x/ARROWBODY_DIVIDER;
arw[4].x = arw[0].x - arw[0].x/ARROWBODY_DIVIDER;
arw[2].x = arw[0].x + arw[0].x/BTN_ARROWBODY_DIV;
arw[4].x = arw[0].x - arw[0].x/BTN_ARROWBODY_DIV;
arw[6].x = 0;
}
#else
arw[1].y = arw[0].y - gw->g.height/ARROWHEAD_DIVIDER;
arw[1].y = arw[0].y - gw->g.height/BTN_ARROWHEAD_DIV;
arw[1].x = arw[0].x << 1;
arw[2].x = arw[0].x + arw[0].x/ARROWBODY_DIVIDER;
arw[4].x = arw[0].x - arw[0].x/ARROWBODY_DIVIDER;
arw[2].x = arw[0].x + arw[0].x/BTN_ARROWBODY_DIV;
arw[4].x = arw[0].x - arw[0].x/BTN_ARROWBODY_DIV;
arw[6].x = 0;
#endif
@ -321,13 +321,13 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
point arw[7];
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
pcol = getButtonColors(gw);
// Create the arrow polygon
arw[0].y = (gw->g.height-1)/2; // Point center
arw[0].x = 0; // Arrow start
arw[3].x = gw->g.width-1; // Arrow end
#if ARROWHEAD_DIVIDER == 0
#if BTN_ARROWHEAD_DIV == 0
if (gw->g.width <= arw[0].y) {
arw[1].x = arw[3].x; // End of head
arw[1].y = arw[0].y+arw[3].x; // Width of head (side 1)
@ -337,15 +337,15 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
} else {
arw[1].x = arw[0].y;
arw[1].y = arw[0].y << 1;
arw[2].y = arw[0].y + arw[0].y/ARROWBODY_DIVIDER;
arw[4].y = arw[0].y - arw[0].y/ARROWBODY_DIVIDER;
arw[2].y = arw[0].y + arw[0].y/BTN_ARROWBODY_DIV;
arw[4].y = arw[0].y - arw[0].y/BTN_ARROWBODY_DIV;
arw[6].y = 0;
}
#else
arw[1].x = gw->g.width/ARROWHEAD_DIVIDER;
arw[1].x = gw->g.width/BTN_ARROWHEAD_DIV;
arw[1].y = arw[0].y << 1;
arw[2].y = arw[0].y + arw[0].y/ARROWBODY_DIVIDER;
arw[4].y = arw[0].y - arw[0].y/ARROWBODY_DIVIDER;
arw[2].y = arw[0].y + arw[0].y/BTN_ARROWBODY_DIV;
arw[4].y = arw[0].y - arw[0].y/BTN_ARROWBODY_DIV;
arw[6].y = 0;
#endif
@ -371,13 +371,13 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
point arw[7];
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
pcol = getButtonColors(gw);
// Create the arrow polygon
arw[0].y = (gw->g.height-1)/2; // Point center
arw[0].x = gw->g.width-1; // Arrow start
arw[3].x = 0; // Arrow end
#if ARROWHEAD_DIVIDER == 0
#if BTN_ARROWHEAD_DIV == 0
if (gw->g.width <= arw[0].y) {
arw[1].x = arw[3].x; // End of head
arw[1].y = arw[0].y+arw[0].x; // Width of head (side 1)
@ -387,15 +387,15 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
} else {
arw[1].x = arw[0].x - arw[0].y;
arw[1].y = arw[0].y << 1;
arw[2].y = arw[0].y + arw[0].y/ARROWBODY_DIVIDER;
arw[4].y = arw[0].y - arw[0].y/ARROWBODY_DIVIDER;
arw[2].y = arw[0].y + arw[0].y/BTN_ARROWBODY_DIV;
arw[4].y = arw[0].y - arw[0].y/BTN_ARROWBODY_DIV;
arw[6].y = 0;
}
#else
arw[1].x = arw[0].x - gw->g.width/ARROWHEAD_DIVIDER;
arw[1].x = arw[0].x - gw->g.width/BTN_ARROWHEAD_DIV;
arw[1].y = arw[0].y << 1;
arw[2].y = arw[0].y + arw[0].y/ARROWBODY_DIVIDER;
arw[4].y = arw[0].y - arw[0].y/ARROWBODY_DIVIDER;
arw[2].y = arw[0].y + arw[0].y/BTN_ARROWBODY_DIV;
arw[4].y = arw[0].y - arw[0].y/BTN_ARROWBODY_DIV;
arw[6].y = 0;
#endif
@ -422,7 +422,7 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
coord_t sy;
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
pcol = getButtonColors(gw);
if (!(gw->g.flags & GWIN_FLG_SYSENABLED)) {
sy = 2 * gw->g.height;

View File

@ -17,8 +17,8 @@
#include "gwin_class.h"
// Parameters for button custom draw
#define TOP_FADE 50 // (TOP_FADE/255)% fade to white for top of button
#define BOTTOM_FADE 25 // (BOTTOM_FADE/255)% fade to black for bottom of button
#define CHK_TOP_FADE 50 // (CHK_TOP_FADE/255)% fade to white for top of button
#define CHK_BOTTOM_FADE 25 // (CHK_BOTTOM_FADE/255)% fade to black for bottom of button
// Our checked state
#define GCHECKBOX_FLG_CHECKED (GWIN_FIRST_CONTROL_FLAG<<0)
@ -47,7 +47,7 @@ static void SendCheckboxEvent(GWidgetObject *gw) {
}
#if GINPUT_NEED_MOUSE
static void MouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
static void CheckboxMouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
(void) x; (void) y;
gw->g.flags ^= GCHECKBOX_FLG_CHECKED;
_gwinUpdate((GHandle)gw);
@ -56,19 +56,19 @@ static void SendCheckboxEvent(GWidgetObject *gw) {
#endif
#if GINPUT_NEED_TOGGLE
static void ToggleOn(GWidgetObject *gw, uint16_t role) {
static void CheckboxToggleOn(GWidgetObject *gw, uint16_t role) {
(void) role;
gw->g.flags ^= GCHECKBOX_FLG_CHECKED;
_gwinUpdate((GHandle)gw);
SendCheckboxEvent(gw);
}
static void ToggleAssign(GWidgetObject *gw, uint16_t role, uint16_t instance) {
static void CheckboxToggleAssign(GWidgetObject *gw, uint16_t role, uint16_t instance) {
(void) role;
((GCheckboxObject *)gw)->toggle = instance;
}
static uint16_t ToggleGet(GWidgetObject *gw, uint16_t role) {
static uint16_t CheckboxToggleGet(GWidgetObject *gw, uint16_t role) {
(void) role;
return ((GCheckboxObject *)gw)->toggle;
}
@ -86,7 +86,7 @@ static const gwidgetVMT checkboxVMT = {
gwinCheckboxDraw_CheckOnLeft, // The default drawing routine
#if GINPUT_NEED_MOUSE
{
MouseDown, // Process mouse down events
CheckboxMouseDown, // Process mouse down events
0, // Process mouse up events (NOT USED)
0, // Process mouse move events (NOT USED)
},
@ -94,10 +94,10 @@ static const gwidgetVMT checkboxVMT = {
#if GINPUT_NEED_TOGGLE
{
1, // 1 toggle role
ToggleAssign, // Assign Toggles
ToggleGet, // Get Toggles
CheckboxToggleAssign, // Assign Toggles
CheckboxToggleGet, // Get Toggles
0, // Process toggle off events (NOT USED)
ToggleOn, // Process toggle on events
CheckboxToggleOn, // Process toggle on events
},
#endif
#if GINPUT_NEED_DIAL
@ -147,7 +147,7 @@ bool_t gwinCheckboxIsChecked(GHandle gh) {
* Custom Draw Routines
*----------------------------------------------------------*/
static const GColorSet *getDrawColors(GWidgetObject *gw) {
static const GColorSet *getCheckboxColors(GWidgetObject *gw) {
if (!(gw->g.flags & GWIN_FLG_SYSENABLED)) return &gw->pstyle->disabled;
if ((gw->g.flags & GCHECKBOX_FLG_CHECKED)) return &gw->pstyle->pressed;
return &gw->pstyle->enabled;
@ -160,7 +160,7 @@ void gwinCheckboxDraw_CheckOnLeft(GWidgetObject *gw, void *param) {
(void) param;
if (gw->g.vmt != (gwinVMT *)&checkboxVMT) return;
pcol = getDrawColors(gw);
pcol = getCheckboxColors(gw);
// Get the dimension of the check box (sans text)
ld = gw->g.width < gw->g.height ? gw->g.width : gw->g.height;
@ -186,7 +186,7 @@ void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param) {
(void) param;
if (gw->g.vmt != (gwinVMT *)&checkboxVMT) return;
pcol = getDrawColors(gw);
pcol = getCheckboxColors(gw);
// Get the dimension of the check box (sans text)
ld = gw->g.width < gw->g.height ? gw->g.width : gw->g.height;
@ -214,7 +214,7 @@ void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param) {
(void) param;
if (gw->g.vmt != (gwinVMT *)&checkboxVMT) return;
pcol = getDrawColors(gw);
pcol = getCheckboxColors(gw);
#if GWIN_NEED_FLASHING
// Flash the on and off state.
@ -235,7 +235,7 @@ void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param) {
(void) param;
if (gw->g.vmt != (gwinVMT *)&checkboxVMT) return;
pcol = getDrawColors(gw);
pcol = getCheckboxColors(gw);
#if GWIN_NEED_FLASHING
// Flash the on and off state.
@ -243,8 +243,8 @@ void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param) {
#endif
/* Fill the box blended from variants of the fill color */
tcol = gdispBlendColor(White, pcol->fill, TOP_FADE);
bcol = gdispBlendColor(Black, pcol->fill, BOTTOM_FADE);
tcol = gdispBlendColor(White, pcol->fill, CHK_TOP_FADE);
bcol = gdispBlendColor(Black, pcol->fill, CHK_BOTTOM_FADE);
dalpha = FIXED(255)/gw->g.height;
for(alpha = 0, i = 0; i < gw->g.height; i++, alpha += dalpha)
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+i, gw->g.x+gw->g.width-2, gw->g.y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha)));

View File

@ -611,7 +611,7 @@ void gwinPutCharArray(GHandle gh, const char *str, size_t n) {
#define MAX_FILLER 11
#define FLOAT_PRECISION 100000
static char *ltoa_wd(char *p, long num, unsigned radix, long divisor) {
static char *consltoa_wd(char *p, long num, unsigned radix, long divisor) {
int i;
char *q;
@ -641,10 +641,10 @@ static char *ltoa_wd(char *p, long num, unsigned radix, long divisor) {
unsigned long precision = FLOAT_PRECISION;
l = num;
p = ltoa_wd(p, l, 10, 0);
p = consltoa_wd(p, l, 10, 0);
*p++ = '.';
l = (num - l) * precision;
return ltoa_wd(p, l, 10, precision / 10);
return consltoa_wd(p, l, 10, precision / 10);
}
#endif
@ -746,7 +746,7 @@ void gwinPrintf(GHandle gh, const char *fmt, ...) {
*p++ = '-';
l = -l;
}
p = ltoa_wd(p, l, 10, 0);
p = consltoa_wd(p, l, 10, 0);
break;
#if GWIN_CONSOLE_USE_FLOAT
case 'f':
@ -774,7 +774,7 @@ void gwinPrintf(GHandle gh, const char *fmt, ...) {
l = va_arg(ap, long);
else
l = va_arg(ap, int);
p = ltoa_wd(p, l, c, 0);
p = consltoa_wd(p, l, c, 0);
break;
default:
*p++ = c;

View File

@ -92,7 +92,7 @@ coord_t gwinGetInnerHeight(GHandle gh) {
#define BORDER_WIDTH 2
static coord_t BorderSize(GHandle gh) { return (gh->flags & GWIN_CONTAINER_BORDER) ? BORDER_WIDTH : 0; }
static coord_t ContainerBorderSize(GHandle gh) { return (gh->flags & GWIN_CONTAINER_BORDER) ? BORDER_WIDTH : 0; }
// The container VMT table
static const gcontainerVMT containerVMT = {
@ -121,10 +121,10 @@ static const gcontainerVMT containerVMT = {
},
#endif
},
BorderSize, // The size of the left border (mandatory)
BorderSize, // The size of the top border (mandatory)
BorderSize, // The size of the right border (mandatory)
BorderSize, // The size of the bottom border (mandatory)
ContainerBorderSize, // The size of the left border (mandatory)
ContainerBorderSize, // The size of the top border (mandatory)
ContainerBorderSize, // The size of the right border (mandatory)
ContainerBorderSize, // The size of the bottom border (mandatory)
0, // A child has been added (optional)
0, // A child has been deleted (optional)
};

View File

@ -17,15 +17,15 @@
#include "gwin_class.h"
/* Some position values */
#define BUTTON_X 18 // Button Width
#define BUTTON_Y 18 // Button Height
#define BUTTON_I 3 // Button inner margin
#define BUTTON_T 2 // Gap from top of window to button
#define BUTTON_B 2 // Gap from button to the bottom of the frame title area
#define BORDER_L 2 // Left Border
#define BORDER_R 2 // Right Border
#define BORDER_T (BUTTON_Y+BUTTON_T+BUTTON_B) // Top Border (Title area)
#define BORDER_B 2 // Bottom Border
#define FRM_BUTTON_X 18 // Button Width
#define FRM_BUTTON_Y 18 // Button Height
#define FRM_BUTTON_I 3 // Button inner margin
#define FRM_BUTTON_T 2 // Gap from top of window to button
#define FRM_BUTTON_B 2 // Gap from button to the bottom of the frame title area
#define FRM_BORDER_L 2 // Left Border
#define FRM_BORDER_R 2 // Right Border
#define FRM_BORDER_T (FRM_BUTTON_Y+FRM_BUTTON_T+FRM_BUTTON_B) // Top Border (Title area)
#define FRM_BORDER_B 2 // Bottom Border
/* Internal state flags */
#define GWIN_FRAME_USER_FLAGS (GWIN_FRAME_CLOSE_BTN|GWIN_FRAME_MINMAX_BTN)
@ -40,10 +40,10 @@
#error "GWIN Frame: - Flag definitions don't match"
#endif
static coord_t BorderSizeL(GHandle gh) { (void)gh; return BORDER_L; }
static coord_t BorderSizeR(GHandle gh) { (void)gh; return BORDER_R; }
static coord_t BorderSizeT(GHandle gh) { (void)gh; return BORDER_T; }
static coord_t BorderSizeB(GHandle gh) { (void)gh; return BORDER_B; }
static coord_t FrameBorderSizeL(GHandle gh) { (void)gh; return FRM_BORDER_L; }
static coord_t FrameBorderSizeR(GHandle gh) { (void)gh; return FRM_BORDER_R; }
static coord_t FrameBorderSizeT(GHandle gh) { (void)gh; return FRM_BORDER_T; }
static coord_t FrameBorderSizeB(GHandle gh) { (void)gh; return FRM_BORDER_B; }
static void forceFrameRedraw(GWidgetObject *gw) {
// Force a redraw of just the frame.
@ -54,42 +54,42 @@ static void forceFrameRedraw(GWidgetObject *gw) {
}
#if GINPUT_NEED_MOUSE
static void mouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
static void FrameMouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
coord_t pos;
// We must be clicking on the frame button area to be of interest
if (y < BUTTON_T || y >= BUTTON_T+BUTTON_Y)
if (y < FRM_BUTTON_T || y >= FRM_BUTTON_T+FRM_BUTTON_Y)
return;
pos = gw->g.width - (BORDER_R+BUTTON_X);
pos = gw->g.width - (FRM_BORDER_R+FRM_BUTTON_X);
if ((gw->g.flags & GWIN_FRAME_CLOSE_BTN)) {
if (x >= pos && x < pos+BUTTON_X) {
if (x >= pos && x < pos+FRM_BUTTON_X) {
// Close is pressed - force redraw the frame only
gw->g.flags |= GWIN_FRAME_CLOSE_PRESSED;
forceFrameRedraw(gw);
return;
}
pos -= BUTTON_X;
pos -= FRM_BUTTON_X;
}
if ((gw->g.flags & GWIN_FRAME_MINMAX_BTN)) {
if (x >= pos && x < pos+BUTTON_X) {
if (x >= pos && x < pos+FRM_BUTTON_X) {
// Close is pressed - force redraw the frame only
gw->g.flags |= GWIN_FRAME_MAX_PRESSED;
forceFrameRedraw(gw);
return;
}
pos -= BUTTON_X;
if (x >= pos && x < pos+BUTTON_X) {
pos -= FRM_BUTTON_X;
if (x >= pos && x < pos+FRM_BUTTON_X) {
// Close is pressed - force redraw the frame only
gw->g.flags |= GWIN_FRAME_MIN_PRESSED;
forceFrameRedraw(gw);
return;
}
pos -= BUTTON_X;
pos -= FRM_BUTTON_X;
}
}
static void mouseUp(GWidgetObject *gw, coord_t x, coord_t y) {
static void FrameMouseUp(GWidgetObject *gw, coord_t x, coord_t y) {
#if GWIN_BUTTON_LAZY_RELEASE
if ((gw->g.flags & GWIN_FRAME_CLOSE_PRESSED)) {
// Close is released - destroy the window
@ -119,12 +119,12 @@ static void forceFrameRedraw(GWidgetObject *gw) {
return;
// We must be releasing over the button
if (y >= BUTTON_T && y < BUTTON_T+BUTTON_Y) {
if (y >= FRM_BUTTON_T && y < FRM_BUTTON_T+FRM_BUTTON_Y) {
coord_t pos;
pos = gw->g.width - (BORDER_R+BUTTON_X);
pos = gw->g.width - (FRM_BORDER_R+FRM_BUTTON_X);
if ((gw->g.flags & GWIN_FRAME_CLOSE_BTN)) {
if ((gw->g.flags & GWIN_FRAME_CLOSE_PRESSED) && x >= pos && x <= pos+BUTTON_X) {
if ((gw->g.flags & GWIN_FRAME_CLOSE_PRESSED) && x >= pos && x <= pos+FRM_BUTTON_X) {
// Close is released - destroy the window. This is tricky as we already have the drawing lock.
gw->g.flags &= ~(GWIN_FRAME_CLOSE_PRESSED|GWIN_FRAME_MAX_PRESSED|GWIN_FRAME_MIN_PRESSED);