xref: /haiku/src/apps/powerstatus/ExtendedInfoWindow.h (revision 8b24b02f060e46f2714889158df0b1535850995d)
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 #ifndef EXTENDED_INFO_WINDOW_H
106aed176cSClemens Zeidler #define EXTENDED_INFO_WINDOW_H
116aed176cSClemens Zeidler 
126aed176cSClemens Zeidler #include <ObjectList.h>
13e391ec67SClemens Zeidler #include <String.h>
146aed176cSClemens Zeidler #include <View.h>
156aed176cSClemens Zeidler #include <Window.h>
166aed176cSClemens Zeidler 
176aed176cSClemens Zeidler #include "DriverInterface.h"
186aed176cSClemens Zeidler #include "PowerStatusView.h"
196aed176cSClemens Zeidler 
206aed176cSClemens Zeidler 
21e391ec67SClemens Zeidler class FontString
22e391ec67SClemens Zeidler {
23e391ec67SClemens Zeidler public:
24e391ec67SClemens Zeidler 					FontString();
25e391ec67SClemens Zeidler 
26e391ec67SClemens Zeidler 	const BFont*	font;
27e391ec67SClemens Zeidler 	BString			string;
28e391ec67SClemens Zeidler };
29e391ec67SClemens Zeidler 
30e391ec67SClemens Zeidler 
316aed176cSClemens Zeidler class BatteryInfoView : public BView
326aed176cSClemens Zeidler {
336aed176cSClemens Zeidler 	public:
34e391ec67SClemens Zeidler 						BatteryInfoView();
35e391ec67SClemens Zeidler 						~BatteryInfoView();
366aed176cSClemens Zeidler 
376aed176cSClemens Zeidler 		virtual void	Update(battery_info& info,
386aed176cSClemens Zeidler 							acpi_extended_battery_info& extInfo);
396aed176cSClemens Zeidler 		virtual	void	Draw(BRect updateRect);
40e391ec67SClemens Zeidler 		virtual void	GetPreferredSize(float *width, float *height);
41*8b24b02fSClemens Zeidler 		virtual void	AttachedToWindow();
426aed176cSClemens Zeidler 
436aed176cSClemens Zeidler 	private:
44e391ec67SClemens Zeidler 		BSize			_MeasureString(const BString& string);
45e391ec67SClemens Zeidler 		void			_FillStringList();
46e391ec67SClemens Zeidler 		void			_AddToStringList(FontString* fontString);
47e391ec67SClemens Zeidler 		void			_ClearStringList();
48e391ec67SClemens Zeidler 
496aed176cSClemens Zeidler 		battery_info				fBatteryInfo;
506aed176cSClemens Zeidler 		acpi_extended_battery_info	fBatteryExtendedInfo;
51e391ec67SClemens Zeidler 
52e391ec67SClemens Zeidler 		BSize						fPreferredSize;
53e391ec67SClemens Zeidler 
54e391ec67SClemens Zeidler 		BObjectList<FontString>		fStringList;
55e391ec67SClemens Zeidler 		BSize						fMaxStringSize;
566aed176cSClemens Zeidler };
576aed176cSClemens Zeidler 
586aed176cSClemens Zeidler 
596aed176cSClemens Zeidler class ExtendedInfoWindow;
606aed176cSClemens Zeidler 
616aed176cSClemens Zeidler class ExtPowerStatusView : public PowerStatusView
626aed176cSClemens Zeidler {
636aed176cSClemens Zeidler 	public:
646aed176cSClemens Zeidler 		ExtPowerStatusView(PowerStatusDriverInterface* interface,
656aed176cSClemens Zeidler 			BRect frame, int32 resizingMode, int batteryId,
666aed176cSClemens Zeidler 			ExtendedInfoWindow* window);
676aed176cSClemens Zeidler 
686aed176cSClemens Zeidler 		virtual	void	Draw(BRect updateRect);
696aed176cSClemens Zeidler 		virtual	void	MouseDown(BPoint where);
706aed176cSClemens Zeidler 
716aed176cSClemens Zeidler 		virtual void	Select(bool select = true);
726aed176cSClemens Zeidler 
736aed176cSClemens Zeidler 		// return true if it battery is in a none critical state
746aed176cSClemens Zeidler 		virtual bool	IsValid();
756aed176cSClemens Zeidler 
766aed176cSClemens Zeidler 	protected:
776aed176cSClemens Zeidler 		virtual void	_Update(bool force = false);
786aed176cSClemens Zeidler 
796aed176cSClemens Zeidler 	private:
806aed176cSClemens Zeidler 		ExtendedInfoWindow*	fExtendedInfoWindow;
816aed176cSClemens Zeidler 		BatteryInfoView*	fBatteryInfoView;
826aed176cSClemens Zeidler 
836aed176cSClemens Zeidler 		bool				fSelected;
846aed176cSClemens Zeidler };
856aed176cSClemens Zeidler 
866aed176cSClemens Zeidler 
876aed176cSClemens Zeidler class ExtendedInfoWindow : public BWindow
886aed176cSClemens Zeidler {
896aed176cSClemens Zeidler public:
906aed176cSClemens Zeidler 		ExtendedInfoWindow(PowerStatusDriverInterface* interface);
916aed176cSClemens Zeidler 		~ExtendedInfoWindow();
926aed176cSClemens Zeidler 
936aed176cSClemens Zeidler 	BatteryInfoView*			GetExtendedBatteryInfoView();
946aed176cSClemens Zeidler 
956aed176cSClemens Zeidler 	void						BatterySelected(ExtPowerStatusView* view);
966aed176cSClemens Zeidler 
976aed176cSClemens Zeidler private:
986aed176cSClemens Zeidler 	PowerStatusDriverInterface* 		fDriverInterface;
996aed176cSClemens Zeidler 	BObjectList<ExtPowerStatusView>		fBatteryViewList;
1006aed176cSClemens Zeidler 
1016aed176cSClemens Zeidler 	BatteryInfoView*					fBatteryInfoView;
1026aed176cSClemens Zeidler 
1036aed176cSClemens Zeidler 	ExtPowerStatusView*					fSelectedView;
1046aed176cSClemens Zeidler };
1056aed176cSClemens Zeidler 
1066aed176cSClemens Zeidler 
1076aed176cSClemens Zeidler #endif
108