2 * Copyright 2016, Adrien Destugues, pulkomandy@pulkomandy.tk
3 * Distributed under terms of the MIT license.
7 #include "CustomRateWindow.h"
13 #include <GroupLayoutBuilder.h>
17 #define B_TRANSLATION_CONTEXT "Custom baudrate window"
20 static const uint32 kOkButtonMsg
= 'ok';
22 CustomRateWindow::CustomRateWindow(int baudrate
)
23 : BWindow(BRect(100, 100, 200, 150), B_TRANSLATE("Custom baudrate"),
24 B_FLOATING_WINDOW
, B_NOT_ZOOMABLE
| B_NOT_RESIZABLE
| B_CLOSE_ON_ESCAPE
25 | B_AUTO_UPDATE_SIZE_LIMITS
)
27 BGroupLayout
* layout
= new BGroupLayout(B_HORIZONTAL
);
30 BGroupView
* root
= new BGroupView(B_VERTICAL
);
33 BGroupLayoutBuilder(root
)
34 .SetInsets(B_USE_WINDOW_SPACING
, B_USE_WINDOW_SPACING
,
35 B_USE_WINDOW_SPACING
, B_USE_WINDOW_SPACING
)
36 .AddGroup(B_HORIZONTAL
)
37 .Add(fSpinner
= new BSpinner("spin", B_TRANSLATE("Baudrate:"), NULL
))
39 .AddGroup(B_HORIZONTAL
)
41 .Add(new BButton("ok", B_TRANSLATE("Ok"), new BMessage(kOkButtonMsg
)))
42 .Add(new BButton("cancel", B_TRANSLATE("Cancel"),
43 new BMessage(B_QUIT_REQUESTED
)))
47 fSpinner
->SetMinValue(50);
48 fSpinner
->SetMaxValue(3000000);
49 fSpinner
->SetValue(baudrate
);
56 CustomRateWindow::MessageReceived(BMessage
* message
)
58 if (message
->what
== kOkButtonMsg
)
60 BMessage
* settings
= new BMessage(kMsgSettings
);
61 settings
->AddInt32("baudrate", fSpinner
->Value());
62 be_app
->PostMessage(settings
);
67 BWindow::MessageReceived(message
);