FireBirdLib - Topfield TMS PVR TAP Programming Library
DrawScrollbar.c
Go to the documentation of this file.
1#include "libFireBird.h"
2
3//Greyscale for background
4int sbBackground[15][3] =
5{
6 {16, 16, 16},
7 {16, 16, 16},
8 {21, 21, 21},
9 {26, 26, 26},
10 {31, 31, 31},
11 {37, 37, 37},
12 {43, 43, 43},
13 {50, 50, 50},
14 {56, 56, 56},
15 {63, 63, 63},
16 {70, 70, 70},
17 {77, 77, 77},
18 {84, 84, 84},
19 {92, 92, 92},
20 {118, 118, 118}
21};
22
23//Greyscale for the slider
24int sbSlider[13][3] =
25{
26 {165, 165, 165},
27 {149, 148, 149},
28 {129, 129, 129},
29 {108, 107, 108},
30 {86, 85, 86},
31 {65, 65, 65},
32 {48, 47, 48},
33 {35, 35, 36},
34 {30, 30, 30},
35 {31, 31, 31},
36 {36, 36, 37},
37 {45, 45, 45},
38 {56, 56, 57}
39};
40
41//Greyscale for top border
42int sbTopBorder[15][3] =
43{
44 {51, 51, 51},
45 {122, 122, 122},
46 {125, 125, 125},
47 {127, 127, 127},
48 {130, 130, 130},
49 {134, 134, 134},
50 {137, 137, 137},
51 {141, 141, 141},
52 {144, 144, 144},
53 {148, 148, 148},
54 {152, 152, 152},
55 {156, 156, 156},
56 {160, 160, 160},
57 {164, 164, 164},
58 {163, 163, 163}
59};
60
61//Greyscale for bottom border
62int sbBotBorder[15][3] =
63{
64 {4, 4, 4},
65 {4, 4, 4},
66 {6, 6, 6},
67 {7, 7, 7},
68 {16, 16, 16},
69 {10, 10, 10},
70 {12, 12, 12},
71 {14, 14, 14},
72 {15, 15, 15},
73 {17, 17, 17},
74 {19, 19, 19},
75 {21, 21, 21},
76 {23, 23, 23},
77 {25, 25, 25},
78 {65, 65, 65}
79};
80
81dword sbArrow = RGB(176, 177, 177);
82
83//sbX & sbY Top left coordinates
84//sbHeight Overall height of the scroll bar
85//sbCurrent Current "location" value
86//sbWindow The size of the entire range that the height of the slider represents.
87//sbMax Maximum "location" value. Valid locations are zero to sbMax.
88
89void DrawScrollbar(word sbRegion, int sbX, int sbY, int sbHeight, int sbCurrent, int sbWindow, int sbMax)
90{
91 TRACEENTER();
92
93 if(sbWindow > sbMax) sbWindow = sbMax;
94
95 int i = 0;
96
97 //Draw the background
98 for(i = 0; i < 15; i++)
99 {
100 TAP_Osd_FillBox(sbRegion, sbX + i, sbY, 1, sbHeight, RGB(sbBackground[i][0], sbBackground[i][1], sbBackground[i][2]));
101 }
102
103 //Draw the top and bottom borders
104 for(i = 0; i < 15; i++)
105 {
106 TAP_Osd_FillBox(sbRegion, sbX + i, sbY, 1, 1, RGB(sbTopBorder[i][0], sbTopBorder[i][1], sbTopBorder[i][2]));
107 TAP_Osd_FillBox(sbRegion, sbX + i, sbY + sbHeight, 1, 1, RGB(sbBotBorder[i][0], sbBotBorder[i][1], sbBotBorder[i][2]));
108 }
109
110 //Draw the top arrow
111 TAP_Osd_FillBox(sbRegion, sbX + 7, sbY + 2, 1, 1, sbArrow);
112 TAP_Osd_FillBox(sbRegion, sbX + 6, sbY + 3, 3, 1, sbArrow);
113 TAP_Osd_FillBox(sbRegion, sbX + 5, sbY + 4, 5, 1, sbArrow);
114 TAP_Osd_FillBox(sbRegion, sbX + 4, sbY + 5, 7, 1, sbArrow);
115 TAP_Osd_FillBox(sbRegion, sbX + 3, sbY + 6, 9, 1, sbArrow);
116
117 //Draw the bottom arrow
118 TAP_Osd_FillBox(sbRegion, sbX + 7, sbY + sbHeight - 2, 1, 1, sbArrow);
119 TAP_Osd_FillBox(sbRegion, sbX + 6, sbY + sbHeight - 3, 3, 1, sbArrow);
120 TAP_Osd_FillBox(sbRegion, sbX + 5, sbY + sbHeight - 4, 5, 1, sbArrow);
121 TAP_Osd_FillBox(sbRegion, sbX + 4, sbY + sbHeight - 5, 7, 1, sbArrow);
122 TAP_Osd_FillBox(sbRegion, sbX + 3, sbY + sbHeight - 6, 9, 1, sbArrow);
123
124 //Draw the slider
125
126 //The height of the slider is sbHeight * sbWindow / sbMax
127 //The location of the slider is sbY + (sbHeight * sbCurrent / sbMax)
128
129 for(i = 0; i < 13; i++)
130 {
131 TAP_Osd_FillBox(sbRegion, (sbX + 1 + i), sbY + ((sbHeight-26) * sbCurrent / sbMax) + 13, 1, ((sbHeight-26) * sbWindow / sbMax), RGB(sbSlider[i][0], sbSlider[i][1], sbSlider[i][2]));
132 }
133
134 TRACEEXIT();
135}
int sbTopBorder[15][3]
Definition: DrawScrollbar.c:42
dword sbArrow
Definition: DrawScrollbar.c:81
int sbBotBorder[15][3]
Definition: DrawScrollbar.c:62
int sbBackground[15][3]
Definition: DrawScrollbar.c:4
int sbSlider[13][3]
Definition: DrawScrollbar.c:24
void DrawScrollbar(word sbRegion, int sbX, int sbY, int sbHeight, int sbCurrent, int sbWindow, int sbMax)
Definition: DrawScrollbar.c:89
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243