00001 #ifndef _XF_TEXT_
00002 #define _XF_TEXT_
00003
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007
00008 #include "xf_types.h"
00009 #include "xf_params.h"
00010
00011 #define ALIGN_LEFT 0
00012 #define ALIGN_RIGHT 1
00013 #define ALIGN_CENTER 2
00014 #define ALIGN_JUSTIFY 3
00015
00016 #define TEXT_SLOTS 256
00017
00018
00019 typedef struct{
00020 u8 linespacing;
00021 u8 letterspacing;
00022 u8 align, alpha, bg;
00023 } xf_textinfo_type;
00024 extern xf_textinfo_type xf_textinfo;
00025
00026
00027 typedef struct {
00028 char Letter;
00029 s16 X, Y;
00030 } XF_Letter;
00031
00032 typedef struct{
00033 s32 NLetters;
00034 XF_Letter Letter[2048];
00035 } XF_TextTemp;
00036 extern XF_TextTemp XF_LetterPos;
00037
00038
00039
00040 typedef struct{
00041 s32 NLetters;
00042 u8 Size;
00043 u16 Color;
00044 u8 Alpha;
00045 s16 x0, y0, x1, y1;
00046 u16 MallocSize;
00047 u8 alpha;
00048 s8 letterspacing, linespacing, align;
00049 XF_Letter *Letter;
00050 } XF_TextSlot_type;
00051 extern XF_TextSlot_type *XF_TextSlot[N_BG];
00052
00053
00054 s16 XF_Text(u8 slot, s16 basex, s16 basey, s16 maxx, s16 maxy, char* text, u16 color, u8 size, s32 limit);
00055
00056
00057
00058
00068 void XF_LoadTextBg(u8 bg_number);
00069 void XF_ClearText(u8 slot);
00070 void XF_ResetTextBg(u8 bg);
00071
00072 extern inline void XF_SetDefaultTextAlign(u8 align){
00073 xf_textinfo.align = align;
00074 }
00075
00076 extern inline void XF_SetDefaultTextLineSpacing(u8 spacing){
00077 xf_textinfo.linespacing = spacing;
00078 }
00079 extern inline void XF_SetDefaultTextLetterSpacing(u8 spacing){
00080 xf_textinfo.letterspacing = spacing;
00081 }
00082
00083 extern inline void XF_SetDefaultTextAlpha(u8 alpha){
00084 xf_textinfo.alpha = alpha;
00085 }
00086
00087
00088
00089 extern inline void XF_ResetText(void){
00090 XF_ResetTextBg(xf_textinfo.bg);
00091 }
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 s16 XF_CreateTextEx(u8 bg, u8 slot, s16 basex, s16 basey, s16 maxx, s16 maxy, char* text, u16 color, u8 size, u8 alpha, s8 letterspacing, s8 linespacing, s8 align, s32 limit);
00102
00103
00104
00105
00106
00107
00108 extern inline void XF_SetTextBgColor(u8 bg, u8 slot, u16 color){
00109 XF_TextSlot[bg][slot].Color = color;
00110 }
00111
00112 extern inline void XF_SetTextColor(u8 slot, u16 color){
00113 XF_SetTextBgColor(xf_textinfo.bg, slot, color);
00114 }
00115
00116 extern inline void XF_SetTextBgAlpha(u8 bg, u8 slot, u8 alpha){
00117 XF_TextSlot[bg][slot].Alpha = alpha;
00118 }
00119
00120 extern inline void XF_SetTextAlpha(u8 slot, u8 alpha){
00121 XF_SetTextBgAlpha(xf_textinfo.bg, slot, alpha);
00122 }
00123
00124 extern inline void XF_SetDefaultTextBg(u8 bg){
00125 xf_textinfo.bg = bg;
00126 }
00127
00128
00129 extern inline s16 XF_CreateText(u8 slot, s16 basex, s16 basey, s16 maxx, s16 maxy, char* text, u16 color, u8 size, s32 limit){
00130 return XF_CreateTextEx(xf_textinfo.bg, slot, basex, basey, maxx, maxy, text, color, size, xf_textinfo.alpha, xf_textinfo.letterspacing, xf_textinfo.linespacing, xf_textinfo.align, limit);
00131 }
00132
00133
00134 extern inline s16 XF_SetTextLimit(u8 slot, char *text, s32 limit){
00135 return XF_CreateTextEx(xf_textinfo.bg, slot, XF_TextSlot[xf_textinfo.bg][slot].x0, XF_TextSlot[xf_textinfo.bg][slot].y0, XF_TextSlot[xf_textinfo.bg][slot].x1, XF_TextSlot[xf_textinfo.bg][slot].y1, text, XF_TextSlot[xf_textinfo.bg][slot].Color, XF_TextSlot[xf_textinfo.bg][slot].Size, XF_TextSlot[xf_textinfo.bg][slot].alpha, XF_TextSlot[xf_textinfo.bg][slot].letterspacing, XF_TextSlot[xf_textinfo.bg][slot].linespacing, XF_TextSlot[xf_textinfo.bg][slot].align, limit);
00136 }
00137
00138
00139
00140 extern inline s16 XF_SetText(u8 slot, char *text){
00141 return XF_SetTextLimit(slot, text, 1<<24);
00142 }
00143
00144 extern inline s16 XF_SetTextPos(u8 slot, s16 basex, s16 basey, s16 maxx, s16 maxy, char *text, s32 limit){
00145 return XF_CreateTextEx(xf_textinfo.bg, slot, basex, basey, maxx, maxy, text, XF_TextSlot[xf_textinfo.bg][slot].Color, XF_TextSlot[xf_textinfo.bg][slot].Size, XF_TextSlot[xf_textinfo.bg][slot].alpha, XF_TextSlot[xf_textinfo.bg][slot].letterspacing, XF_TextSlot[xf_textinfo.bg][slot].linespacing, XF_TextSlot[xf_textinfo.bg][slot].align, limit);
00146 }
00147
00148
00149
00150 extern XF_Font *xf_fonts[16];
00151 #define XF_SetTextFont(slot, font) xf_fonts[slot] = font
00152
00153
00154
00156
00157
00158 #ifdef __cplusplus
00159 }
00160 #endif
00161
00162
00163
00164
00165
00166
00167
00168
00169 #endif
00170
00171
00172
00173