1 #include "RefreshSlider.h" 2 #include "Constants.h" 3 4 #include <Window.h> 5 6 #include <stdio.h> 7 8 9 RefreshSlider::RefreshSlider(BRect frame) 10 :BSlider(frame, "Screen", "Refresh Rate:", 11 new BMessage(SLIDER_INVOKE_MSG), gMinRefresh * 10, gMaxRefresh * 10), 12 fStatus(new char[32]) 13 { 14 } 15 16 17 RefreshSlider::~RefreshSlider() 18 { 19 delete[] fStatus; 20 } 21 22 23 void 24 RefreshSlider::DrawFocusMark() 25 { 26 if (IsFocus()) { 27 rgb_color blue = { 0, 0, 229, 255 }; 28 29 BRect rect(ThumbFrame()); 30 BView *view = OffscreenView(); 31 32 rect.InsetBy(2.0, 2.0); 33 rect.right--; 34 rect.bottom--; 35 36 view->SetHighColor(blue); 37 view->StrokeRect(rect); 38 } 39 } 40 41 42 void 43 RefreshSlider::KeyDown(const char *bytes, int32 numBytes) 44 { 45 switch (*bytes) { 46 case B_LEFT_ARROW: 47 { 48 SetValue(Value() - 1); 49 Invoke(); 50 break; 51 } 52 53 case B_RIGHT_ARROW: 54 { 55 SetValue(Value() + 1); 56 Invoke(); 57 break; 58 } 59 60 default: 61 break; 62 } 63 } 64 65 66 char* 67 RefreshSlider::UpdateText() const 68 { 69 if (fStatus) { 70 sprintf(fStatus, "%.1f Hz", (float)Value() / 10); 71 return fStatus; 72 } else 73 return NULL; 74 } 75 76