2 * Copyright (c) 2008-2009, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
6 * Artur Wyszynski <harakash@gmail.com>
10 #include "GradientsWindow.h"
13 GradientsWindow::GradientsWindow()
14 : BWindow(BRect(0, 0, 230, 490), "Gradients Test", B_TITLED_WINDOW
,
15 B_NOT_RESIZABLE
| B_NOT_ZOOMABLE
)
17 BRect
field(10, 10, Bounds().Width() - 10, 30);
18 fGradientsMenu
= new BPopUpMenu("gradientsType");
19 fLinearItem
= new BMenuItem("Linear", new BMessage(MSG_LINEAR
));
20 fRadialItem
= new BMenuItem("Radial", new BMessage(MSG_RADIAL
));
21 fRadialFocusItem
= new BMenuItem("Radial focus",
22 new BMessage(MSG_RADIAL_FOCUS
));
24 fDiamondItem
= new BMenuItem("Diamond", new BMessage(MSG_DIAMOND
));
25 fConicItem
= new BMenuItem("Conic", new BMessage(MSG_CONIC
));
26 fGradientsMenu
->AddItem(fLinearItem
);
27 fGradientsMenu
->AddItem(fRadialItem
);
28 fGradientsMenu
->AddItem(fRadialFocusItem
);
29 fGradientsMenu
->AddItem(fDiamondItem
);
30 fGradientsMenu
->AddItem(fConicItem
);
31 fLinearItem
->SetMarked(true);
32 fGradientsTypeField
= new BMenuField(field
, "gradientsField",
33 "Gradient type:", fGradientsMenu
, B_FOLLOW_LEFT
| B_FOLLOW_BOTTOM
,
34 B_WILL_DRAW
| B_NAVIGABLE
| B_FRAME_EVENTS
);
35 fGradientsTypeField
->SetViewColor(255, 255, 255);
36 fGradientsTypeField
->SetDivider(110);
37 AddChild(fGradientsTypeField
);
39 BRect bounds
= Bounds();
41 fGradientsView
= new GradientsView(bounds
);
42 AddChild(fGradientsView
);
44 MoveTo((BScreen().Frame().Width() - Bounds().Width()) / 2,
45 (BScreen().Frame().Height() - Bounds().Height()) / 2 );
50 GradientsWindow::QuitRequested()
52 be_app
->PostMessage(B_QUIT_REQUESTED
);
58 GradientsWindow::MessageReceived(BMessage
*msg
)
62 fGradientsView
->SetType(BGradient::TYPE_LINEAR
);
65 fGradientsView
->SetType(BGradient::TYPE_RADIAL
);
67 case MSG_RADIAL_FOCUS
:
68 fGradientsView
->SetType(BGradient::TYPE_RADIAL_FOCUS
);
71 fGradientsView
->SetType(BGradient::TYPE_DIAMOND
);
74 fGradientsView
->SetType(BGradient::TYPE_CONIC
);
77 BWindow::MessageReceived(msg
);