FireBirdLib - Topfield TMS PVR TAP Programming Library
OSDDrawList.c
Go to the documentation of this file.
1#include "FBLib_TMSOSDMenu.h"
2
3void OSDDrawList(void)
4{
6
7 int i, YText, hL, dLines;
8 dword XStart, XEnd, yT, yL;
9 tMenu *pMenu;
10 tItem *pItem;
11 dword ItemColor;
12 char s[4];
13 dword MaxNameIconWidth, MaxValueIconWidth;
14 word ItemRgn = 0;
15
16 pMenu = &Menu[CurrentMenuLevel];
17
18 //Get maximum width of icons
19 MaxNameIconWidth = 0;
20 MaxValueIconWidth = 0;
21 for(i = 0; i < pMenu->NrItems; i++)
22 {
23 if(pMenu->Item[i].pNameIconGd && (pMenu->Item[i].pNameIconGd->width > MaxNameIconWidth)) MaxNameIconWidth = pMenu->Item[i].pNameIconGd->width;
24 if(pMenu->Item[i].pValueIconGd && (pMenu->Item[i].pValueIconGd->width > MaxValueIconWidth)) MaxValueIconWidth = pMenu->Item[i].pValueIconGd->width;
25 if(pMenu->Item[i].ColorPatch && (MaxValueIconWidth < 50)) MaxValueIconWidth = 50;
26 }
27
28 if(MaxNameIconWidth) MaxNameIconWidth += 8;
29 if(MaxValueIconWidth) MaxValueIconWidth += 8;
30
31 switch (pMenu->NrLines)
32 {
33 case 18:
34 YText = 96 - (5 + FONTYOFFSET);
35 hL = 19;
36 break;
37
38 case 15:
39 YText = 96 - (5 + FONTYOFFSET);
40 hL = 23;
41 break;
42
43 default:
44 YText = 101 - (5 + FONTYOFFSET);
45 hL = 35;
46 break;
47 }
48
49 dLines = hL + 2;
50
51 //The background
52 TAP_Osd_Draw3dBoxFill(OSDRgn, pMenu->XPos, 96, pMenu->Width, pMenu->NrLines * dLines - 2, RGB(30, 30, 30), RGB(30, 30, 30), RGB(30, 30, 30));
53
54 for(i = 0; i < pMenu->NrLines; i++)
55 {
56 yL = 96 + (i * dLines);
57
58 TAP_Osd_DrawRectangle(OSDRgn, pMenu->XPos, yL + hL, pMenu->Width, 2, 1, RGB(16, 16, 16));
59
60 pItem = &pMenu->Item[i + pMenu->CurrentTopIndex];
61
62 if ((i + pMenu->CurrentTopIndex) < pMenu->NrItems)
63 {
64 //Draw the background or selection bar and the optional value arrows
65 if ((i + pMenu->CurrentTopIndex) == pMenu->CurrentSelection)
66 {
67 OSDMenuDrawCursor(pMenu->XPos, yL, pMenu->Width, hL);
68
69 if (pMenu->HasValueColumn && pItem->ValueArrows)
70 {
71 TAP_Osd_PutGd(OSDRgn, pMenu->ValueXPos + 20, yL + ((hL - _pfeil_l_Gd.height) >> 1), (MenuCursorType == CT_Standard ? &_pfeil_l_Gd : &_pfeil_l_bright_Gd), TRUE);
72 TAP_Osd_PutGd(OSDRgn, pMenu->XPos + pMenu->Width - 20, yL + ((hL - _pfeil_r_Gd.height) >> 1), (MenuCursorType == CT_Standard ? &_pfeil_r_Gd : &_pfeil_r_bright_Gd), TRUE);
73 }
74 }
75
76 //Draw line content
77
78 XEnd = (pMenu->HasValueColumn && (pItem->ValueArrows || *pItem->Value) ? pMenu->ValueXPos : pMenu->XPos + pMenu->Width - 15);
79 yT = YText + (i * dLines);
80
81 if(pItem->Selectable)
82 ItemColor = pItem->TextColor;
83 else
84 ItemColor = RGB(128, 128, 140);
85
86 //Line numbers
87 if(pMenu->NumberedItems)
88 {
89 int MaxX = 100;
90
91 XStart = 101;
92
93 if(pItem->CustomIndex >= 0)
94 {
95 TAP_SPrint(s, "%2.2d", pItem->CustomIndex);
96
97 if(pItem->CustomIndex > 99)
98 {
99 XStart += 10;
100 MaxX += 10;
101 }
102
103 if(pItem->CustomIndex > 999)
104 {
105 XStart += 10;
106 MaxX += 10;
107 }
108 }
109 else
110 {
111 TAP_SPrint(s, "%2.2d", i + pMenu->CurrentTopIndex + 1);
112
113 if(i + pMenu->CurrentTopIndex + 1 > 99)
114 {
115 XStart += 10;
116 MaxX += 10;
117 }
118
119 if(i + pMenu->CurrentTopIndex + 1 > 999)
120 {
121 XStart += 10;
122 MaxX += 10;
123 }
124 }
125
126 FMUC_PutStringAA(OSDRgn, pMenu->XPos + 11, yT + 5 + FONTYOFFSET, MaxX, s, ItemColor, COLOR_None, pMenu->FontListLineNumber, FALSE, ALIGN_LEFT, 1);
127 }
128 else
129 {
130 XStart = pMenu->XPos + 16;
131 }
132
133 //Icons on the left column
134 if(pItem->pNameIconGd)
135 TAP_Osd_PutGd(OSDRgn, XStart, yL + ((hL - pItem->pNameIconGd->height) >> 1), pItem->pNameIconGd, TRUE);
136
137 //The text of the left column
138 if (pItem->drawName) FMUC_PutStringAA(OSDRgn, XStart + MaxNameIconWidth, yT + 5 + FONTYOFFSET, XEnd, pItem->Name, pItem->Selectable ? pItem->NameColor : ItemColor, COLOR_None, pMenu->FontListNameColumn, TRUE, ALIGN_LEFT, 1);
139
140 if(pMenu->HasValueColumn)
141 {
142 //The text of the right column
143 if (pItem->drawValue) FMUC_PutStringAA(OSDRgn, pMenu->ValueXPos + 30 + pMenu->ValueXOffset + MaxValueIconWidth, yT + 5 + FONTYOFFSET, pMenu->XPos + pMenu->Width - 15, pItem->Value, ItemColor, COLOR_None, pMenu->FontListValueColumn, TRUE, ALIGN_LEFT, 1);
144
145 //The color patch or icon of the right column. The former has priority
146 if(pItem->ColorPatch)
147 {
148 TAP_Osd_FillBox(OSDRgn, pMenu->ValueXPos + 30 + pMenu->ValueXOffset, yL + ((hL - 18) >> 1) + 1, 50, 18, (pItem->ColorPatch & 0x00ffffff) | 0xff000000);
149 TAP_Osd_DrawRectangle(OSDRgn, pMenu->ValueXPos + 30 + pMenu->ValueXOffset, yL + ((hL - 18) >> 1) + 1, 50, 18, 1, RGB(192,192,192));
150 }
151 else
152 {
153 if(pItem->pValueIconGd)
154 TAP_Osd_PutGd(OSDRgn, pMenu->ValueXPos + 30 + pMenu->ValueXOffset, yL + ((hL - pItem->pValueIconGd->height) >> 1), pItem->pValueIconGd, TRUE);
155 }
156 }
157
158 if (pItem->passDrawing && pMenu->CallbackProcedure)
159 {
160 if (!ItemRgn) ItemRgn = TAP_Osd_Create(0, 0, pMenu->Width, hL, 0, OSD_Flag_MemRgn);
161
162 TAP_Osd_Copy(OSDRgn, ItemRgn, pMenu->XPos, yL, pMenu->Width, hL, 0, 0, FALSE);
163 pMenu->CallbackProcedure(OSDCB_ListItem | (pItem->ID << 8), ItemRgn);
164 TAP_Osd_Copy(ItemRgn, OSDRgn, 0, 0, pMenu->Width, hL, pMenu->XPos, yL, FALSE);
165 }
166 }
167 }
168
169 if (ItemRgn) TAP_Osd_Delete(ItemRgn);
170
172
173 TRACEEXIT();
174}
#define FONTYOFFSET
void OSDMenuDrawCursor(dword x, dword y, dword w, dword h)
tMenu Menu[NRMENULEVELS]
Definition: OSDMenuInit.c:6
TYPE_GrData _pfeil_r_bright_Gd
TYPE_GrData _pfeil_l_Gd
TYPE_GrData _pfeil_l_bright_Gd
dword CurrentMenuLevel
Definition: OSDMenuInit.c:7
word OSDRgn
Definition: OSDMenuInit.c:4
tCursorType MenuCursorType
Definition: OSDMenuInit.c:9
TYPE_GrData _pfeil_r_Gd
void FMUC_PutStringAA(word rgn, dword x, dword y, dword maxX, const char *str, dword fcolor, dword bcolor, tFontDataUC *FontData, byte bDot, byte align, float AntiAliasFactor)
void OSDDrawList(void)
Definition: OSDDrawList.c:3
@ OSDCB_ListItem
Definition: libFireBird.h:2795
@ OSDCB_List
Definition: libFireBird.h:2792
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243
@ CT_Standard
Definition: libFireBird.h:2748
dword TextColor
dword ColorPatch
bool drawValue
char Name[ITEMNAMESIZE]
bool Selectable
TYPE_GrData * pNameIconGd
int CustomIndex
dword ID
bool drawName
bool passDrawing
char Value[ITEMVALUESIZE]
TYPE_GrData * pValueIconGd
dword NameColor
bool ValueArrows
tFontDataUC * FontListLineNumber
void(* CallbackProcedure)(tOSDCB OSDCBType, word OSDRgn)
int CurrentSelection
bool NumberedItems
dword XPos
dword Width
int CurrentTopIndex
tItem * Item
bool HasValueColumn
tFontDataUC * FontListNameColumn
dword ValueXPos
tFontDataUC * FontListValueColumn
int ValueXOffset