2 * Copyright 2016-2017 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license
6 * Alexander von Gluck IV <kallisti5@unixzen.com>
7 * Brian Hill <supernova@tycho.email>
9 #ifndef _SOFTWARE_UPDATER_WINDOW_H
10 #define _SOFTWARE_UPDATER_WINDOW_H
15 #include <GroupView.h>
16 #include <MessageRunner.h>
18 #include <OutlineListView.h>
21 #include <ScrollView.h>
22 #include <StatusBar.h>
23 #include <StringView.h>
26 #include "StripeView.h"
28 using namespace BPrivate
;
37 class SuperItem
: public BListItem
{
39 SuperItem(const char* label
);
41 virtual void DrawItem(BView
*, BRect
, bool);
42 float GetPackageItemHeight();
43 float GetPackageItemHeight(bool showMoreDetails
);
44 BBitmap
* GetIcon(bool showMoreDetails
);
45 float GetIconSize(bool showMoreDetails
);
46 void SetDetailLevel(bool showMoreDetails
);
47 bool GetDetailLevel() { return fShowMoreDetails
; };
48 void SetItemCount(int32 count
);
49 float ZoomWidth(BView
*owner
);
52 BBitmap
* _GetPackageIcon(float listItemHeight
);
58 bool fShowMoreDetails
;
59 font_height fBoldFontHeight
;
60 float fPackageItemLineHeight
;
61 BBitmap
* fPackageLessIcon
;
62 BBitmap
* fPackageMoreIcon
;
67 class PackageItem
: public BListItem
{
69 PackageItem(const char* name
,
70 const char* simple_version
,
71 const char* detailed_version
,
72 const char* repository
,
74 const char* file_name
,
76 virtual void DrawItem(BView
*, BRect
, bool);
77 virtual void Update(BView
*owner
, const BFont
*font
);
78 void CalculateZoomWidths(BView
*owner
);
79 int NameCompare(PackageItem
* item
);
80 const char* FileName() { return fFileName
.String(); };
81 void SetDownloadProgress(float percent
);
82 void ShowProgressBar() { fDrawBarFlag
= true; };
83 float MoreDetailsWidth()
84 { return fMoreDetailsWidth
; };
85 float LessDetailsWidth()
86 { return fLessDetailsWidth
; };
89 void _DrawBar(BPoint where
, BView
* view
,
93 BString fSimpleVersion
;
94 BString fDetailedVersion
;
98 font_height fSmallFontHeight
;
99 float fSmallTotalHeight
;
101 SuperItem
* fSuperItem
;
103 float fDownloadProgress
;
105 float fMoreDetailsWidth
;
106 float fLessDetailsWidth
;
110 class PackageListView
: public BOutlineListView
{
113 virtual void FrameResized(float newWidth
, float newHeight
);
114 void ExpandOrCollapse(BListItem
*superItem
,
116 void AddPackage(uint32 install_type
,
121 const char* repository
,
122 const char* file_name
);
123 void UpdatePackageProgress(const char* packageName
,
127 void SetMoreDetails(bool showMore
);
131 void _SetItemHeights();
133 SuperItem
* fSuperUpdateItem
;
134 SuperItem
* fSuperInstallItem
;
135 SuperItem
* fSuperUninstallItem
;
136 bool fShowMoreDetails
;
137 PackageItem
* fLastProgressItem
;
138 int16 fLastProgressValue
;
142 class SoftwareUpdaterWindow
: public BWindow
{
144 SoftwareUpdaterWindow();
145 bool QuitRequested();
146 void FrameMoved(BPoint newPosition
);
147 void FrameResized(float newWidth
, float newHeight
);
148 void Zoom(BPoint origin
, float width
, float height
);
149 void MessageReceived(BMessage
* message
);
150 bool ConfirmUpdates();
151 void UpdatesApplying(const char* header
,
153 bool UserCancelRequested();
154 void AddPackageInfo(uint32 install_type
,
155 const char* package_name
,
159 const char* repository
,
160 const char* file_name
);
161 void ShowWarningAlert(const char* text
);
162 BBitmap
GetIcon(int32 iconSize
);
163 BRect
GetDefaultRect() { return fDefaultRect
; };
164 BPoint
GetLocation() { return Frame().LeftTop(); };
165 BLayoutItem
* layout_item_for(BView
* view
);
166 void FinalUpdate(const char* header
,
170 uint32
_WaitForButtonClick();
171 void _SetState(uint32 state
);
173 status_t
_WriteSettings();
174 status_t
_ReadSettings(BMessage
& settings
);
177 StripeView
* fStripeView
;
178 BStringView
* fHeaderView
;
179 BStringView
* fDetailView
;
180 BButton
* fUpdateButton
;
181 BButton
* fCancelButton
;
182 BStatusBar
* fStatusBar
;
183 PackageListView
* fListView
;
184 BScrollView
* fScrollView
;
185 BCheckBox
* fDetailsCheckbox
;
186 BLayoutItem
* fDetailsLayoutItem
;
187 BLayoutItem
* fPackagesLayoutItem
;
188 BLayoutItem
* fProgressLayoutItem
;
189 BLayoutItem
* fCancelButtonLayoutItem
;
190 BLayoutItem
* fUpdateButtonLayoutItem
;
191 BLayoutItem
* fDetailsCheckboxLayoutItem
;
193 uint32 fCurrentState
;
195 bool fWaitingForButton
;
196 uint32 fButtonResult
;
197 bool fUpdateConfirmed
;
198 bool fUserCancelRequested
;
199 BInvoker fCancelAlertResponse
;
200 int32 fWarningAlertCount
;
201 BInvoker fWarningAlertDismissed
;
203 status_t fSettingsReadStatus
;
204 BMessage fInitialSettings
;
205 bool fSaveFrameChanges
;
206 BMessageRunner
* fMessageRunner
;
207 BMessage fFrameChangeMessage
;
208 float fZoomHeightBaseline
;
209 float fZoomWidthBaseline
;
213 int SortPackageItems(const BListItem
* item1
, const BListItem
* item2
);
216 #endif // _SOFTWARE_UPDATER_WINDOW_H