2 * Copyright 2004-2006, the Haiku project. All rights reserved.
3 * Distributed under the terms of the Haiku License.
5 * Authors in chronological order:
6 * mccall@digitalparadise.co.uk
10 #include <InterfaceDefs.h>
11 #include <TranslationUtils.h>
15 #include <LayoutBuilder.h>
18 #include <TextControl.h>
21 #include "KeyboardView.h"
22 #include "KeyboardMessages.h"
23 #include "KeyboardSettings.h"
25 #undef B_TRANSLATION_CONTEXT
26 #define B_TRANSLATION_CONTEXT "KeyboardView"
28 KeyboardView::KeyboardView()
31 fIconBitmap
= BTranslationUtils::GetBitmap("key_bmap");
32 fClockBitmap
= BTranslationUtils::GetBitmap("clock_bmap");
34 // Create the "Key repeat rate" slider...
35 fRepeatSlider
= new BSlider("key_repeat_rate",
36 B_TRANSLATE("Key repeat rate"),
37 new BMessage(SLIDER_REPEAT_RATE
),
38 20, 300, B_HORIZONTAL
);
39 fRepeatSlider
->SetHashMarks(B_HASH_MARKS_BOTTOM
);
40 fRepeatSlider
->SetHashMarkCount(5);
41 fRepeatSlider
->SetLimitLabels(B_TRANSLATE("Slow"),B_TRANSLATE("Fast"));
42 fRepeatSlider
->SetExplicitMinSize(BSize(200, B_SIZE_UNSET
));
45 // Create the "Delay until key repeat" slider...
46 fDelaySlider
= new BSlider("delay_until_key_repeat",
47 B_TRANSLATE("Delay until key repeat"),
48 new BMessage(SLIDER_DELAY_RATE
),
49 250000, 1000000, B_HORIZONTAL
);
50 fDelaySlider
->SetHashMarks(B_HASH_MARKS_BOTTOM
);
51 fDelaySlider
->SetHashMarkCount(4);
52 fDelaySlider
->SetLimitLabels(B_TRANSLATE("Short"),B_TRANSLATE("Long"));
54 // Create the "Typing test area" text box...
55 BTextControl
* textcontrol
= new BTextControl(NULL
,
56 B_TRANSLATE("Typing test area"),
57 new BMessage('TTEA'));
58 textcontrol
->SetAlignment(B_ALIGN_LEFT
, B_ALIGN_CENTER
);
59 textcontrol
->SetExplicitMinSize(BSize(
60 textcontrol
->StringWidth(B_TRANSLATE("Typing test area")), B_SIZE_UNSET
));
63 BLayoutBuilder::Group
<>(this, B_VERTICAL
, B_USE_DEFAULT_SPACING
)
70 KeyboardView::~KeyboardView()
77 KeyboardView::Draw(BRect updateFrame
)
80 pt
.x
= fRepeatSlider
->Frame().right
+ 10;
82 if (fIconBitmap
!= NULL
) {
83 pt
.y
= fRepeatSlider
->Frame().bottom
- 35
84 - fIconBitmap
->Bounds().Height() / 3;
85 DrawBitmap(fIconBitmap
, pt
);
88 if (fClockBitmap
!= NULL
) {
89 pt
.y
= fDelaySlider
->Frame().bottom
- 35
90 - fClockBitmap
->Bounds().Height() / 3;
91 DrawBitmap(fClockBitmap
, pt
);