117ea072aSStefano Ceccherini #include <Application.h>
217ea072aSStefano Ceccherini #include <ChannelSlider.h>
317ea072aSStefano Ceccherini #include <Window.h>
417ea072aSStefano Ceccherini
5*a361dc5aSStefano Ceccherini #include <string>
6*a361dc5aSStefano Ceccherini
7*a361dc5aSStefano Ceccherini
8*a361dc5aSStefano Ceccherini struct limit_label {
9*a361dc5aSStefano Ceccherini std::string min_label;
10*a361dc5aSStefano Ceccherini std::string max_label;
11*a361dc5aSStefano Ceccherini };
12*a361dc5aSStefano Ceccherini
13*a361dc5aSStefano Ceccherini
14*a361dc5aSStefano Ceccherini const struct limit_label kLabels[] = {
15*a361dc5aSStefano Ceccherini { "min_label_1", "max_label_1" },
16*a361dc5aSStefano Ceccherini { "min_label_2", "max_label_2" },
17*a361dc5aSStefano Ceccherini { "min_label_3", "max_label_3" },
18*a361dc5aSStefano Ceccherini };
19*a361dc5aSStefano Ceccherini
20*a361dc5aSStefano Ceccherini
2117ea072aSStefano Ceccherini class MainWindow : public BWindow {
2217ea072aSStefano Ceccherini public:
MainWindow()2317ea072aSStefano Ceccherini MainWindow()
2417ea072aSStefano Ceccherini :BWindow(BRect(50, 50, 250, 360), "window", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
2517ea072aSStefano Ceccherini {
2643f7b929SJérôme Duval BChannelSlider *slider = new BChannelSlider(BRect(10, 10, 20, 20),
2745735be6SKarsten Heimrich "vertical slider", "Verticalp", new BMessage('test'), 4);
2843f7b929SJérôme Duval slider->SetOrientation(B_VERTICAL);
2917ea072aSStefano Ceccherini AddChild(slider);
3043f7b929SJérôme Duval slider->ResizeToPreferred();
3145735be6SKarsten Heimrich
3245735be6SKarsten Heimrich slider = new BChannelSlider(BRect(10, 10, 20, 20), "vertical slider",
3345735be6SKarsten Heimrich "Verticalp", new BMessage('test'), B_VERTICAL, 4);
3445735be6SKarsten Heimrich AddChild(slider);
3545735be6SKarsten Heimrich slider->SetLimitLabels("Wminp", "Wmaxp");
3645735be6SKarsten Heimrich slider->ResizeToPreferred();
3745735be6SKarsten Heimrich slider->MoveBy(slider->Bounds().Width() + 10.0, 0.0);
3845735be6SKarsten Heimrich
3945735be6SKarsten Heimrich BChannelSlider *horizontal = new BChannelSlider(BRect(150, 10, 160, 20),
4045735be6SKarsten Heimrich "horizontal slider", "Horizontal", new BMessage('test'), 3);
4117ea072aSStefano Ceccherini AddChild(horizontal);
4243f7b929SJérôme Duval horizontal->ResizeToPreferred();
4345735be6SKarsten Heimrich
4445735be6SKarsten Heimrich horizontal = new BChannelSlider(BRect(150, 10, 160, 20),
4545735be6SKarsten Heimrich "horizontal slider", "Horizontalp", new BMessage('test'),
4645735be6SKarsten Heimrich B_HORIZONTAL, 3);
4745735be6SKarsten Heimrich AddChild(horizontal);
4845735be6SKarsten Heimrich horizontal->SetLimitLabels("Wminp", "Wmaxp");
4945735be6SKarsten Heimrich horizontal->ResizeToPreferred();
5045735be6SKarsten Heimrich horizontal->MoveBy(0.0, horizontal->Bounds().Height() + 10.0);
5145735be6SKarsten Heimrich
5245735be6SKarsten Heimrich ResizeTo(horizontal->Frame().right + 10, slider->Frame().bottom + 10);
53*a361dc5aSStefano Ceccherini
54*a361dc5aSStefano Ceccherini for (int32 i = 0; i < horizontal->CountChannels(); i++) {
55*a361dc5aSStefano Ceccherini horizontal->SetLimitLabelsFor(i, kLabels[i].min_label.c_str(),
56*a361dc5aSStefano Ceccherini kLabels[i].max_label.c_str());
57*a361dc5aSStefano Ceccherini }
58*a361dc5aSStefano Ceccherini
59*a361dc5aSStefano Ceccherini for (int32 i = 0; i < horizontal->CountChannels(); i++) {
60*a361dc5aSStefano Ceccherini if (strcmp(horizontal->MinLimitLabelFor(i), kLabels[i].min_label.c_str()) != 0)
61*a361dc5aSStefano Ceccherini printf("wrong min label for channel %ld\n", i);
62*a361dc5aSStefano Ceccherini if (strcmp(horizontal->MaxLimitLabelFor(i), kLabels[i].max_label.c_str()) != 0)
63*a361dc5aSStefano Ceccherini printf("wrong max label for channel %ld\n", i);
64*a361dc5aSStefano Ceccherini }
6517ea072aSStefano Ceccherini }
6617ea072aSStefano Ceccherini
QuitRequested()6717ea072aSStefano Ceccherini virtual bool QuitRequested() { be_app->PostMessage(B_QUIT_REQUESTED); return BWindow::QuitRequested() ; }
6817ea072aSStefano Ceccherini };
6917ea072aSStefano Ceccherini
7017ea072aSStefano Ceccherini
7117ea072aSStefano Ceccherini class App : public BApplication {
7217ea072aSStefano Ceccherini public:
App()7317ea072aSStefano Ceccherini App() : BApplication("application/x-vnd.channelslidertest")
7417ea072aSStefano Ceccherini {
7517ea072aSStefano Ceccherini }
7617ea072aSStefano Ceccherini
ReadyToRun()7717ea072aSStefano Ceccherini virtual void ReadyToRun()
7817ea072aSStefano Ceccherini {
7917ea072aSStefano Ceccherini (new MainWindow())->Show();
8017ea072aSStefano Ceccherini }
8117ea072aSStefano Ceccherini
8217ea072aSStefano Ceccherini };
8317ea072aSStefano Ceccherini
main()8417ea072aSStefano Ceccherini int main()
8517ea072aSStefano Ceccherini {
8617ea072aSStefano Ceccherini App app;
8717ea072aSStefano Ceccherini
8817ea072aSStefano Ceccherini app.Run();
8917ea072aSStefano Ceccherini
9017ea072aSStefano Ceccherini return 0;
9117ea072aSStefano Ceccherini }
92