xref: /haiku/src/apps/powerstatus/ExtendedInfoWindow.cpp (revision e391ec67b76eb39e7ecdb4da2693e1adf19cd0f7)
16aed176cSClemens Zeidler /*
26aed176cSClemens Zeidler  * Copyright 2006, Haiku, Inc. All Rights Reserved.
36aed176cSClemens Zeidler  * Distributed under the terms of the MIT License.
46aed176cSClemens Zeidler  *
56aed176cSClemens Zeidler  * Authors:
66aed176cSClemens Zeidler  *		Clemens Zeidler, haiku@Clemens-Zeidler.de
76aed176cSClemens Zeidler  */
86aed176cSClemens Zeidler 
96aed176cSClemens Zeidler #include "ExtendedInfoWindow.h"
106aed176cSClemens Zeidler 
116aed176cSClemens Zeidler #include <Box.h>
126aed176cSClemens Zeidler #include <GroupLayout.h>
136aed176cSClemens Zeidler #include <GroupView.h>
146aed176cSClemens Zeidler #include <SpaceLayoutItem.h>
156aed176cSClemens Zeidler #include <String.h>
166aed176cSClemens Zeidler 
176aed176cSClemens Zeidler 
18*e391ec67SClemens Zeidler FontString::FontString()
19*e391ec67SClemens Zeidler {
20*e391ec67SClemens Zeidler 	font = be_plain_font;
21*e391ec67SClemens Zeidler }
22*e391ec67SClemens Zeidler 
23*e391ec67SClemens Zeidler 
24*e391ec67SClemens Zeidler const int kLineSpacing = 5;
25*e391ec67SClemens Zeidler 
26*e391ec67SClemens Zeidler BatteryInfoView::BatteryInfoView()
276aed176cSClemens Zeidler 	:
28*e391ec67SClemens Zeidler 	BView("battery info view", B_WILL_DRAW |
29*e391ec67SClemens Zeidler 		B_FULL_UPDATE_ON_RESIZE),
30*e391ec67SClemens Zeidler 	fPreferredSize(200, 200),
31*e391ec67SClemens Zeidler 	fMaxStringSize(0, 0)
326aed176cSClemens Zeidler {
336aed176cSClemens Zeidler 	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
346aed176cSClemens Zeidler }
356aed176cSClemens Zeidler 
366aed176cSClemens Zeidler 
37*e391ec67SClemens Zeidler BatteryInfoView::~BatteryInfoView()
38*e391ec67SClemens Zeidler {
39*e391ec67SClemens Zeidler 	_ClearStringList();
40*e391ec67SClemens Zeidler }
41*e391ec67SClemens Zeidler 
42*e391ec67SClemens Zeidler 
436aed176cSClemens Zeidler void
446aed176cSClemens Zeidler BatteryInfoView::Update(battery_info& info, acpi_extended_battery_info& extInfo)
456aed176cSClemens Zeidler {
466aed176cSClemens Zeidler 	fBatteryInfo = info;
476aed176cSClemens Zeidler 	fBatteryExtendedInfo = extInfo;
48*e391ec67SClemens Zeidler 
49*e391ec67SClemens Zeidler 	_FillStringList();
506aed176cSClemens Zeidler }
516aed176cSClemens Zeidler 
526aed176cSClemens Zeidler 
536aed176cSClemens Zeidler void
546aed176cSClemens Zeidler BatteryInfoView::Draw(BRect updateRect)
556aed176cSClemens Zeidler {
566aed176cSClemens Zeidler 	SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
576aed176cSClemens Zeidler 
58*e391ec67SClemens Zeidler 	BPoint point(10, 10);
59*e391ec67SClemens Zeidler 
60*e391ec67SClemens Zeidler 	float space = _MeasureString("").height + kLineSpacing;
61*e391ec67SClemens Zeidler 
62*e391ec67SClemens Zeidler 	for (int i = 0; i < fStringList.CountItems(); i ++)
63*e391ec67SClemens Zeidler 	{
64*e391ec67SClemens Zeidler 		FontString* fontString = fStringList.ItemAt(i);
65*e391ec67SClemens Zeidler 		SetFont(fontString->font);
66*e391ec67SClemens Zeidler 		DrawString(fontString->string.String(), point);
67*e391ec67SClemens Zeidler 		point.y += space;
68*e391ec67SClemens Zeidler 	}
69*e391ec67SClemens Zeidler }
70*e391ec67SClemens Zeidler 
71*e391ec67SClemens Zeidler 
72*e391ec67SClemens Zeidler void
73*e391ec67SClemens Zeidler BatteryInfoView::GetPreferredSize(float *width, float *height)
74*e391ec67SClemens Zeidler {
75*e391ec67SClemens Zeidler 	*width = fPreferredSize.width;
76*e391ec67SClemens Zeidler 	*height = fPreferredSize.height;
77*e391ec67SClemens Zeidler }
78*e391ec67SClemens Zeidler 
79*e391ec67SClemens Zeidler 
80*e391ec67SClemens Zeidler BSize
81*e391ec67SClemens Zeidler BatteryInfoView::_MeasureString(const BString& string)
82*e391ec67SClemens Zeidler {
83*e391ec67SClemens Zeidler 	BFont font;
84*e391ec67SClemens Zeidler 	GetFont(&font);
85*e391ec67SClemens Zeidler 	BSize size;
86*e391ec67SClemens Zeidler 
87*e391ec67SClemens Zeidler 	size.width = font.StringWidth(string);
88*e391ec67SClemens Zeidler 
89*e391ec67SClemens Zeidler 	font_height height;
90*e391ec67SClemens Zeidler 	font.GetHeight(&height);
91*e391ec67SClemens Zeidler 	size.height = height.ascent + height.descent;
92*e391ec67SClemens Zeidler 
93*e391ec67SClemens Zeidler 	return size;
94*e391ec67SClemens Zeidler }
95*e391ec67SClemens Zeidler 
96*e391ec67SClemens Zeidler 
97*e391ec67SClemens Zeidler void
98*e391ec67SClemens Zeidler BatteryInfoView::_FillStringList()
99*e391ec67SClemens Zeidler {
100*e391ec67SClemens Zeidler 	_ClearStringList();
101*e391ec67SClemens Zeidler 
1026aed176cSClemens Zeidler 	BString powerUnit;
1036aed176cSClemens Zeidler 	BString rateUnit;
1046aed176cSClemens Zeidler 	switch (fBatteryExtendedInfo.power_unit) {
1056aed176cSClemens Zeidler 		case 0:
1066aed176cSClemens Zeidler 			powerUnit = " mWh";
1076aed176cSClemens Zeidler 			rateUnit = " mW";
1086aed176cSClemens Zeidler 			break;
1096aed176cSClemens Zeidler 
1106aed176cSClemens Zeidler 		case 1:
1116aed176cSClemens Zeidler 			powerUnit = " mAh";
1126aed176cSClemens Zeidler 			rateUnit = " mA";
1136aed176cSClemens Zeidler 			break;
1146aed176cSClemens Zeidler 	}
1156aed176cSClemens Zeidler 
116*e391ec67SClemens Zeidler 	FontString* fontString;
117*e391ec67SClemens Zeidler 
118*e391ec67SClemens Zeidler 	fontString = new FontString;
119*e391ec67SClemens Zeidler 	fStringList.AddItem(fontString);
120*e391ec67SClemens Zeidler 	fontString->font = be_bold_font;
121*e391ec67SClemens Zeidler 
1226aed176cSClemens Zeidler 	if (fBatteryInfo.state & BATTERY_CHARGING)
123*e391ec67SClemens Zeidler 		fontString->string = "Battery charging";
1246aed176cSClemens Zeidler 	else if (fBatteryInfo.state & BATTERY_DISCHARGING)
125*e391ec67SClemens Zeidler 		fontString->string = "Battery discharging";
1266aed176cSClemens Zeidler 	else if (fBatteryInfo.state & BATTERY_CRITICAL_STATE)
127*e391ec67SClemens Zeidler 		fontString->string = "Empty Battery Slot";
1286aed176cSClemens Zeidler 	else
129*e391ec67SClemens Zeidler 		fontString->string = "Battery unused";
1306aed176cSClemens Zeidler 
131*e391ec67SClemens Zeidler 	fontString = new FontString;
132*e391ec67SClemens Zeidler 	fontString->string = "Capacity: ";
133*e391ec67SClemens Zeidler 	fontString->string << fBatteryInfo.capacity;
134*e391ec67SClemens Zeidler 	fontString->string << powerUnit;
135*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1366aed176cSClemens Zeidler 
137*e391ec67SClemens Zeidler 	fontString = new FontString;
138*e391ec67SClemens Zeidler 	fontString->string = "Last full Charge: ";
139*e391ec67SClemens Zeidler 	fontString->string << fBatteryInfo.full_capacity;
140*e391ec67SClemens Zeidler 	fontString->string << powerUnit;
141*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1426aed176cSClemens Zeidler 
143*e391ec67SClemens Zeidler 	fontString = new FontString;
144*e391ec67SClemens Zeidler 	fontString->string = "Current Rate: ";
145*e391ec67SClemens Zeidler 	fontString->string << fBatteryInfo.current_rate;
146*e391ec67SClemens Zeidler 	fontString->string << rateUnit;
147*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1486aed176cSClemens Zeidler 
149*e391ec67SClemens Zeidler 	// empty line
150*e391ec67SClemens Zeidler 	fontString = new FontString;
151*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1526aed176cSClemens Zeidler 
153*e391ec67SClemens Zeidler 	fontString = new FontString;
154*e391ec67SClemens Zeidler 	fontString->string = "Design Capacity: ";
155*e391ec67SClemens Zeidler 	fontString->string << fBatteryExtendedInfo.design_capacity;
156*e391ec67SClemens Zeidler 	fontString->string << powerUnit;
157*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1586aed176cSClemens Zeidler 
159*e391ec67SClemens Zeidler 	fontString = new FontString;
160*e391ec67SClemens Zeidler 	fontString->string = "Technology: ";
161*e391ec67SClemens Zeidler 	fontString->string << fBatteryExtendedInfo.technology;
162*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1636aed176cSClemens Zeidler 
164*e391ec67SClemens Zeidler 	fontString = new FontString;
165*e391ec67SClemens Zeidler 	fontString->string = "Design Voltage: ";
166*e391ec67SClemens Zeidler 	fontString->string << fBatteryExtendedInfo.design_voltage;
167*e391ec67SClemens Zeidler 	fontString->string << " mV";
168*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1696aed176cSClemens Zeidler 
170*e391ec67SClemens Zeidler 	fontString = new FontString;
171*e391ec67SClemens Zeidler 	fontString->string = "Design Capacity Warning: ";
172*e391ec67SClemens Zeidler 	fontString->string << fBatteryExtendedInfo.design_capacity_warning;
173*e391ec67SClemens Zeidler 	fontString->string << powerUnit;
174*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1756aed176cSClemens Zeidler 
176*e391ec67SClemens Zeidler 	fontString = new FontString;
177*e391ec67SClemens Zeidler 	fontString->string = "Design Capacity low Warning: ";
178*e391ec67SClemens Zeidler 	fontString->string << fBatteryExtendedInfo.design_capacity_low;
179*e391ec67SClemens Zeidler 	fontString->string << powerUnit;
180*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1816aed176cSClemens Zeidler 
182*e391ec67SClemens Zeidler 	fontString = new FontString;
183*e391ec67SClemens Zeidler 	fontString->string = "Capacity Granularity 1: ";
184*e391ec67SClemens Zeidler 	fontString->string << fBatteryExtendedInfo.capacity_granularity_1;
185*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1866aed176cSClemens Zeidler 
187*e391ec67SClemens Zeidler 	fontString = new FontString;
188*e391ec67SClemens Zeidler 	fontString->string = "Capacity Granularity 2: ";
189*e391ec67SClemens Zeidler 	fontString->string << fBatteryExtendedInfo.capacity_granularity_2;
190*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1916aed176cSClemens Zeidler 
192*e391ec67SClemens Zeidler 	fontString = new FontString;
193*e391ec67SClemens Zeidler 	fontString->string = "Model Number: ";
194*e391ec67SClemens Zeidler 	fontString->string << fBatteryExtendedInfo.model_number;
195*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
1966aed176cSClemens Zeidler 
197*e391ec67SClemens Zeidler 	fontString = new FontString;
198*e391ec67SClemens Zeidler 	fontString->string = "Serial number: ";
199*e391ec67SClemens Zeidler 	fontString->string << fBatteryExtendedInfo.serial_number;
200*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
2016aed176cSClemens Zeidler 
202*e391ec67SClemens Zeidler 	fontString = new FontString;
203*e391ec67SClemens Zeidler 	fontString->string = "Type: ";
204*e391ec67SClemens Zeidler 	fontString->string += fBatteryExtendedInfo.type;
205*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
2066aed176cSClemens Zeidler 
207*e391ec67SClemens Zeidler 	fontString = new FontString;
208*e391ec67SClemens Zeidler 	fontString->string = "OEM Info: ";
209*e391ec67SClemens Zeidler 	fontString->string += fBatteryExtendedInfo.oem_info;
210*e391ec67SClemens Zeidler 	_AddToStringList(fontString);
2116aed176cSClemens Zeidler 
212*e391ec67SClemens Zeidler 	fPreferredSize.width = fMaxStringSize.width + 10;
213*e391ec67SClemens Zeidler 	fPreferredSize.height = (fMaxStringSize.height + kLineSpacing) *
214*e391ec67SClemens Zeidler 		fStringList.CountItems();
215*e391ec67SClemens Zeidler }
216*e391ec67SClemens Zeidler 
217*e391ec67SClemens Zeidler 
218*e391ec67SClemens Zeidler void
219*e391ec67SClemens Zeidler BatteryInfoView::_AddToStringList(FontString* fontString)
220*e391ec67SClemens Zeidler {
221*e391ec67SClemens Zeidler 	fStringList.AddItem(fontString);
222*e391ec67SClemens Zeidler 	BSize stringSize = _MeasureString(fontString->string);
223*e391ec67SClemens Zeidler 	if (fMaxStringSize.width < stringSize.width)
224*e391ec67SClemens Zeidler 		fMaxStringSize = stringSize;
225*e391ec67SClemens Zeidler }
226*e391ec67SClemens Zeidler 
227*e391ec67SClemens Zeidler 
228*e391ec67SClemens Zeidler void
229*e391ec67SClemens Zeidler BatteryInfoView::_ClearStringList()
230*e391ec67SClemens Zeidler {
231*e391ec67SClemens Zeidler 	for (int i = 0; i < fStringList.CountItems(); i ++)
232*e391ec67SClemens Zeidler 		delete fStringList.ItemAt(i);
233*e391ec67SClemens Zeidler 	fStringList.MakeEmpty();
234*e391ec67SClemens Zeidler 	fMaxStringSize = BSize(0, 0);
2356aed176cSClemens Zeidler }
2366aed176cSClemens Zeidler 
2376aed176cSClemens Zeidler 
2386aed176cSClemens Zeidler ExtPowerStatusView::ExtPowerStatusView(PowerStatusDriverInterface* interface,
2396aed176cSClemens Zeidler 			BRect frame, int32 resizingMode, int batteryId,
2406aed176cSClemens Zeidler 			ExtendedInfoWindow* window)
2416aed176cSClemens Zeidler 	:
2426aed176cSClemens Zeidler 	PowerStatusView(interface, frame, resizingMode, batteryId),
2436aed176cSClemens Zeidler 	fExtendedInfoWindow(window),
2446aed176cSClemens Zeidler 	fBatteryInfoView(window->GetExtendedBatteryInfoView()),
2456aed176cSClemens Zeidler 	fSelected(false)
2466aed176cSClemens Zeidler {
2476aed176cSClemens Zeidler 
2486aed176cSClemens Zeidler }
2496aed176cSClemens Zeidler 
2506aed176cSClemens Zeidler 
2516aed176cSClemens Zeidler void
2526aed176cSClemens Zeidler ExtPowerStatusView::Draw(BRect updateRect)
2536aed176cSClemens Zeidler {
2546aed176cSClemens Zeidler 	if (fSelected) {
2556aed176cSClemens Zeidler 		SetLowColor(102, 152, 203);
2566aed176cSClemens Zeidler 		SetHighColor(102, 152, 203);
2576aed176cSClemens Zeidler 		FillRect(updateRect);
2586aed176cSClemens Zeidler 	}
2596aed176cSClemens Zeidler 	else {
2606aed176cSClemens Zeidler 		SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
2616aed176cSClemens Zeidler 		SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
2626aed176cSClemens Zeidler 		FillRect(updateRect);
2636aed176cSClemens Zeidler 	}
2646aed176cSClemens Zeidler 
2656aed176cSClemens Zeidler 	PowerStatusView::Draw(updateRect);
2666aed176cSClemens Zeidler }
2676aed176cSClemens Zeidler 
2686aed176cSClemens Zeidler 
2696aed176cSClemens Zeidler void
2706aed176cSClemens Zeidler ExtPowerStatusView::MouseDown(BPoint where)
2716aed176cSClemens Zeidler {
2726aed176cSClemens Zeidler 	if (!fSelected) {
2736aed176cSClemens Zeidler 		fSelected = true;
2746aed176cSClemens Zeidler 		_Update(true);
2756aed176cSClemens Zeidler 		fExtendedInfoWindow->BatterySelected(this);
2766aed176cSClemens Zeidler 	}
2776aed176cSClemens Zeidler }
2786aed176cSClemens Zeidler 
2796aed176cSClemens Zeidler 
2806aed176cSClemens Zeidler void
2816aed176cSClemens Zeidler ExtPowerStatusView::Select(bool select)
2826aed176cSClemens Zeidler {
2836aed176cSClemens Zeidler 	fSelected = select;
2846aed176cSClemens Zeidler 	_Update(true);
2856aed176cSClemens Zeidler }
2866aed176cSClemens Zeidler 
2876aed176cSClemens Zeidler 
2886aed176cSClemens Zeidler bool
2896aed176cSClemens Zeidler ExtPowerStatusView::IsValid()
2906aed176cSClemens Zeidler {
2916aed176cSClemens Zeidler 	if (fBatteryInfo.state & BATTERY_CRITICAL_STATE)
2926aed176cSClemens Zeidler 		return false;
2936aed176cSClemens Zeidler 	return true;
2946aed176cSClemens Zeidler }
2956aed176cSClemens Zeidler 
2966aed176cSClemens Zeidler 
2976aed176cSClemens Zeidler void
2986aed176cSClemens Zeidler ExtPowerStatusView::_Update(bool force)
2996aed176cSClemens Zeidler {
3006aed176cSClemens Zeidler 	PowerStatusView::_Update(force);
3016aed176cSClemens Zeidler 	if (!fSelected)
3026aed176cSClemens Zeidler 		return;
3036aed176cSClemens Zeidler 
3046aed176cSClemens Zeidler 	acpi_extended_battery_info extInfo;
3056aed176cSClemens Zeidler 	fDriverInterface->GetExtendedBatteryInfo(&extInfo, fBatteryId);
3066aed176cSClemens Zeidler 
3076aed176cSClemens Zeidler 	fBatteryInfoView->Update(fBatteryInfo, extInfo);
3086aed176cSClemens Zeidler 	fBatteryInfoView->Invalidate();
3096aed176cSClemens Zeidler }
3106aed176cSClemens Zeidler 
3116aed176cSClemens Zeidler 
3126aed176cSClemens Zeidler ExtendedInfoWindow::ExtendedInfoWindow(PowerStatusDriverInterface* interface)
3136aed176cSClemens Zeidler 	:
3146aed176cSClemens Zeidler 	BWindow(BRect(100, 150, 500, 500), "Extended Battery Info", B_TITLED_WINDOW,
315*e391ec67SClemens Zeidler 		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AVOID_FRONT |
316*e391ec67SClemens Zeidler 		B_ASYNCHRONOUS_CONTROLS),
3176aed176cSClemens Zeidler 	fDriverInterface(interface),
3186aed176cSClemens Zeidler 	fSelectedView(NULL)
3196aed176cSClemens Zeidler {
3206aed176cSClemens Zeidler 	BView *view = new BView(Bounds(), "view", B_FOLLOW_ALL, 0);
3216aed176cSClemens Zeidler 	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
3226aed176cSClemens Zeidler 	AddChild(view);
3236aed176cSClemens Zeidler 
3246aed176cSClemens Zeidler 	BGroupLayout* mainLayout = new BGroupLayout(B_VERTICAL);
3256aed176cSClemens Zeidler 	mainLayout->SetSpacing(10);
3266aed176cSClemens Zeidler 	mainLayout->SetInsets(10, 10, 10, 10);
3276aed176cSClemens Zeidler 	view->SetLayout(mainLayout);
3286aed176cSClemens Zeidler 
3296aed176cSClemens Zeidler 	BRect rect = Bounds();
3306aed176cSClemens Zeidler 	rect.InsetBy(5, 5);
3316aed176cSClemens Zeidler 	BBox *infoBox = new BBox(rect, "Power Status Box");
3326aed176cSClemens Zeidler 	infoBox->SetLabel("Battery Info");
3336aed176cSClemens Zeidler 	BGroupLayout* infoLayout = new BGroupLayout(B_HORIZONTAL);
3346aed176cSClemens Zeidler 	infoLayout->SetInsets(10, infoBox->TopBorderOffset() * 2 + 10, 10, 10);
3356aed176cSClemens Zeidler 	infoLayout->SetSpacing(10);
3366aed176cSClemens Zeidler 	infoBox->SetLayout(infoLayout);
3376aed176cSClemens Zeidler 	mainLayout->AddView(infoBox);
3386aed176cSClemens Zeidler 
3396aed176cSClemens Zeidler 	BGroupView* batteryView = new BGroupView(B_VERTICAL);
3406aed176cSClemens Zeidler 	batteryView->GroupLayout()->SetSpacing(10);
3416aed176cSClemens Zeidler 	infoLayout->AddView(batteryView);
3426aed176cSClemens Zeidler 
343*e391ec67SClemens Zeidler 	// create before the battery views
344*e391ec67SClemens Zeidler 	fBatteryInfoView = new BatteryInfoView();
3456aed176cSClemens Zeidler 
3466aed176cSClemens Zeidler 	BGroupLayout* batteryLayout = batteryView->GroupLayout();
3476aed176cSClemens Zeidler 	BRect batteryRect(0, 0, 50, 30);
3486aed176cSClemens Zeidler 	for (int i = 0; i < interface->GetBatteryCount(); i++) {
3496aed176cSClemens Zeidler 		ExtPowerStatusView* view = new ExtPowerStatusView(interface,
350*e391ec67SClemens Zeidler 			batteryRect, B_FOLLOW_NONE, i, this);
351*e391ec67SClemens Zeidler 		view->SetExplicitMaxSize(BSize(70, 80));
352*e391ec67SClemens Zeidler 		view->SetExplicitMinSize(BSize(70, 80));
353*e391ec67SClemens Zeidler 
3546aed176cSClemens Zeidler 		batteryLayout->AddView(view);
3556aed176cSClemens Zeidler 		fBatteryViewList.AddItem(view);
3566aed176cSClemens Zeidler 		fDriverInterface->StartWatching(view);
3576aed176cSClemens Zeidler 		if (view->IsValid())
3586aed176cSClemens Zeidler 			fSelectedView = view;
3596aed176cSClemens Zeidler 	}
3606aed176cSClemens Zeidler 
3616aed176cSClemens Zeidler 	batteryLayout->AddItem(BSpaceLayoutItem::CreateGlue());
3626aed176cSClemens Zeidler 
363*e391ec67SClemens Zeidler 	infoLayout->AddView(fBatteryInfoView);
3646aed176cSClemens Zeidler 
3656aed176cSClemens Zeidler 	if (!fSelectedView && fBatteryViewList.CountItems() > 0)
3666aed176cSClemens Zeidler 		fSelectedView = fBatteryViewList.ItemAt(0);
3676aed176cSClemens Zeidler 	fSelectedView->Select();
3686aed176cSClemens Zeidler 
3696aed176cSClemens Zeidler 	BSize size = mainLayout->PreferredSize();
3706aed176cSClemens Zeidler 	ResizeTo(size.width, size.height);
3716aed176cSClemens Zeidler }
3726aed176cSClemens Zeidler 
3736aed176cSClemens Zeidler 
3746aed176cSClemens Zeidler ExtendedInfoWindow::~ExtendedInfoWindow()
3756aed176cSClemens Zeidler {
3766aed176cSClemens Zeidler 	for (int i = 0; i < fBatteryViewList.CountItems(); i++) {
3776aed176cSClemens Zeidler 		fDriverInterface->StopWatching(fBatteryViewList.ItemAt(i));
3786aed176cSClemens Zeidler 	}
3796aed176cSClemens Zeidler }
3806aed176cSClemens Zeidler 
3816aed176cSClemens Zeidler 
3826aed176cSClemens Zeidler BatteryInfoView*
3836aed176cSClemens Zeidler ExtendedInfoWindow::GetExtendedBatteryInfoView()
3846aed176cSClemens Zeidler {
3856aed176cSClemens Zeidler 	return fBatteryInfoView;
3866aed176cSClemens Zeidler }
3876aed176cSClemens Zeidler 
3886aed176cSClemens Zeidler 
3896aed176cSClemens Zeidler void
3906aed176cSClemens Zeidler ExtendedInfoWindow::BatterySelected(ExtPowerStatusView* view)
3916aed176cSClemens Zeidler {
3926aed176cSClemens Zeidler 	if (fSelectedView) {
3936aed176cSClemens Zeidler 		fSelectedView->Select(false);
3946aed176cSClemens Zeidler 		fSelectedView->Invalidate();
3956aed176cSClemens Zeidler 	}
3966aed176cSClemens Zeidler 
3976aed176cSClemens Zeidler 	fSelectedView = view;
3986aed176cSClemens Zeidler }
399