FireBirdLib - Topfield TMS PVR TAP Programming Library
OSDCalcIndices.c
Go to the documentation of this file.
1#include <string.h>
2#include "FBLib_TMSOSDMenu.h"
3
4void OSDCalcIndices(void)
5{
7
8 tMenu *pMenu;
9
10 pMenu = &Menu[CurrentMenuLevel];
11
12 //if TopIndex or SelectionIndex has changed, make list dirty
14 {
15 pMenu->CurrentTopIndex = pMenu->CurrentSelection;
16
17 if (pMenu->OSDMenuDisplayMode == OMDM_Text)
18 {
19 if (pMenu->CurrentTopIndex + pMenu->NrLines > pMenu->NrItems)
20 {
21 pMenu->CurrentTopIndex = pMenu->NrItems - pMenu->NrLines;
22
23 if (pMenu->CurrentTopIndex < 0) pMenu->CurrentTopIndex = 0;
24
25 pMenu->CurrentSelection = pMenu->CurrentTopIndex;
26 }
27 }
28 }
29 else
30 {
31 if(pMenu->CurrentSelection < pMenu->CurrentTopIndex)
32 {
33 if(pMenu->CurrentSelection > 0)
34 {
35 //Check if there are selectable items above the current selection
36 bool Selectable;
37 int i;
38
39 Selectable = FALSE;
40 for(i = pMenu->CurrentSelection - 1; i >= 0; i--)
41 {
42 if(pMenu->Item[i].Selectable)
43 {
44 Selectable = TRUE;
45 break;
46 }
47 }
48 if(Selectable)
49 pMenu->CurrentTopIndex = pMenu->CurrentSelection;
50 else
51 pMenu->CurrentTopIndex = 0;
52 }
53 else
54 {
55 pMenu->CurrentTopIndex = pMenu->CurrentSelection;
56 }
57 }
58
59
60 if(pMenu->CurrentSelection > (pMenu->CurrentTopIndex + pMenu->NrLines - 1))
61 {
62 if(pMenu->CurrentSelection < pMenu->NrItems - 1)
63 {
64 //Check if there are selectable items above the current selection
65 bool Selectable;
66 int i;
67
68 Selectable = FALSE;
69 for(i = pMenu->CurrentSelection + 1; i < pMenu->NrItems; i++)
70 {
71 if(pMenu->Item[i].Selectable)
72 {
73 Selectable = TRUE;
74 break;
75 }
76 }
77 if(Selectable)
78 pMenu->CurrentTopIndex = pMenu->CurrentSelection - pMenu->NrLines + 1;
79 else
80 pMenu->CurrentTopIndex = pMenu->NrItems - pMenu->NrLines;
81
82 if((pMenu->CurrentSelection - pMenu->CurrentTopIndex) > pMenu->NrLines)
83 pMenu->CurrentTopIndex = pMenu->CurrentSelection - pMenu->NrLines;
84 }
85 else
86 {
87 pMenu->CurrentTopIndex = pMenu->CurrentSelection - pMenu->NrLines + 1;
88 }
89 }
90 }
91
92 TRACEEXIT();
93}
tMenu Menu[NRMENULEVELS]
Definition: OSDMenuInit.c:6
@ OMDM_Text
@ OMDM_Memo
dword CurrentMenuLevel
Definition: OSDMenuInit.c:7
void OSDCalcIndices(void)
Definition: OSDCalcIndices.c:4
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243
bool Selectable
int CurrentSelection
int CurrentTopIndex
tItem * Item
tOSDMenuDisplayMode OSDMenuDisplayMode