1/*
2 * Copyright 2004-2006, the Haiku project. All rights reserved.
3 * Distributed under the terms of the Haiku License.
4 *
5 * Authors in chronological order:
6 *  mccall@digitalparadise.co.uk
7 *  J��r��me Duval
8 *  Marcus Overhagen
9*/
10#include <InterfaceDefs.h>
11#include <TranslationUtils.h>
12#include <Bitmap.h>
13#include <Button.h>
14#include <Catalog.h>
15#include <GroupLayout.h>
16#include <GroupLayoutBuilder.h>
17#include <Locale.h>
18#include <Slider.h>
19#include <TextControl.h>
20#include <Window.h>
21
22#include "KeyboardView.h"
23#include "KeyboardMessages.h"
24#include "KeyboardSettings.h"
25
26#undef B_TRANSLATION_CONTEXT
27#define B_TRANSLATION_CONTEXT "KeyboardView"
28
29KeyboardView::KeyboardView()
30 :	BGroupView()
31{
32	fIconBitmap = BTranslationUtils::GetBitmap("key_bmap");
33	fClockBitmap = BTranslationUtils::GetBitmap("clock_bmap");
34
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"));
43
44
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"));
53
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));
61
62	// Build the layout
63	SetLayout(new BGroupLayout(B_HORIZONTAL));
64
65	AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
66		.Add(fRepeatSlider)
67		.Add(fDelaySlider)
68		.Add(textcontrol)
69		.SetInsets(10, 10, 10, 10)
70	);
71}
72
73
74KeyboardView::~KeyboardView()
75{
76
77}
78
79
80void
81KeyboardView::Draw(BRect updateFrame)
82{
83	BPoint pt;
84	pt.x = fRepeatSlider->Frame().right + 10;
85
86	if (fIconBitmap != NULL) {
87		pt.y = fRepeatSlider->Frame().bottom - 35
88			- fIconBitmap->Bounds().Height() / 3;
89		DrawBitmap(fIconBitmap, pt);
90	}
91
92	if (fClockBitmap != NULL) {
93		pt.y = fDelaySlider->Frame().bottom - 35
94			- fClockBitmap->Bounds().Height() / 3;
95		DrawBitmap(fClockBitmap, pt);
96	}
97}
98