]>
git.ipfire.org Git - thirdparty/newt.git/blob - scale.c
13 static void scaleDraw(newtComponent co
);
15 static struct componentOps scaleOps
= {
17 newtDefaultEventHandler
,
19 newtDefaultPlaceHandler
,
20 newtDefaultMappedHandler
,
23 newtComponent
newtScale(int left
, int top
, int width
, long long fullValue
) {
27 co
= malloc(sizeof(*co
));
28 sc
= malloc(sizeof(struct scale
));
39 sc
->fullValue
= fullValue
;
45 void newtScaleSet(newtComponent co
, unsigned long long amount
) {
46 struct scale
* sc
= co
->data
;
49 newCharsSet
= (amount
* co
->width
) / sc
->fullValue
;
51 if (newCharsSet
!= sc
->charsSet
) {
52 sc
->charsSet
= newCharsSet
;
57 static void scaleDraw(newtComponent co
) {
58 struct scale
* sc
= co
->data
;
61 if (co
->top
== -1) return;
63 newtGotorc(co
->top
, co
->left
);
65 SLsmg_set_color(NEWT_COLORSET_FULLSCALE
);
66 for (i
= 0; i
< sc
->charsSet
; i
++)
67 SLsmg_write_string(" ");
69 SLsmg_set_color(NEWT_COLORSET_EMPTYSCALE
);
70 for (i
= 0; i
< (co
->width
- sc
->charsSet
); i
++)
71 SLsmg_write_string(" ");