2 * Copyright 2001-2006, Haiku.
3 * Distributed under the terms of the MIT License.
7 * Stefano Ceccherini (burton666@libero.it)
8 * Axel Dörfler, axeld@pinc-software.de
12 #include "RefreshSlider.h"
13 #include "Constants.h"
23 #undef B_TRANSLATION_CONTEXT
24 #define B_TRANSLATION_CONTEXT "Screen"
27 RefreshSlider::RefreshSlider(BRect frame
, float min
, float max
, uint32 resizingMode
)
28 : BSlider(frame
, B_TRANSLATE("Screen"), B_TRANSLATE("Refresh rate:"),
29 new BMessage(SLIDER_INVOKE_MSG
), (int32
)rintf(min
* 10), (int32
)rintf(max
* 10),
30 B_BLOCK_THUMB
, resizingMode
),
31 fStatus(new (std::nothrow
) char[32])
34 minRefresh
<< (uint32
)min
;
36 maxRefresh
<< (uint32
)max
;
37 SetLimitLabels(minRefresh
.String(), maxRefresh
.String());
39 SetHashMarks(B_HASH_MARKS_BOTTOM
);
40 SetHashMarkCount(uint32(max
- min
) / 5 + 1);
42 SetKeyIncrementValue(1);
46 RefreshSlider::~RefreshSlider()
53 RefreshSlider::DrawFocusMark()
56 rgb_color blue
= { 0, 0, 229, 255 };
58 BRect
rect(ThumbFrame());
59 BView
*view
= OffscreenView();
61 rect
.InsetBy(2.0, 2.0);
65 view
->SetHighColor(blue
);
66 view
->StrokeRect(rect
);
72 RefreshSlider::KeyDown(const char *bytes
, int32 numBytes
)
77 SetValue(Value() - 1);
84 SetValue(Value() + 1);
96 RefreshSlider::UpdateText() const
99 snprintf(fStatus
, 32, B_TRANSLATE("%.1f Hz"), (float)Value() / 10);