FireBirdLib - Topfield TMS PVR TAP Programming Library
OSDMenuMessageBoxShow.c
Go to the documentation of this file.
1#include <string.h>
2#include "FBLib_TMSOSDMenu.h"
3
5{
7
8 dword x, y, dx, dy, i;
9 char *pText;
10 char *EndOfText;
11 dword Lines;
12 char s[256];
13 TYPE_GrData *MB;
14 tOSDMapInfo *OSDMapInfo;
15
16 if(MessageBox.NrButtons == 0)
17 {
18 TRACEEXIT();
19 return;
20 }
21
23
25 {
26 x = (720 - _InfoBox_Gd.width) >> 1;
27 y = (576 - _InfoBox_Gd.height) >> 1;
28 if(OSDRgn || MyOSDRgn)
29 {
32 if(MyOSDRgn)
33 {
34 OSDMapInfo = (tOSDMapInfo*) FIS_vOsdMap();
35 if(OSDMapInfo)
36 InfoBoxSaveArea = TAP_Osd_SaveBox(MyOSDRgn, InfoBoxSaveAreaX - OSDMapInfo[MyOSDRgn].x, InfoBoxSaveAreaY - OSDMapInfo[MyOSDRgn].y, _InfoBox_Gd.width, _InfoBox_Gd.height);
37 }
38 else
40 }
41 MessageBoxOSDRgn = TAP_Osd_Create(x, y, _InfoBox_Gd.width, _InfoBox_Gd.height, 0, 0);
42 TAP_ExitNormal();
43 }
44 TAP_Osd_PutGd(MessageBoxOSDRgn, 0, 0, &_InfoBox_Gd, FALSE);
45
46 OSDMenuPutS(MessageBoxOSDRgn, 0, 10, 380, MessageBox.Title, RGB(232,146,17), COLOR_None, 14, FALSE, ALIGN_CENTER);
47
48 //Count the number of lines
49 strncpyUC(s, MessageBox.Text, 255);
50 s[255] = '\0';
51 pText = s;
52 EndOfText = s + strlen(s);
53 Lines = 0;
54 while(pText < EndOfText)
55 {
56 Lines++;
57 pText = strpbrk(pText, "\x0d\x0a");
58 if(!pText) break;
59 *pText = '\0';
60 pText++;
61 if (Lines == 7) break;
62 }
63
64 dy = 20;
65 y = 38 - 10 * (Lines - 1);
66 pText = s;
67 for(i = 0; i < Lines; i++)
68 {
69 OSDMenuPutS(MessageBoxOSDRgn, 0, y - 7 + 36, 380, pText, RGB(192,192,192), COLOR_None, 14, FALSE, ALIGN_CENTER);
70 y += dy;
71 pText += (strlen(pText) + 1);
72 }
73
74 dx = _InfoBox_Gd.width / (MessageBox.NrButtons + 1);
75 x = dx;
76
77 //With more than 3 buttons, they overlap. This means that the text is not centered.
78 //Therefore draw inactive buttons first, then the active one
79 for(i = 0; i < MessageBox.NrButtons; i++)
80 {
82 {
83 TAP_Osd_FillBox(MessageBoxOSDRgn, x - (MB->width >> 1), 120, MB->width, MB->height, RGB(36,36,36));
84 OSDMenuPutS(MessageBoxOSDRgn, x - (MB->width >> 1), 124, x + (MB->width >> 1), MessageBox.Button[i], RGB(230,230,250), COLOR_None, 14, FALSE, ALIGN_CENTER);
85 }
86 x += dx;
87 }
88
89 x = (MessageBox.CurrentButton + 1) * dx;
90 TAP_Osd_PutGd(MessageBoxOSDRgn, x - (MB->width >> 1), 120, MB, FALSE);
91 OSDMenuPutS(MessageBoxOSDRgn, x - (MB->width >> 1), 124, x + (MB->width >> 1), MessageBox.Button[MessageBox.CurrentButton], RGB(40,40,40), COLOR_None, 14, FALSE, ALIGN_CENTER);
92
93 TAP_Osd_Sync();
94
95 TRACEEXIT();
96}
dword InfoBoxSaveAreaX
Definition: OSDMenuInit.c:15
TYPE_GrData _MessageBoxSelectedButtonBackground_Gd
tMessageBox MessageBox
Definition: OSDMenuInit.c:19
word MessageBoxOSDRgn
Definition: OSDMenuInit.c:18
void OSDMenuPutS(word rgn, dword x, dword y, dword maxX, const char *str, dword fcolor, dword bcolor, byte fntSize, byte bDot, byte align)
Definition: OSDMenuPutS.c:3
TYPE_GrData _InfoBox_Gd
byte * InfoBoxSaveArea
Definition: OSDMenuInit.c:14
word OSDRgn
Definition: OSDMenuInit.c:4
word MyOSDRgn
Definition: OSDMenuInit.c:4
dword InfoBoxSaveAreaY
dword FIS_vOsdMap(void)
Definition: FIS_vOSDMap.c:3
void OSDMenuMessageBoxShow(void)
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243
byte * strncpyUC(byte *dest, const byte *src, size_t n)
Definition: strncpyUC.c:4
char Title[STDSTRINGSIZE]
char Text[STDSTRINGSIZE]
char Button[MAXMBBUTTONS][STDSTRINGSIZE]