1 #ifndef UTILITY_H 2 #define UTILITY_H 3 4 5 #include <Rect.h> 6 7 8 int secondsToSlider(int val); 9 10 inline BPoint 11 scale_direct(float x, float y, BRect area) 12 { 13 return BPoint(area.Width()*x+area.left,area.Height()*y+area.top); 14 } 15 16 17 inline BRect 18 scale_direct(float x1,float x2,float y1,float y2,BRect area) 19 { 20 return BRect(area.Width()*x1+area.left,area.Height()*y1+area.top, area.Width()*x2+area.left,area.Height()*y2+area.top); 21 } 22 23 static const float kPositionalX[] = {0,.1,.25,.3,.7,.75,.9,1.0}; 24 static const float kPositionalY[] = {0,.1,.7,.8,.9,1.0}; 25 26 inline BPoint 27 scale(int x, int y,BRect area) 28 { 29 return scale_direct(kPositionalX[x],kPositionalY[y],area); 30 } 31 32 33 inline BRect 34 scale(int x1, int x2, int y1, int y2,BRect area) 35 { 36 return scale_direct(kPositionalX[x1], kPositionalX[x2], 37 kPositionalY[y1], kPositionalY[y2], area); 38 } 39 40 #endif // UTILITY_H 41