Ticket #5052: Touchpad.patch

File Touchpad.patch, 7.6 KB (added by mt, 13 years ago)

patch file

  • TouchpadPrefView.cpp

     
    1313
    1414#include <Alert.h>
    1515#include <Box.h>
     16#include <Catalog.h>
    1617#include <CheckBox.h>
    1718#include <File.h>
    1819#include <FindDirectory.h>
     
    9394
    9495    int32 result = 0;
    9596    if (GetRightScrollRatio() > 0.7 || GetBottomScrollRatio() > 0.7) {
    96         BAlert *alert = new BAlert("ReallyChangeScrollArea",
     97        BAlert* alert = new BAlert("ReallyChangeScrollArea",
    9798            "The new scroll area is very small. Do you really want to change "
    9899                "the scroll area?", "Ok", "Cancel", NULL, B_WIDTH_AS_USUAL,
    99100            B_WARNING_ALERT);
     
    158159        DrawSliders();
    159160    }
    160161
    161     if (fYTracking){
     162    if (fYTracking) {
    162163        if (point.y > fPadRect.bottom)
    163164            fYScrollRange = fPadRect.Height();
    164165        else if (point.y < fPadRect.top)
     
    175176void
    176177TouchpadView::DrawSliders()
    177178{
    178     BView *view;
     179    BView* view;
    179180    if (fOffScreenView != NULL)
    180181        view = fOffScreenView;
    181182    else
     
    253254
    254255//  #pragma mark - TouchpadPrefView
    255256
     257#undef TR_CONTEXT
     258#define TR_CONTEXT "TouchpadPrefView"
    256259
    257 TouchpadPrefView::TouchpadPrefView(BRect frame, const char *name)
     260
     261TouchpadPrefView::TouchpadPrefView()
    258262    :
    259     BView(frame, name, B_FOLLOW_ALL_SIDES, 0)
     263    BGroupView()
    260264{
    261265    SetupView();
    262266    // set view values
     
    264268}
    265269
    266270
    267 
    268271TouchpadPrefView::~TouchpadPrefView()
    269272{
    270273}
     
    351354TouchpadPrefView::SetupView()
    352355{
    353356    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"));
    359359
    360     fTouchpadView = new TouchpadView(BRect(0,0,130,120));
     360    fTouchpadView = new TouchpadView(BRect(0, 0, 130, 120));
    361361    fTouchpadView->SetExplicitMaxSize(BSize(130, 120));
    362362
    363363    // 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);
    366367    fScrollAccelSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
    367368    fScrollAccelSlider->SetHashMarkCount(7);
    368     fScrollAccelSlider->SetLimitLabels("Slow", "Fast");
     369    fScrollAccelSlider->SetLimitLabels(TR("Slow"), TR("Fast"));
    369370
    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);
    373375    fScrollStepXSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
    374376    fScrollStepXSlider->SetHashMarkCount(7);
    375     fScrollStepXSlider->SetLimitLabels("Wide", "Small");
     377    fScrollStepXSlider->SetLimitLabels(TR("Wide"), TR("Small"));
    376378
    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);
    380382    fScrollStepYSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
    381383    fScrollStepYSlider->SetHashMarkCount(7);
    382     fScrollStepYSlider->SetLimitLabels("Wide", "Small");
     384    fScrollStepYSlider->SetLimitLabels(TR("Wide"), TR("Small"));
    383385
    384     fTwoFingerBox = new BCheckBox("Two Finger Scrolling",
     386    fTwoFingerBox = new BCheckBox(TR("Two Finger Scrolling"),
    385387        new BMessage(SCROLL_CONTROL_CHANGED));
    386     fTwoFingerHorizontalBox = new BCheckBox("Horizontal Scrolling",
     388    fTwoFingerHorizontalBox = new BCheckBox(TR("Horizontal Scrolling"),
    387389        new BMessage(SCROLL_CONTROL_CHANGED));
    388390
    389391    BGroupView* scrollPrefLeftLayout = new BGroupView(B_VERTICAL);
     
    409411    scrollPrefLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(15));
    410412    scrollPrefLayout->AddView(scrollPrefRightLayout);
    411413
    412     BBox* tapBox = new BBox(rect, "tapbox");
    413     tapBox->SetLabel("Tap Gesture");
     414    BBox* tapBox = new BBox("tapbox");
     415    tapBox->SetLabel(TR("Tap Gesture"));
    414416
    415417    BGroupLayout* tapPrefLayout = new BGroupLayout(B_HORIZONTAL);
    416418    tapPrefLayout->SetInsets(10, tapBox->TopBorderOffset() * 2 + 10, 10, 10);
    417419    tapBox->SetLayout(tapPrefLayout);
    418420
    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);
    421423    fTapSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
    422424    fTapSlider->SetHashMarkCount(7);
    423     fTapSlider->SetLimitLabels("Off", "High");
     425    fTapSlider->SetLimitLabels(TR("Off"), TR("High"));
    424426
    425427    tapPrefLayout->AddView(fTapSlider);
    426428
    427429    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));
    429432
    430433    buttonView->AddChild(fDefaultButton);
    431434    buttonView->GetLayout()->AddItem(
    432435        BSpaceLayoutItem::CreateHorizontalStrut(7));
    433     fRevertButton = new BButton("Revert", new BMessage(REVERT_SETTINGS));
     436    fRevertButton = new BButton(TR("Revert"), new BMessage(REVERT_SETTINGS));
    434437    fRevertButton->SetEnabled(false);
    435438    buttonView->AddChild(fRevertButton);
    436439    buttonView->GetLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
  • TouchpadPrefView.h

     
    1515#include <Invoker.h>
    1616#include <Slider.h>
    1717#include <View.h>
     18#include <GroupView.h>
    1819
    1920#include "TouchpadPref.h"
    2021#include "touchpad_settings.h"
     
    7879};
    7980
    8081
    81 class TouchpadPrefView : public BView {
     82class TouchpadPrefView : public BGroupView {
    8283public:
    83                             TouchpadPrefView(BRect frame, const char* name);
     84                            TouchpadPrefView();
    8485    virtual                 ~TouchpadPrefView();
    8586    virtual void            MessageReceived(BMessage* msg);
    8687    virtual void            AttachedToWindow();
  • main.cpp

     
    99
    1010#include <Application.h>
    1111#include <Window.h>
     12#include <Catalog.h>
     13#include <GroupLayout.h>
     14#include <GroupLayoutBuilder.h>
     15#include <Locale.h>
    1216
    1317#include "TouchpadPrefView.h"
    1418
     
    2832    }
    2933};
    3034
     35#undef TR_CONTEXT
     36#define TR_CONTEXT "TouchpadMain"
    3137
    3238int
    3339main(int argc, char* argv[])
    3440{
    3541    BApplication* app = new BApplication("application/x-vnd.Haiku-Touchpad");
     42    BCatalog fCatalog;
     43
     44    be_locale->GetAppCatalog(&fCatalog);
    3645    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    );
    4154    window->Show();
    4255    app->Run();
    4356
  • Jamfile

     
    66    TouchpadPref.cpp
    77    TouchpadPrefView.cpp
    88    main.cpp
    9     : be $(TARGET_LIBSUPC++)
     9    : be $(TARGET_LIBSUPC++) liblocale.so
    1010    : Touchpad.rdef
    1111    ;
     12
     13DoCatalogs Touchpad :
     14    x-vnd.Haiku-Appearance
     15    :
     16    TouchpadPrefView.cpp
     17    main.cpp
     18    : en.catalog
     19    ;