OLD | NEW |
1 #include <u.h> | 1 #include <u.h> |
2 #include <libc.h> | 2 #include <libc.h> |
3 #include <draw.h> | 3 #include <draw.h> |
4 #include <mouse.h> | 4 #include <mouse.h> |
5 #include <frame.h> | 5 #include <frame.h> |
6 | 6 |
7 void | 7 void |
8 frinit(Frame *f, Rectangle r, Font *ft, Image *b, Image *cols[NCOL]) | 8 frinit(Frame *f, Rectangle r, Font *ft, Image *b, Image *cols[NCOL]) |
9 { | 9 { |
10 f->font = ft; | 10 f->font = ft; |
(...skipping 13 matching lines...) Expand all Loading... |
24 if(f->tick==nil && f->cols[BACK]!=0) | 24 if(f->tick==nil && f->cols[BACK]!=0) |
25 frinittick(f); | 25 frinittick(f); |
26 } | 26 } |
27 | 27 |
28 void | 28 void |
29 frinittick(Frame *f) | 29 frinittick(Frame *f) |
30 { | 30 { |
31 Image *b; | 31 Image *b; |
32 Font *ft; | 32 Font *ft; |
33 | 33 |
| 34 if(f->cols[BACK] == nil || f->display == nil) |
| 35 return; |
| 36 f->tickscale = scalesize(f->display, 1); |
34 b = f->display->screenimage; | 37 b = f->display->screenimage; |
35 ft = f->font; | 38 ft = f->font; |
36 if(f->tick) | 39 if(f->tick) |
37 freeimage(f->tick); | 40 freeimage(f->tick); |
38 » f->tick = allocimage(f->display, Rect(0, 0, FRTICKW, ft->height), b->cha
n, 0, DWhite); | 41 » f->tick = allocimage(f->display, Rect(0, 0, f->tickscale*FRTICKW, ft->he
ight), b->chan, 0, DWhite); |
39 if(f->tick == nil) | 42 if(f->tick == nil) |
40 return; | 43 return; |
41 if(f->tickback) | 44 if(f->tickback) |
42 freeimage(f->tickback); | 45 freeimage(f->tickback); |
43 f->tickback = allocimage(f->display, f->tick->r, b->chan, 0, DWhite); | 46 f->tickback = allocimage(f->display, f->tick->r, b->chan, 0, DWhite); |
44 if(f->tickback == 0){ | 47 if(f->tickback == 0){ |
45 freeimage(f->tick); | 48 freeimage(f->tick); |
46 f->tick = 0; | 49 f->tick = 0; |
47 return; | 50 return; |
48 } | 51 } |
49 /* background color */ | 52 /* background color */ |
50 draw(f->tick, f->tick->r, f->cols[BACK], nil, ZP); | 53 draw(f->tick, f->tick->r, f->cols[BACK], nil, ZP); |
51 /* vertical line */ | 54 /* vertical line */ |
52 » draw(f->tick, Rect(FRTICKW/2, 0, FRTICKW/2+1, ft->height), f->display->b
lack, nil, ZP); | 55 » draw(f->tick, Rect(f->tickscale*(FRTICKW/2), 0, f->tickscale*(FRTICKW/2+
1), ft->height), f->display->black, nil, ZP); |
53 /* box on each end */ | 56 /* box on each end */ |
54 » draw(f->tick, Rect(0, 0, FRTICKW, FRTICKW), f->cols[TEXT], nil, ZP); | 57 » draw(f->tick, Rect(0, 0, f->tickscale*FRTICKW, f->tickscale*FRTICKW), f-
>cols[TEXT], nil, ZP); |
55 » draw(f->tick, Rect(0, ft->height-FRTICKW, FRTICKW, ft->height), f->cols[
TEXT], nil, ZP); | 58 » draw(f->tick, Rect(0, ft->height-f->tickscale*FRTICKW, f->tickscale*FRTI
CKW, ft->height), f->cols[TEXT], nil, ZP); |
56 } | 59 } |
57 | 60 |
58 void | 61 void |
59 frsetrects(Frame *f, Rectangle r, Image *b) | 62 frsetrects(Frame *f, Rectangle r, Image *b) |
60 { | 63 { |
61 f->b = b; | 64 f->b = b; |
62 f->entire = r; | 65 f->entire = r; |
63 f->r = r; | 66 f->r = r; |
64 f->r.max.y -= (r.max.y-r.min.y)%f->font->height; | 67 f->r.max.y -= (r.max.y-r.min.y)%f->font->height; |
65 f->maxlines = (r.max.y-r.min.y)/f->font->height; | 68 f->maxlines = (r.max.y-r.min.y)/f->font->height; |
66 } | 69 } |
67 | 70 |
68 void | 71 void |
69 frclear(Frame *f, int freeall) | 72 frclear(Frame *f, int freeall) |
70 { | 73 { |
71 if(f->nbox) | 74 if(f->nbox) |
72 _frdelbox(f, 0, f->nbox-1); | 75 _frdelbox(f, 0, f->nbox-1); |
73 if(f->box) | 76 if(f->box) |
74 free(f->box); | 77 free(f->box); |
75 if(freeall){ | 78 if(freeall){ |
76 freeimage(f->tick); | 79 freeimage(f->tick); |
77 freeimage(f->tickback); | 80 freeimage(f->tickback); |
78 f->tick = 0; | 81 f->tick = 0; |
79 f->tickback = 0; | 82 f->tickback = 0; |
80 } | 83 } |
81 f->box = 0; | 84 f->box = 0; |
82 f->ticked = 0; | 85 f->ticked = 0; |
83 } | 86 } |
OLD | NEW |