1 /* 2 * Copyright 2004-2006, the Haiku project. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors in chronological order: 6 * mccall@digitalparadise.co.uk 7 * Jérôme Duval 8 * Marcus Overhagen 9 */ 10 11 12 #include "KeyboardView.h" 13 14 #include <Bitmap.h> 15 #include <Button.h> 16 #include <Catalog.h> 17 #include <InterfaceDefs.h> 18 #include <LayoutBuilder.h> 19 #include <Locale.h> 20 #include <Slider.h> 21 #include <TextControl.h> 22 #include <Window.h> 23 24 #include "InputConstants.h" 25 #include "KeyboardSettings.h" 26 27 #undef B_TRANSLATION_CONTEXT 28 #define B_TRANSLATION_CONTEXT "KeyboardView" 29 30 31 KeyboardView::KeyboardView() 32 : 33 BGroupView() 34 { 35 // Create the "Key repeat rate" slider... 36 fRepeatSlider 37 = new BSlider("key_repeat_rate", B_TRANSLATE("Key repeat rate"), 38 new BMessage(kMsgSliderrepeatrate), 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)); 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(kMsgSliderdelayrate), 250000, 1000000, B_HORIZONTAL); 49 fDelaySlider->SetHashMarks(B_HASH_MARKS_BOTTOM); 50 fDelaySlider->SetHashMarkCount(4); 51 fDelaySlider->SetLimitLabels(B_TRANSLATE("Short"), B_TRANSLATE("Long")); 52 53 // Create the "Typing test area" text box... 54 BTextControl* textcontrol = new BTextControl( 55 NULL, B_TRANSLATE("Typing test area"), new BMessage('TTEA')); 56 textcontrol->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER); 57 textcontrol->SetExplicitMinSize( 58 BSize(textcontrol->StringWidth(B_TRANSLATE("Typing test area")), 59 B_SIZE_UNSET)); 60 61 // Build the layout 62 BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING) 63 .Add(fRepeatSlider) 64 .Add(fDelaySlider) 65 .Add(textcontrol) 66 .AddGlue(); 67 } 68 69 70 KeyboardView::~KeyboardView() 71 { 72 } 73 74 75 void 76 KeyboardView::Draw(BRect updateFrame) 77 { 78 BPoint pt; 79 pt.x = fRepeatSlider->Frame().right + 10; 80 81 if (fIconBitmap != NULL) { 82 pt.y = fRepeatSlider->Frame().bottom - 35 83 - fIconBitmap->Bounds().Height() / 3; 84 DrawBitmap(fIconBitmap, pt); 85 } 86 87 if (fClockBitmap != NULL) { 88 pt.y = fDelaySlider->Frame().bottom - 35 89 - fClockBitmap->Bounds().Height() / 3; 90 DrawBitmap(fClockBitmap, pt); 91 } 92 } 93