forked from HaikuArchives/Weather
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForecastView.h
169 lines (147 loc) · 4.41 KB
/
ForecastView.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
/*
* Copyright 2015 Adrián Arroyo Calle <[email protected]>
* Copyright 2015 Przemysław Buczkowski <[email protected]>
* Copyright 2014 George White
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef _FORECASTVIEW_H_
#define _FORECASTVIEW_H_
#include <Bitmap.h>
#include <Button.h>
#include <DateFormat.h>
#include <Dragger.h>
#include <FormattingConventions.h>
#include <GridLayout.h>
#include <GridView.h>
#include <GroupView.h>
#include <MenuBar.h>
#include <Resources.h>
#include <String.h>
#include <StringView.h>
#include <View.h>
#include <Window.h>
#include "ForecastDayView.h"
#include "LabelView.h"
#include "PreferencesWindow.h"
#include "SelectionWindow.h"
const uint32 kAutoUpdateMessage = 'AutU';
const uint32 kUpdateMessage = 'Upda';
const uint32 kShowForecastMessage = 'SFor';
const uint32 kSettingsMessage = 'Pref';
extern const char* kSettingsFileName;
const uint32 kSizeSmallIcon = 40;
const uint32 kSizeLargeIcon = 80;
const uint32 kSizeDeskBarIcon = 16;
enum weatherIconSize {
SMALL_ICON,
LARGE_ICON,
DESKBAR_ICON
};
class _EXPORT ForecastView;
class ForecastView : public BView {
public:
ForecastView(BRect frame, BMessage* settings);
ForecastView(BMessage* archive);
virtual ~ForecastView();
virtual void MessageReceived(BMessage* msg);
virtual void AttachedToWindow();
virtual void AllAttached();
virtual void Draw(BRect updateRect);
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* archive);
status_t SaveState(BMessage* into, bool deep = true) const;
void SetDisplayUnit(DisplayUnit unit);
void Reload(bool forcedForecast = false);
void StopReload();
void SetCityName(BString city);
BString CityName();
void SetCityId(BString cityId);
BString CityId();
void SetCondition(BString condition);
void SetUpdateDelay(int32 delay);
int32 UpdateDelay();
DisplayUnit Unit();
bool IsFahrenheitDefault();
void SetShowForecast(bool showForecast);
bool ShowForecast();
void SetTextColor(rgb_color color);
void SetBackgroundColor(rgb_color color);
bool IsDefaultColor() const;
bool IsConnected() const;
BBitmap* GetWeatherIcon(weatherIconSize size);
BBitmap* GetWeatherIcon(int32 condition, weatherIconSize size);
int32 GetCondition();
BString GetStatus();
int32 Temperature();
private:
void _Init();
void _DownloadData();
static int32 _DownloadDataFunc(void *cookie);
void _LoadBitmaps();
void _DeleteBitmaps();
void _DeleteIcons(BBitmap* bitmap[2]);
const char * _GetWeatherMessage(int32 condition);
BString _GetDayText(const BString& day) const;
status_t _ApplyState(BMessage *settings);
void _ShowForecast(bool);
void _LoadIcons(BBitmap* bitmap[2], uint32 type, const char* name);
bool _SupportTransparent();
bool _NetworkConnected();
thread_id fDownloadThread;
bool fForcedForecast;
BGridView* fView;
BGridLayout* fLayout;
bool fReplicated;
BString fCity;
BString fCityId;
int32 fUpdateDelay;
DisplayUnit fDisplayUnit;
bool fShowForecast;
int32 fTemperature;
int32 fCondition;
BDateFormat fDateFormat;
SelectionWindow* fSelectionWindow;
PreferencesWindow* fPreferencesWindow;
BMessageRunner* fAutoUpdate;
BMessageRunner* fDelayUpdateAfterReconnection;
bool fConnected;
BBitmap* fAlert[3];
BBitmap* fClearNight[3];
BBitmap* fClear[3];
BBitmap* fClouds[3];
BBitmap* fCold[3];
BBitmap* fDrizzle[3];
BBitmap* fFewClouds[3];
BBitmap* fFog[3];
BBitmap* fFreezingDrizzle[3];
BBitmap* fLightSnow[3];
BBitmap* fMixedSnowRain[3];
BBitmap* fMostlyCloudyNight[3];
BBitmap* fNightFewClouds[3];
BBitmap* fRainingScattered[3];
BBitmap* fRaining[3];
BBitmap* fSevereThunderstorm[3];
BBitmap* fShining[3];
BBitmap* fShiny[3];
BBitmap* fSnow[3];
BBitmap* fStorm[3];
BBitmap* fThunder[3];
BBitmap* fTropicalStorm[3];
BBitmap* fCloud[3];
BBitmap* fIsolatedThunderstorm[3];
BBitmap* fIsolatedThundershowers[3];
BGroupView* fInfoView;
BGroupView* fNumberView;
BGroupView* fForecastView;
BMenuItem* fShowForecastMenuItem;
BButton* fConditionButton;
ForecastDayView* fForecastDayView[5];
LabelView* fConditionView;
LabelView* fTemperatureView;
LabelView* fCityView;
BDragger* fDragger;
rgb_color fBackgroundColor;
rgb_color fTextColor;
};
BString FormatString(DisplayUnit unit, int32 temp);
#endif // _FORECASTVIEW_H_