Ticket #5052: Touchpad.patch
File Touchpad.patch, 7.6 KB (added by , 14 years ago) |
---|
-
TouchpadPrefView.cpp
13 13 14 14 #include <Alert.h> 15 15 #include <Box.h> 16 #include <Catalog.h> 16 17 #include <CheckBox.h> 17 18 #include <File.h> 18 19 #include <FindDirectory.h> … … 93 94 94 95 int32 result = 0; 95 96 if (GetRightScrollRatio() > 0.7 || GetBottomScrollRatio() > 0.7) { 96 BAlert *alert = new BAlert("ReallyChangeScrollArea",97 BAlert* alert = new BAlert("ReallyChangeScrollArea", 97 98 "The new scroll area is very small. Do you really want to change " 98 99 "the scroll area?", "Ok", "Cancel", NULL, B_WIDTH_AS_USUAL, 99 100 B_WARNING_ALERT); … … 158 159 DrawSliders(); 159 160 } 160 161 161 if (fYTracking) {162 if (fYTracking) { 162 163 if (point.y > fPadRect.bottom) 163 164 fYScrollRange = fPadRect.Height(); 164 165 else if (point.y < fPadRect.top) … … 175 176 void 176 177 TouchpadView::DrawSliders() 177 178 { 178 BView *view;179 BView* view; 179 180 if (fOffScreenView != NULL) 180 181 view = fOffScreenView; 181 182 else … … 253 254 254 255 // #pragma mark - TouchpadPrefView 255 256 257 #undef TR_CONTEXT 258 #define TR_CONTEXT "TouchpadPrefView" 256 259 257 TouchpadPrefView::TouchpadPrefView(BRect frame, const char *name) 260 261 TouchpadPrefView::TouchpadPrefView() 258 262 : 259 B View(frame, name, B_FOLLOW_ALL_SIDES, 0)263 BGroupView() 260 264 { 261 265 SetupView(); 262 266 // set view values … … 264 268 } 265 269 266 270 267 268 271 TouchpadPrefView::~TouchpadPrefView() 269 272 { 270 273 } … … 351 354 TouchpadPrefView::SetupView() 352 355 { 353 356 SetLayout(new BGroupLayout(B_VERTICAL)); 354 BRect rect = Bounds(); 355 rect.InsetBy(5, 5); 356 BBox* scrollBox = new BBox(rect, "Touchpad"); 357 scrollBox->SetLabel("Scrolling"); 358 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 357 BBox* scrollBox = new BBox("Touchpad"); 358 scrollBox->SetLabel(TR("Scrolling")); 359 359 360 fTouchpadView = new TouchpadView(BRect(0, 0,130,120));360 fTouchpadView = new TouchpadView(BRect(0, 0, 130, 120)); 361 361 fTouchpadView->SetExplicitMaxSize(BSize(130, 120)); 362 362 363 363 // Create the "Mouse Speed" slider... 364 fScrollAccelSlider = new BSlider(rect, "scroll_accel", 365 "Scroll Acceleration", new BMessage(SCROLL_CONTROL_CHANGED), 0, 20); 364 fScrollAccelSlider = new BSlider("scroll_accel", 365 TR("Scroll Acceleration"), new BMessage(SCROLL_CONTROL_CHANGED), 366 0, 20, B_HORIZONTAL); 366 367 fScrollAccelSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); 367 368 fScrollAccelSlider->SetHashMarkCount(7); 368 fScrollAccelSlider->SetLimitLabels( "Slow", "Fast");369 fScrollAccelSlider->SetLimitLabels(TR("Slow"), TR("Fast")); 369 370 370 fScrollStepXSlider = new BSlider(rect, "scroll_stepX", 371 "Horizontal Scroll Step Size", new BMessage(SCROLL_CONTROL_CHANGED), 0, 372 20); 371 fScrollStepXSlider = new BSlider("scroll_stepX", 372 TR("Horizontal Scroll Step Size"), 373 new BMessage(SCROLL_CONTROL_CHANGED), 374 0, 20, B_HORIZONTAL); 373 375 fScrollStepXSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); 374 376 fScrollStepXSlider->SetHashMarkCount(7); 375 fScrollStepXSlider->SetLimitLabels( "Wide", "Small");377 fScrollStepXSlider->SetLimitLabels(TR("Wide"), TR("Small")); 376 378 377 fScrollStepYSlider = new BSlider( rect,"scroll_stepY",378 "Vertical Scroll Step Size", new BMessage(SCROLL_CONTROL_CHANGED), 0,379 20);379 fScrollStepYSlider = new BSlider("scroll_stepY", 380 TR("Vertical Scroll Step Size"), new BMessage(SCROLL_CONTROL_CHANGED), 381 0, 20, B_HORIZONTAL); 380 382 fScrollStepYSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); 381 383 fScrollStepYSlider->SetHashMarkCount(7); 382 fScrollStepYSlider->SetLimitLabels( "Wide", "Small");384 fScrollStepYSlider->SetLimitLabels(TR("Wide"), TR("Small")); 383 385 384 fTwoFingerBox = new BCheckBox( "Two Finger Scrolling",386 fTwoFingerBox = new BCheckBox(TR("Two Finger Scrolling"), 385 387 new BMessage(SCROLL_CONTROL_CHANGED)); 386 fTwoFingerHorizontalBox = new BCheckBox( "Horizontal Scrolling",388 fTwoFingerHorizontalBox = new BCheckBox(TR("Horizontal Scrolling"), 387 389 new BMessage(SCROLL_CONTROL_CHANGED)); 388 390 389 391 BGroupView* scrollPrefLeftLayout = new BGroupView(B_VERTICAL); … … 409 411 scrollPrefLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(15)); 410 412 scrollPrefLayout->AddView(scrollPrefRightLayout); 411 413 412 BBox* tapBox = new BBox( rect,"tapbox");413 tapBox->SetLabel( "Tap Gesture");414 BBox* tapBox = new BBox("tapbox"); 415 tapBox->SetLabel(TR("Tap Gesture")); 414 416 415 417 BGroupLayout* tapPrefLayout = new BGroupLayout(B_HORIZONTAL); 416 418 tapPrefLayout->SetInsets(10, tapBox->TopBorderOffset() * 2 + 10, 10, 10); 417 419 tapBox->SetLayout(tapPrefLayout); 418 420 419 fTapSlider = new BSlider( rect, "tap_sens", "Tap Click Sensitivity",420 new BMessage(TAP_CONTROL_CHANGED), 0, 20 );421 fTapSlider = new BSlider("tap_sens", TR("Tap Click Sensitivity"), 422 new BMessage(TAP_CONTROL_CHANGED), 0, 20, B_HORIZONTAL); 421 423 fTapSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); 422 424 fTapSlider->SetHashMarkCount(7); 423 fTapSlider->SetLimitLabels( "Off", "High");425 fTapSlider->SetLimitLabels(TR("Off"), TR("High")); 424 426 425 427 tapPrefLayout->AddView(fTapSlider); 426 428 427 429 BGroupView* buttonView = new BGroupView(B_HORIZONTAL); 428 fDefaultButton = new BButton("Defaults", new BMessage(DEFAULT_SETTINGS)); 430 fDefaultButton = new BButton(TR("Defaults"), 431 new BMessage(DEFAULT_SETTINGS)); 429 432 430 433 buttonView->AddChild(fDefaultButton); 431 434 buttonView->GetLayout()->AddItem( 432 435 BSpaceLayoutItem::CreateHorizontalStrut(7)); 433 fRevertButton = new BButton( "Revert", new BMessage(REVERT_SETTINGS));436 fRevertButton = new BButton(TR("Revert"), new BMessage(REVERT_SETTINGS)); 434 437 fRevertButton->SetEnabled(false); 435 438 buttonView->AddChild(fRevertButton); 436 439 buttonView->GetLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); -
TouchpadPrefView.h
15 15 #include <Invoker.h> 16 16 #include <Slider.h> 17 17 #include <View.h> 18 #include <GroupView.h> 18 19 19 20 #include "TouchpadPref.h" 20 21 #include "touchpad_settings.h" … … 78 79 }; 79 80 80 81 81 class TouchpadPrefView : public B View {82 class TouchpadPrefView : public BGroupView { 82 83 public: 83 TouchpadPrefView( BRect frame, const char* name);84 TouchpadPrefView(); 84 85 virtual ~TouchpadPrefView(); 85 86 virtual void MessageReceived(BMessage* msg); 86 87 virtual void AttachedToWindow(); -
main.cpp
9 9 10 10 #include <Application.h> 11 11 #include <Window.h> 12 #include <Catalog.h> 13 #include <GroupLayout.h> 14 #include <GroupLayoutBuilder.h> 15 #include <Locale.h> 12 16 13 17 #include "TouchpadPrefView.h" 14 18 … … 28 32 } 29 33 }; 30 34 35 #undef TR_CONTEXT 36 #define TR_CONTEXT "TouchpadMain" 31 37 32 38 int 33 39 main(int argc, char* argv[]) 34 40 { 35 41 BApplication* app = new BApplication("application/x-vnd.Haiku-Touchpad"); 42 BCatalog fCatalog; 43 44 be_locale->GetAppCatalog(&fCatalog); 36 45 TouchpadPrefWindow* window = new TouchpadPrefWindow(BRect(50, 50, 450, 350), 37 "Touchpad", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE 38 | B_ASYNCHRONOUS_CONTROLS); 39 window->AddChild( 40 new TouchpadPrefView(window->Bounds(), "TouchpadPrefView")); 46 TR("Touchpad"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE 47 | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS); 48 window->SetLayout(new BGroupLayout(B_HORIZONTAL)); 49 window->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 50 .Add(new TouchpadPrefView()) 51 .End() 52 .SetInsets(5, 5, 5, 5) 53 ); 41 54 window->Show(); 42 55 app->Run(); 43 56 -
Jamfile
6 6 TouchpadPref.cpp 7 7 TouchpadPrefView.cpp 8 8 main.cpp 9 : be $(TARGET_LIBSUPC++) 9 : be $(TARGET_LIBSUPC++) liblocale.so 10 10 : Touchpad.rdef 11 11 ; 12 13 DoCatalogs Touchpad : 14 x-vnd.Haiku-Appearance 15 : 16 TouchpadPrefView.cpp 17 main.cpp 18 : en.catalog 19 ;