FireBirdLib - Topfield TMS PVR TAP Programming Library
OSDMemoFormatText.c
Go to the documentation of this file.
1#include <string.h>
2#include "FBLib_TMSOSDMenu.h"
3
4#define HORSPACE 568
5
7{
8 tMenu *pMenu;
9 dword spW, Width = 0;
10 char *buffer, *from, *upto, *p, c;
11
12 TRACEENTER();
13
14 pMenu = &Menu[CurrentMenuLevel];
15
16 if (!pMenu->MemoText)
17 {
18 TRACEEXIT();
19 return;
20 }
21
23
24 spW = FMUC_GetStringWidth(" ", pMenu->FontMemo);
25
26 buffer = TAP_MemAlloc(strlen(pMenu->MemoText) + 1);
27 strcpy(buffer, pMenu->MemoText);
28
29 from = buffer;
30 upto = from - 1;
31
32 while ((p = strpbrk(upto + 1, " \n")))
33 {
34 c = *p;
35 *p = 0;
36
37 Width += FMUC_GetStringWidth(upto + 1, pMenu->FontMemo) + (c == ' ' ? spW : 0);
38
39 if (Width > HORSPACE)
40 {
41 if (upto < from) upto = p;
42
43 *upto = 0;
44 OSDMenuItemAdd(from, NULL, NULL, NULL, TRUE, FALSE, 0);
45 from = upto + 1;
46 Width = 0;
47 }
48 else
49 {
50 if (c == '\n')
51 {
52 OSDMenuItemAdd(*from ? from : " ", NULL, NULL, NULL, TRUE, FALSE, 0);
53 from = p + 1;
54 Width = 0;
55 }
56
57 upto = p;
58 }
59
60 *p = c;
61 }
62
63 TAP_MemFree(buffer);
64
65 TRACEEXIT();
66}
tMenu Menu[NRMENULEVELS]
Definition: OSDMenuInit.c:6
dword CurrentMenuLevel
Definition: OSDMenuInit.c:7
dword FMUC_GetStringWidth(const char *Text, tFontDataUC *FontData)
void OSDMemoFormatText(void)
#define HORSPACE
void OSDMenuItemsClear(void)
bool OSDMenuItemAdd(const char *Name, const char *Value, TYPE_GrData *pNameIconGd, TYPE_GrData *pValueIconGd, bool Selectable, bool ValueArrows, dword ID)
Definition: OSDMenuItemAdd.c:5
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243
char * MemoText
tFontDataUC * FontMemo