diff --git a/GNUmakefile b/GNUmakefile index c86d8f5..db4d158 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -7,7 +7,7 @@ CFLAGS = -Wall -Wextra -fPIC -Iinclude -D_MILSKO LDFLAGS = LIBS = -L_OBJS = src/ds.o src/core.o src/default.o src/draw.o src/lowlevel.o +L_OBJS = src/ds.o src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o L_OBJS += src/window.o src/button.o L_LIBS = -lfreetype diff --git a/include/Mw/Button.h b/include/Mw/Button.h index ba2c482..c13ed9d 100644 --- a/include/Mw/Button.h +++ b/include/Mw/Button.h @@ -3,6 +3,7 @@ #define __MW_BUTTON_H__ #include +#include #ifdef __cplusplus extern "C" { diff --git a/include/Mw/Default.h b/include/Mw/Default.h index 6cf5d3b..bdfbb99 100644 --- a/include/Mw/Default.h +++ b/include/Mw/Default.h @@ -3,6 +3,7 @@ #define __MW_DEFAULT_H__ #include +#include #ifdef __cplusplus extern "C" { diff --git a/include/Mw/Draw.h b/include/Mw/Draw.h index c9fc08e..79c7f88 100644 --- a/include/Mw/Draw.h +++ b/include/Mw/Draw.h @@ -14,6 +14,7 @@ MWDECL MwLLColor MwParseColor(MwWidget handle, const char* text); MWDECL void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color); MWDECL void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert); +MWDECL void MwDrawText(MwWidget handle, MwPoint* point, const char* text, MwLLColor color); #ifdef __cplusplus } diff --git a/include/Mw/Font.h b/include/Mw/Font.h new file mode 100644 index 0000000..65664d5 --- /dev/null +++ b/include/Mw/Font.h @@ -0,0 +1,18 @@ +/* $Id$ */ +#ifndef __MW_FONT_H__ +#define __MW_FONT_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +MWDECL MwFont MwFontData[]; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/Mw/Milsko.h b/include/Mw/Milsko.h index 2b6eafa..052b589 100644 --- a/include/Mw/Milsko.h +++ b/include/Mw/Milsko.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/include/Mw/TypeDefs.h b/include/Mw/TypeDefs.h index b4ec771..fe91df1 100644 --- a/include/Mw/TypeDefs.h +++ b/include/Mw/TypeDefs.h @@ -10,6 +10,7 @@ typedef struct _MwRect MwRect; typedef struct _MwIntegerKeyValue MwIntegerKeyValue; typedef struct _MwTextKeyValue MwTextKeyValue; typedef struct _MwUserHandlerKeyValue MwUserHandlerKeyValue; +typedef struct _MwFont MwFont; #ifdef _MILSKO typedef struct _MwWidget *MwWidget, MwWidgetRec; #else @@ -75,4 +76,10 @@ struct _MwClass { MwHandler click; }; +struct _MwFont { + int left; + int top; + unsigned char data[14]; +}; + #endif diff --git a/include/Mw/Window.h b/include/Mw/Window.h index ee6fad1..d0cccd1 100644 --- a/include/Mw/Window.h +++ b/include/Mw/Window.h @@ -3,6 +3,7 @@ #define __MW_WINDOW_H__ #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/button.c b/src/button.c index d78690e..9a304b8 100644 --- a/src/button.c +++ b/src/button.c @@ -15,7 +15,7 @@ static void draw(MwWidget handle) { MwDrawFrame(handle, &r, MwParseColor(handle, MwGetText(handle, MwNbackground)), handle->pressed); - MwDrawRect(handle, &r, MwParseColor(handle, MwGetText(handle, MwNbackground))); +// MwDrawRect(handle, &r, MwParseColor(handle, MwGetText(handle, MwNbackground))); } static void click(MwWidget handle) { diff --git a/src/draw.c b/src/draw.c index 4ff7007..4bfa681 100644 --- a/src/draw.c +++ b/src/draw.c @@ -115,3 +115,27 @@ void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) { rect->width -= border * 2; rect->height -= border * 2; } + +void MwDrawText(MwWidget handle, MwPoint* point, const char* text, MwLLColor color){ + int i, x, y, sx, sy; + MwRect r; + + sx = point->x; + sy = point->y; + + for(i = 0; text[i] != 0; i++){ + for(y = 0; y < 14; y++){ + for(x = 0; x < 7; x++){ + r.x = sx + x; + r.y = sy + y; + r.width = 1; + r.height = 1; + + if(MwFontData[(unsigned char)text[i]].data[y] & (1 << (7 - x))){ + MwDrawRect(handle, &r, color); + } + } + } + sx += 7; + } +} diff --git a/src/font.c b/src/font.c new file mode 100644 index 0000000..d7318e0 --- /dev/null +++ b/src/font.c @@ -0,0 +1,133 @@ +/* $Id$ */ +#include + +MwFont MwFontData[] = { + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 0 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 1 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 2 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 3 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 4 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 5 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 6 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 7 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 8 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 9 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 10 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 11 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 12 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 13 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 14 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 15 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 16 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 17 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 18 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 19 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 20 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 21 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 22 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 23 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 24 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 25 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 26 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 27 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 28 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 29 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 30 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}}, /* 31 */ + {0, 12, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 32 */ + {0, 12, {0, 0, 8, 8, 8, 8, 8, 8, 8, 0, 8, 8, 0, 0}}, /* 33 */ + {0, 12, {0, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 34 */ + {0, 12, {0, 0, 20, 20, 20, 62, 20, 20, 62, 20, 20, 20, 0, 0}}, /* 35 */ + {0, 12, {0, 0, 8, 60, 74, 74, 40, 28, 10, 74, 74, 60, 8, 0}}, /* 36 */ + {0, 12, {0, 0, 50, 74, 76, 56, 8, 16, 28, 50, 82, 76, 0, 0}}, /* 37 */ + {0, 12, {0, 0, 24, 36, 36, 36, 24, 50, 74, 68, 76, 50, 0, 0}}, /* 38 */ + {0, 12, {0, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 39 */ + {0, 12, {0, 2, 4, 8, 8, 16, 16, 16, 16, 16, 8, 8, 4, 2}}, /* 40 */ + {0, 12, {0, 32, 16, 8, 8, 4, 4, 4, 4, 4, 8, 8, 16, 32}}, /* 41 */ + {0, 12, {0, 0, 0, 0, 8, 42, 28, 8, 28, 42, 8, 0, 0, 0}}, /* 42 */ + {0, 12, {0, 0, 0, 0, 8, 8, 8, 62, 8, 8, 8, 0, 0, 0}}, /* 43 */ + {0, 12, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 8, 8, 16}}, /* 44 */ + {0, 12, {0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 0, 0, 0}}, /* 45 */ + {0, 12, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 28, 8, 0}}, /* 46 */ + {0, 12, {0, 2, 2, 4, 4, 8, 8, 8, 16, 16, 32, 32, 64, 64}}, /* 47 */ + {0, 12, {0, 0, 24, 36, 66, 66, 66, 66, 66, 66, 36, 24, 0, 0}}, /* 48 */ + {0, 12, {0, 0, 8, 24, 40, 8, 8, 8, 8, 8, 8, 62, 0, 0}}, /* 49 */ + {0, 12, {0, 0, 60, 66, 66, 2, 4, 4, 8, 16, 32, 126, 0, 0}}, /* 50 */ + {0, 12, {0, 0, 126, 2, 4, 8, 28, 2, 2, 66, 66, 60, 0, 0}}, /* 51 */ + {0, 12, {0, 0, 4, 12, 20, 20, 36, 36, 68, 126, 4, 4, 0, 0}}, /* 52 */ + {0, 12, {0, 0, 126, 64, 64, 124, 66, 2, 2, 66, 66, 60, 0, 0}}, /* 53 */ + {0, 12, {0, 0, 28, 32, 64, 64, 92, 98, 66, 66, 66, 60, 0, 0}}, /* 54 */ + {0, 12, {0, 0, 126, 2, 4, 4, 8, 8, 16, 16, 32, 32, 0, 0}}, /* 55 */ + {0, 12, {0, 0, 60, 66, 66, 36, 24, 36, 66, 66, 66, 60, 0, 0}}, /* 56 */ + {0, 12, {0, 0, 60, 66, 66, 66, 70, 58, 2, 66, 68, 56, 0, 0}}, /* 57 */ + {0, 12, {0, 0, 0, 0, 8, 28, 8, 0, 0, 8, 28, 8, 0, 0}}, /* 58 */ + {0, 12, {0, 0, 0, 0, 0, 24, 24, 0, 0, 24, 8, 8, 16, 0}}, /* 59 */ + {0, 12, {0, 0, 0, 2, 4, 8, 16, 32, 16, 8, 4, 2, 0, 0}}, /* 60 */ + {0, 12, {0, 0, 0, 0, 0, 126, 0, 0, 126, 0, 0, 0, 0, 0}}, /* 61 */ + {0, 12, {0, 0, 0, 32, 16, 8, 4, 2, 4, 8, 16, 32, 0, 0}}, /* 62 */ + {0, 12, {0, 0, 60, 66, 66, 4, 8, 8, 8, 0, 8, 8, 0, 0}}, /* 63 */ + {0, 12, {0, 0, 28, 34, 78, 82, 82, 82, 82, 78, 32, 30, 0, 0}}, /* 64 */ + {0, 12, {0, 0, 24, 36, 66, 66, 66, 126, 66, 66, 66, 66, 0, 0}}, /* 65 */ + {0, 12, {0, 0, 120, 68, 66, 68, 120, 68, 66, 66, 68, 120, 0, 0}}, /* 66 */ + {0, 12, {0, 0, 60, 66, 66, 64, 64, 64, 64, 66, 66, 60, 0, 0}}, /* 67 */ + {0, 12, {0, 0, 120, 68, 66, 66, 66, 66, 66, 66, 68, 120, 0, 0}}, /* 68 */ + {0, 12, {0, 0, 126, 64, 64, 64, 120, 64, 64, 64, 64, 126, 0, 0}}, /* 69 */ + {0, 12, {0, 0, 126, 64, 64, 64, 120, 64, 64, 64, 64, 64, 0, 0}}, /* 70 */ + {0, 12, {0, 0, 60, 66, 66, 64, 64, 78, 66, 66, 70, 58, 0, 0}}, /* 71 */ + {0, 12, {0, 0, 66, 66, 66, 66, 126, 66, 66, 66, 66, 66, 0, 0}}, /* 72 */ + {0, 12, {0, 0, 62, 8, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0}}, /* 73 */ + {0, 12, {0, 0, 14, 4, 4, 4, 4, 4, 4, 68, 68, 56, 0, 0}}, /* 74 */ + {0, 12, {0, 0, 66, 68, 72, 80, 96, 80, 72, 68, 66, 66, 0, 0}}, /* 75 */ + {0, 12, {0, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 126, 0, 0}}, /* 76 */ + {0, 12, {0, 0, 66, 102, 102, 90, 90, 66, 66, 66, 66, 66, 0, 0}}, /* 77 */ + {0, 12, {0, 0, 66, 66, 98, 98, 82, 74, 70, 70, 66, 66, 0, 0}}, /* 78 */ + {0, 12, {0, 0, 60, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0}}, /* 79 */ + {0, 12, {0, 0, 124, 66, 66, 66, 66, 124, 64, 64, 64, 64, 0, 0}}, /* 80 */ + {0, 12, {0, 0, 60, 66, 66, 66, 66, 66, 114, 74, 70, 60, 4, 2}}, /* 81 */ + {0, 12, {0, 0, 124, 66, 66, 66, 66, 124, 72, 68, 66, 66, 0, 0}}, /* 82 */ + {0, 12, {0, 0, 60, 66, 66, 64, 48, 12, 2, 66, 66, 60, 0, 0}}, /* 83 */ + {0, 12, {0, 0, 127, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0}}, /* 84 */ + {0, 12, {0, 0, 66, 66, 66, 66, 66, 66, 66, 66, 66, 60, 0, 0}}, /* 85 */ + {0, 12, {0, 0, 66, 66, 66, 66, 36, 36, 36, 24, 24, 24, 0, 0}}, /* 86 */ + {0, 12, {0, 0, 34, 34, 34, 34, 34, 34, 42, 42, 42, 20, 0, 0}}, /* 87 */ + {0, 12, {0, 0, 66, 66, 36, 36, 24, 24, 36, 36, 66, 66, 0, 0}}, /* 88 */ + {0, 12, {0, 0, 34, 34, 34, 20, 20, 8, 8, 8, 8, 8, 0, 0}}, /* 89 */ + {0, 12, {0, 0, 126, 2, 4, 8, 8, 16, 32, 32, 64, 126, 0, 0}}, /* 90 */ + {0, 12, {0, 30, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 30}}, /* 91 */ + {0, 12, {0, 64, 64, 32, 32, 16, 16, 16, 8, 8, 4, 4, 2, 2}}, /* 92 */ + {0, 12, {0, 60, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 60}}, /* 93 */ + {0, 12, {0, 24, 36, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 94 */ + {0, 12, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 126}}, /* 95 */ + {0, 12, {0, 16, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 96 */ + {0, 12, {0, 0, 0, 0, 0, 60, 66, 2, 62, 66, 66, 62, 0, 0}}, /* 97 */ + {0, 12, {0, 0, 64, 64, 64, 92, 98, 66, 66, 66, 98, 92, 0, 0}}, /* 98 */ + {0, 12, {0, 0, 0, 0, 0, 60, 66, 64, 64, 64, 66, 60, 0, 0}}, /* 99 */ + {0, 12, {0, 0, 2, 2, 2, 58, 70, 66, 66, 66, 70, 58, 0, 0}}, /* 100 */ + {0, 12, {0, 0, 0, 0, 0, 60, 66, 66, 126, 64, 66, 60, 0, 0}}, /* 101 */ + {0, 12, {0, 0, 12, 18, 16, 16, 124, 16, 16, 16, 16, 16, 0, 0}}, /* 102 */ + {0, 12, {0, 0, 0, 0, 0, 58, 68, 68, 68, 56, 32, 92, 66, 60}}, /* 103 */ + {0, 12, {0, 0, 64, 64, 64, 92, 98, 66, 66, 66, 66, 66, 0, 0}}, /* 104 */ + {0, 12, {0, 0, 8, 8, 0, 24, 8, 8, 8, 8, 8, 62, 0, 0}}, /* 105 */ + {0, 12, {0, 0, 2, 2, 0, 6, 2, 2, 2, 2, 2, 34, 34, 28}}, /* 106 */ + {0, 12, {0, 0, 64, 64, 64, 68, 72, 80, 112, 72, 68, 66, 0, 0}}, /* 107 */ + {0, 12, {0, 0, 24, 8, 8, 8, 8, 8, 8, 8, 8, 62, 0, 0}}, /* 108 */ + {0, 12, {0, 0, 0, 0, 0, 52, 42, 42, 42, 42, 42, 34, 0, 0}}, /* 109 */ + {0, 12, {0, 0, 0, 0, 0, 92, 98, 66, 66, 66, 66, 66, 0, 0}}, /* 110 */ + {0, 12, {0, 0, 0, 0, 0, 60, 66, 66, 66, 66, 66, 60, 0, 0}}, /* 111 */ + {0, 12, {0, 0, 0, 0, 0, 92, 98, 66, 66, 66, 98, 92, 64, 64}}, /* 112 */ + {0, 12, {0, 0, 0, 0, 0, 58, 70, 66, 66, 66, 70, 58, 2, 2}}, /* 113 */ + {0, 12, {0, 0, 0, 0, 0, 92, 98, 66, 64, 64, 64, 64, 0, 0}}, /* 114 */ + {0, 12, {0, 0, 0, 0, 0, 60, 66, 32, 24, 4, 66, 60, 0, 0}}, /* 115 */ + {0, 12, {0, 0, 16, 16, 16, 124, 16, 16, 16, 16, 18, 12, 0, 0}}, /* 116 */ + {0, 12, {0, 0, 0, 0, 0, 66, 66, 66, 66, 66, 70, 58, 0, 0}}, /* 117 */ + {0, 12, {0, 0, 0, 0, 0, 34, 34, 34, 20, 20, 8, 8, 0, 0}}, /* 118 */ + {0, 12, {0, 0, 0, 0, 0, 34, 34, 42, 42, 42, 42, 20, 0, 0}}, /* 119 */ + {0, 12, {0, 0, 0, 0, 0, 66, 66, 36, 24, 36, 66, 66, 0, 0}}, /* 120 */ + {0, 12, {0, 0, 0, 0, 0, 66, 66, 66, 66, 70, 58, 2, 66, 60}}, /* 121 */ + {0, 12, {0, 0, 0, 0, 0, 126, 4, 8, 16, 16, 32, 126, 0, 0}}, /* 122 */ + {0, 12, {0, 6, 8, 8, 8, 8, 8, 16, 8, 8, 8, 8, 8, 6}}, /* 123 */ + {0, 12, {0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}}, /* 124 */ + {0, 12, {0, 48, 8, 8, 8, 8, 8, 4, 8, 8, 8, 8, 8, 48}}, /* 125 */ + {0, 12, {0, 32, 82, 74, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 126 */ + {0, 12, {0, 90, 66, 0, 66, 66, 0, 66, 66, 0, 66, 90, 0, 0}} /* 127 */ +};