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 <GroupLayout.h>
16 #include <GroupLayoutBuilder.h>
19 #include <TextControl.h>
22 #include "KeyboardView.h"
23 #include "KeyboardMessages.h"
24 #include "KeyboardSettings.h"
26 #undef B_TRANSLATION_CONTEXT
27 #define B_TRANSLATION_CONTEXT "KeyboardView"
29 KeyboardView::KeyboardView()
32 fIconBitmap
= BTranslationUtils::GetBitmap("key_bmap");
33 fClockBitmap
= BTranslationUtils::GetBitmap("clock_bmap");
35 // Create the "Key repeat rate" slider...
36 fRepeatSlider
= new BSlider("key_repeat_rate",
37 B_TRANSLATE("Key repeat rate"),
38 new BMessage(SLIDER_REPEAT_RATE
),
39 20, 300, B_HORIZONTAL
);
40 fRepeatSlider
->SetHashMarks(B_HASH_MARKS_BOTTOM
);
41 fRepeatSlider
->SetHashMarkCount(5);
42 fRepeatSlider
->SetLimitLabels(B_TRANSLATE("Slow"),B_TRANSLATE("Fast"));
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 SetLayout(new BGroupLayout(B_HORIZONTAL
));
65 AddChild(BGroupLayoutBuilder(B_VERTICAL
, 10)
69 .SetInsets(10, 10, 10, 10)
74 KeyboardView::~KeyboardView()
81 KeyboardView::Draw(BRect updateFrame
)
84 pt
.x
= fRepeatSlider
->Frame().right
+ 10;
86 if (fIconBitmap
!= NULL
) {
87 pt
.y
= fRepeatSlider
->Frame().bottom
- 35
88 - fIconBitmap
->Bounds().Height() / 3;
89 DrawBitmap(fIconBitmap
, pt
);
92 if (fClockBitmap
!= NULL
) {
93 pt
.y
= fDelaySlider
->Frame().bottom
- 35
94 - fClockBitmap
->Bounds().Height() / 3;
95 DrawBitmap(fClockBitmap
, pt
);