tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / preferences / screen / RefreshSlider.cpp
blob5194d659925bd82cbb16d550fcf496a91ad43f42
1 /*
2 * Copyright 2001-2006, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Rafael Romo
7 * Stefano Ceccherini (burton666@libero.it)
8 * Axel Dörfler, axeld@pinc-software.de
9 */
12 #include "RefreshSlider.h"
13 #include "Constants.h"
15 #include <Catalog.h>
16 #include <String.h>
17 #include <Window.h>
19 #include <new>
20 #include <stdio.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])
33 BString minRefresh;
34 minRefresh << (uint32)min;
35 BString maxRefresh;
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()
48 delete[] fStatus;
52 void
53 RefreshSlider::DrawFocusMark()
55 if (IsFocus()) {
56 rgb_color blue = { 0, 0, 229, 255 };
58 BRect rect(ThumbFrame());
59 BView *view = OffscreenView();
61 rect.InsetBy(2.0, 2.0);
62 rect.right--;
63 rect.bottom--;
65 view->SetHighColor(blue);
66 view->StrokeRect(rect);
71 void
72 RefreshSlider::KeyDown(const char *bytes, int32 numBytes)
74 switch (*bytes) {
75 case B_LEFT_ARROW:
77 SetValue(Value() - 1);
78 Invoke();
79 break;
82 case B_RIGHT_ARROW:
84 SetValue(Value() + 1);
85 Invoke();
86 break;
89 default:
90 break;
95 const char*
96 RefreshSlider::UpdateText() const
98 if (fStatus != NULL)
99 snprintf(fStatus, 32, B_TRANSLATE("%.1f Hz"), (float)Value() / 10);
101 return fStatus;