1#include <stdlib.h>
2#include <stdio.h>
3
4#include "NetworkSetupAddOn.h"
5
6class MultipleAddOn : public NetworkSetupAddOn {
7	public:
8		MultipleAddOn(image_id addon_image, int index);
9		~MultipleAddOn();
10		BView*			CreateView(BRect* bounds);
11		const char* 	Name();
12
13	private:
14		char*	fName;
15		rgb_color fViewColor;
16};
17
18
19MultipleAddOn::MultipleAddOn(image_id image, int i)
20	:
21	NetworkSetupAddOn(image)
22{
23	fName = (char*) malloc(64);
24	sprintf(fName, "Multi #%d", i);
25
26	fViewColor.red = rand() % 256;
27	fViewColor.blue = rand() % 256;
28	fViewColor.green = rand() % 256;
29	fViewColor.alpha = 255;
30}
31
32
33MultipleAddOn::~MultipleAddOn()
34{
35	free(fName);
36}
37
38
39BView*
40MultipleAddOn::CreateView(BRect* bounds)
41{
42	BView *v = new BView(*bounds, "a view", B_FOLLOW_ALL, B_WILL_DRAW);
43	v->SetViewColor(fViewColor);
44	return v;
45}
46
47
48const char*
49MultipleAddOn::Name()
50{
51	return fName;
52}
53
54
55NetworkSetupAddOn*
56get_nth_addon(image_id image, int index)
57{
58	if (index < 0 || index > 3)
59		return NULL;
60
61	return new MultipleAddOn(image, index);
62}
63