xref: /haiku/src/apps/powerstatus/ExtendedInfoWindow.h (revision 10074df18f9ae90f1d0a8fa93cf98f4e9ddeda0d)
1 /*
2  * Copyright 2009-2017, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Clemens Zeidler, haiku@Clemens-Zeidler.de
7  *		Kacper Kasper, kacperkasper@gmail.com
8  */
9 
10 #ifndef EXTENDED_INFO_WINDOW_H
11 #define EXTENDED_INFO_WINDOW_H
12 
13 
14 #include <ObjectList.h>
15 #include <String.h>
16 #include <StringView.h>
17 #include <TabView.h>
18 #include <View.h>
19 #include <Window.h>
20 
21 #include "DriverInterface.h"
22 #include "PowerStatusView.h"
23 
24 
25 class BatteryInfoView : public BView {
26 public:
27 							BatteryInfoView();
28 							~BatteryInfoView();
29 
30 	virtual void			Update(battery_info& info,
31 								acpi_extended_battery_info& extInfo);
32 	virtual void			AttachedToWindow();
33 
34 private:
35 			BString			_GetTextForLine(size_t line);
36 
37 			battery_info				fBatteryInfo;
38 			acpi_extended_battery_info	fBatteryExtendedInfo;
39 
40 			BObjectList<BStringView>	fStringList;
41 };
42 
43 
44 class ExtendedInfoWindow;
45 class BatteryTabView;
46 
47 class ExtPowerStatusView : public PowerStatusView {
48 public:
49 								ExtPowerStatusView(
50 									PowerStatusDriverInterface* interface,
51 									BRect frame, int32 resizingMode,
52 									int batteryID,
53 									BatteryInfoView* batteryInfoView,
54 									ExtendedInfoWindow* window);
55 
56 	virtual void				Select(bool select = true);
57 
58 	// return true if it battery is in a critical state
59 	virtual	bool				IsCritical();
60 
61 protected:
62 	virtual void				Update(bool force = false, bool notify = true);
63 
64 private:
65 			ExtendedInfoWindow*	fExtendedInfoWindow;
66 			BatteryInfoView*	fBatteryInfoView;
67 			BatteryTabView*		fBatteryTabView;
68 
69 			bool				fSelected;
70 };
71 
72 
73 class BatteryTab : public BTab {
74 public:
75 						BatteryTab(BatteryInfoView* target,
76 							ExtPowerStatusView* view);
77 						~BatteryTab();
78 
79 	virtual	void		Select(BView* owner);
80 
81 	virtual	void		DrawFocusMark(BView* owner, BRect frame);
82 	virtual	void		DrawLabel(BView* owner, BRect frame);
83 private:
84 	ExtPowerStatusView*	fBatteryView;
85 };
86 
87 
88 class BatteryTabView : public BTabView {
89 public:
90 					BatteryTabView(const char* name);
91 					~BatteryTabView();
92 
93 	virtual	BRect	TabFrame(int32 index) const;
94 };
95 
96 
97 class ExtendedInfoWindow : public BWindow
98 {
99 public:
100 		ExtendedInfoWindow(PowerStatusDriverInterface* interface);
101 		~ExtendedInfoWindow();
102 
103 	BatteryTabView*				GetBatteryTabView();
104 
105 private:
106 	PowerStatusDriverInterface* 		fDriverInterface;
107 	BObjectList<ExtPowerStatusView>		fBatteryViewList;
108 
109 	BatteryTabView*						fBatteryTabView;
110 
111 	ExtPowerStatusView*					fSelectedView;
112 };
113 
114 
115 #endif
116