xref: /haiku/src/apps/poorman/PoorManAdvancedView.cpp (revision 2813f49667afbbf73ac2d49e0aa5f515d761c709)
1 /* PoorManAdvancedView.cpp
2  *
3  *	Philip Harrison
4  *	Started: 5/12/2004
5  *	Version: 0.1
6  */
7 
8 #include <Box.h>
9 #include <Catalog.h>
10 #include <Locale.h>
11 
12 #include "constants.h"
13 #include "PoorManAdvancedView.h"
14 #include "PoorManWindow.h"
15 #include "PoorManApplication.h"
16 
17 
18 #undef B_TRANSLATE_CONTEXT
19 #define B_TRANSLATE_CONTEXT "PoorMan"
20 
21 
22 PoorManAdvancedView::PoorManAdvancedView(BRect rect, const char *name)
23 	: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
24 {
25 	PoorManWindow	*	win;
26 	win = ((PoorManApplication *)be_app)->GetPoorManWindow();
27 
28 	SetViewColor(BACKGROUND_COLOR);
29 
30 	// Console Logging BBox
31 	BRect maxRect;
32 	maxRect = rect;
33 	maxRect.top -= 5.0;
34 	maxRect.left -= 5.0;
35 	maxRect.right -= 7.0;
36 	maxRect.bottom -= 118.0;
37 
38 	BBox * connectionOptions = new BBox(maxRect, B_TRANSLATE("Connections"));
39 	connectionOptions->SetLabel(STR_BBX_CONNECTION);
40 	AddChild(connectionOptions);
41 
42 	BRect sliderRect;
43 	sliderRect = connectionOptions->Bounds();
44 	sliderRect.InsetBy(10.0f, 10.0f);
45 	sliderRect.top += 10;
46 	sliderRect.bottom = sliderRect.top + 50.0;
47 
48 	maxConnections = new StatusSlider(sliderRect, "Max Slider", STR_SLD_LABEL,
49 		STR_SLD_STATUS_LABEL, new BMessage(MSG_PREF_ADV_SLD_MAX_CONNECTION), 1, 200);
50 
51 	// labels below the slider 1 and 200
52 	maxConnections->SetLimitLabels("1", "200");
53 	SetMaxSimutaneousConnections(win->MaxConnections());
54 	connectionOptions->AddChild(maxConnections);
55 }
56 
57 void
58 PoorManAdvancedView::SetMaxSimutaneousConnections(int32 num)
59 {
60 	if (num <= 0 || num > 200)
61 		maxConnections->SetValue(32);
62 	else
63 		maxConnections->SetValue(num);
64 }
65