-
-
Notifications
You must be signed in to change notification settings - Fork 335
/
SoftwareUpdaterWindow.h
188 lines (157 loc) · 4.6 KB
/
SoftwareUpdaterWindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
* Copyright 2016-2017 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT license
*
* Authors:
* Alexander von Gluck IV <kallisti5@unixzen.com>
* Brian Hill <supernova@warpmail.net>
*/
#ifndef _SOFTWARE_UPDATER_WINDOW_H
#define _SOFTWARE_UPDATER_WINDOW_H
#include <Button.h>
#include <GroupView.h>
#include <OutlineListView.h>
#include <Point.h>
#include <ScrollView.h>
#include <StatusBar.h>
#include <StringView.h>
#include <ToolTip.h>
#include <Window.h>
#include "StripeView.h"
using namespace BPrivate;
enum {
PACKAGE_UPDATE,
PACKAGE_INSTALL,
PACKAGE_UNINSTALL
};
class SuperItem : public BListItem {
public:
SuperItem(const char* label);
~SuperItem();
virtual void DrawItem(BView*, BRect, bool);
virtual void Update(BView *owner, const BFont *font);
font_height GetFontHeight() { return fFontHeight; };
float GetPackageItemHeight()
{ return fPackageItemHeight; };
BBitmap* GetIcon() { return fPackageIcon; };
int16 GetIconSize() { return fIconSize; };
private:
void _GetPackageIcon();
BString fLabel;
BFont fRegularFont;
BFont fBoldFont;
font_height fFontHeight;
float fPackageItemHeight;
BBitmap* fPackageIcon;
int16 fIconSize;
};
class PackageItem : public BListItem {
public:
PackageItem(const char* name,
const char* version,
const char* summary,
const char* tooltip,
SuperItem* super);
~PackageItem();
virtual void DrawItem(BView*, BRect, bool);
virtual void Update(BView *owner, const BFont *font);
void SetItemHeight(const BFont* font);
int ICompare(PackageItem* item);
BTextToolTip* ToolTip() { return fToolTip; };
private:
BString fName;
BString fVersion;
BString fSummary;
BTextToolTip* fToolTip;
BFont fRegularFont;
BFont fSmallFont;
font_height fSmallFontHeight;
float fSmallTotalHeight;
float fLabelOffset;
SuperItem* fSuperItem;
};
class PackageListView : public BOutlineListView {
public:
PackageListView();
virtual void FrameResized(float newWidth, float newHeight);
void AddPackage(uint32 install_type,
const char* name,
const char* cur_ver,
const char* new_ver,
const char* summary,
const char* repository);
void SortItems();
float ItemHeight();
protected:
virtual bool GetToolTipAt(BPoint point, BToolTip** _tip);
private:
SuperItem* fSuperUpdateItem;
SuperItem* fSuperInstallItem;
SuperItem* fSuperUninstallItem;
};
class SoftwareUpdaterWindow : public BWindow {
public:
SoftwareUpdaterWindow();
~SoftwareUpdaterWindow();
void MessageReceived(BMessage* message);
bool ConfirmUpdates(const char* text);
void UpdatesApplying(const char* header,
const char* detail);
bool UserCancelRequested();
void AddPackageInfo(uint32 install_type,
const char* package_name,
const char* cur_ver,
const char* new_ver,
const char* summary,
const char* repository);
void ShowWarningAlert(const char* text);
const BBitmap* GetIcon() { return fIcon; };
BRect GetDefaultRect() { return fDefaultRect; };
BPoint GetLocation() { return Frame().LeftTop(); };
BLayoutItem* layout_item_for(BView* view);
private:
uint32 _WaitForButtonClick();
void _SetState(uint32 state);
uint32 _GetState();
BRect fDefaultRect;
StripeView* fStripeView;
BStringView* fHeaderView;
BStringView* fDetailView;
BButton* fUpdateButton;
BButton* fCancelButton;
BStatusBar* fStatusBar;
#if USE_PANE_SWITCH
PaneSwitch* fPackagesSwitch;
BLayoutItem* fPkgSwitchLayoutItem;
#endif
PackageListView* fListView;
BScrollView* fScrollView;
BLayoutItem* fDetailsLayoutItem;
BLayoutItem* fPackagesLayoutItem;
BLayoutItem* fProgressLayoutItem;
BLayoutItem* fUpdateButtonLayoutItem;
BBitmap* fIcon;
uint32 fCurrentState;
sem_id fWaitingSem;
bool fWaitingForButton;
uint32 fButtonResult;
bool fUserCancelRequested;
BInvoker fCancelAlertResponse;
int32 fWarningAlertCount;
BInvoker fWarningAlertDismissed;
};
int SortPackageItems(const BListItem* item1, const BListItem* item2);
class FinalWindow : public BWindow {
public:
FinalWindow(BRect rect, BPoint location,
const char* header, const char* detail);
~FinalWindow();
void MessageReceived(BMessage* message);
private:
StripeView* fStripeView;
BStringView* fHeaderView;
BStringView* fDetailView;
BButton* fCancelButton;
BBitmap* fIcon;
};
#endif // _SOFTWARE_UPDATER_WINDOW_H