summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-04-11 13:05:00 +0100
committerCarl Hetherington <cth@carlh.net>2016-04-11 13:05:00 +0100
commitc74d789ed75e87bccd094f45f082674f8f8d2f2f (patch)
tree991e253800e7e4bb4136d52d86d90846f1656ae7 /src/wx
parent304e32c0c9573b36171a2f6eddee6f7400874ed2 (diff)
Add UTC-3:30 timezone to cinema (#831).
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/cinema_dialog.cc62
-rw-r--r--src/wx/cinema_dialog.h27
-rw-r--r--src/wx/screens_panel.cc7
3 files changed, 81 insertions, 15 deletions
diff --git a/src/wx/cinema_dialog.cc b/src/wx/cinema_dialog.cc
index c0b7b5242..b4663195f 100644
--- a/src/wx/cinema_dialog.cc
+++ b/src/wx/cinema_dialog.cc
@@ -37,7 +37,7 @@ column (string s)
return s;
}
-CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, list<string> emails, int utc_offset)
+CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, list<string> emails, int utc_offset_hour, int utc_offset_minute)
: wxDialog (parent, wxID_ANY, std_to_wx (title))
{
wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
@@ -77,15 +77,41 @@ CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, list<st
overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
}
- for (int i = -11; i <= -1; ++i) {
- _utc_offset->Append (wxString::Format (_("UTC%d"), i));
- }
- _utc_offset->Append (_("UTC"));
- for (int i = 1; i <= 12; ++i) {
- _utc_offset->Append (wxString::Format (_("UTC+%d"), i));
+ _offsets.push_back (Offset (_("UTC-11"), -11, 0));
+ _offsets.push_back (Offset (_("UTC-10"), -10, 0));
+ _offsets.push_back (Offset (_("UTC-9"), -9, 0));
+ _offsets.push_back (Offset (_("UTC-8"), -8, 0));
+ _offsets.push_back (Offset (_("UTC-7"), -7, 0));
+ _offsets.push_back (Offset (_("UTC-6"), -6, 0));
+ _offsets.push_back (Offset (_("UTC-5"), -5, 0));
+ _offsets.push_back (Offset (_("UTC-4"), -4, 0));
+ _offsets.push_back (Offset (_("UTC-3:30"), -3, 30));
+ _offsets.push_back (Offset (_("UTC-3"), -3, 0));
+ _offsets.push_back (Offset (_("UTC-2"), -2, 0));
+ _offsets.push_back (Offset (_("UTC-1"), -1, 0));
+ _offsets.push_back (Offset (_("UTC") , 0, 0));
+ _offsets.push_back (Offset (_("UTC+1"), 1, 0));
+ _offsets.push_back (Offset (_("UTC+2"), 2, 0));
+ _offsets.push_back (Offset (_("UTC+3"), 3, 0));
+ _offsets.push_back (Offset (_("UTC+4"), 4, 0));
+ _offsets.push_back (Offset (_("UTC+5"), 5, 0));
+ _offsets.push_back (Offset (_("UTC+6"), 6, 0));
+ _offsets.push_back (Offset (_("UTC+7"), 7, 0));
+ _offsets.push_back (Offset (_("UTC+8"), 8, 0));
+ _offsets.push_back (Offset (_("UTC+9"), 9, 0));
+ _offsets.push_back (Offset (_("UTC+10"), 10, 0));
+ _offsets.push_back (Offset (_("UTC+11"), 11, 0));
+ _offsets.push_back (Offset (_("UTC+12"), 12, 0));
+
+ size_t sel;
+ for (size_t i = 0; i < _offsets.size(); ++i) {
+ _utc_offset->Append (_offsets[i].name);
+ if (_offsets[i].hour == utc_offset_hour && _offsets[i].minute == utc_offset_minute) {
+ sel = i;
+ }
}
- _utc_offset->SetSelection (utc_offset + 11);
+ _utc_offset->SetSelection (sel);
overall_sizer->Layout ();
overall_sizer->SetSizeHints (this);
@@ -118,7 +144,23 @@ CinemaDialog::emails () const
}
int
-CinemaDialog::utc_offset () const
+CinemaDialog::utc_offset_hour () const
{
- return _utc_offset->GetSelection() - 11;
+ size_t const sel = _utc_offset->GetSelection();
+ if (sel < 0 || sel > _offsets.size()) {
+ return 0;
+ }
+
+ return _offsets[sel].hour;
+}
+
+int
+CinemaDialog::utc_offset_minute () const
+{
+ size_t const sel = _utc_offset->GetSelection();
+ if (sel < 0 || sel > _offsets.size()) {
+ return 0;
+ }
+
+ return _offsets[sel].minute;
}
diff --git a/src/wx/cinema_dialog.h b/src/wx/cinema_dialog.h
index a34935e51..2949d6c8c 100644
--- a/src/wx/cinema_dialog.h
+++ b/src/wx/cinema_dialog.h
@@ -27,11 +27,19 @@
class CinemaDialog : public wxDialog
{
public:
- CinemaDialog (wxWindow *, std::string, std::string name = "", std::list<std::string> emails = std::list<std::string> (), int utc_offset = 0);
+ CinemaDialog (
+ wxWindow *,
+ std::string,
+ std::string name = "",
+ std::list<std::string> emails = std::list<std::string> (),
+ int utc_offset_hour = 0,
+ int utc_offset_minute = 0
+ );
std::string name () const;
std::list<std::string> emails () const;
- int utc_offset () const;
+ int utc_offset_hour () const;
+ int utc_offset_minute () const;
private:
std::vector<std::string> get_emails () const;
@@ -41,4 +49,19 @@ private:
EditableList<std::string, EmailDialog>* _email_list;
std::vector<std::string> _emails;
wxChoice* _utc_offset;
+
+ struct Offset
+ {
+ Offset (wxString n, int h, int m)
+ : name (n)
+ , hour (h)
+ , minute (m)
+ {}
+
+ wxString name;
+ int hour;
+ int minute;
+ };
+
+ std::vector<Offset> _offsets;
};
diff --git a/src/wx/screens_panel.cc b/src/wx/screens_panel.cc
index a75316d8c..ddb088c2f 100644
--- a/src/wx/screens_panel.cc
+++ b/src/wx/screens_panel.cc
@@ -149,7 +149,7 @@ ScreensPanel::add_cinema_clicked ()
{
CinemaDialog* d = new CinemaDialog (this, "Add Cinema");
if (d->ShowModal () == wxID_OK) {
- shared_ptr<Cinema> c (new Cinema (d->name(), d->emails(), d->utc_offset()));
+ shared_ptr<Cinema> c (new Cinema (d->name(), d->emails(), d->utc_offset_hour(), d->utc_offset_minute()));
Config::instance()->add_cinema (c);
add_cinema (c);
}
@@ -166,11 +166,12 @@ ScreensPanel::edit_cinema_clicked ()
pair<wxTreeItemId, shared_ptr<Cinema> > c = *_selected_cinemas.begin();
- CinemaDialog* d = new CinemaDialog (this, "Edit cinema", c.second->name, c.second->emails, c.second->utc_offset());
+ CinemaDialog* d = new CinemaDialog (this, "Edit cinema", c.second->name, c.second->emails, c.second->utc_offset_hour(), c.second->utc_offset_minute());
if (d->ShowModal () == wxID_OK) {
c.second->name = d->name ();
c.second->emails = d->emails ();
- c.second->set_utc_offset (d->utc_offset ());
+ c.second->set_utc_offset_hour (d->utc_offset_hour ());
+ c.second->set_utc_offset_minute (d->utc_offset_minute ());
_targets->SetItemText (c.first, std_to_wx (d->name()));
Config::instance()->changed ();
}