4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "Profile/PageProfile.hpp"
25 #include "Profile/Profile.hpp"
26 #include "PageSettings.hpp"
27 #include "InfoBoxes/InfoBoxSettings.hpp"
30 * Old enum moved from PageSettings.
39 Load(PageLayout
&_pl
, const unsigned page
)
42 unsigned prefixLen
= sprintf(profileKey
, "Page%u", page
);
46 PageLayout pl
= PageLayout::Default();
47 strcpy(profileKey
+ prefixLen
, "InfoBoxMode");
48 if (!Profile::Get(profileKey
, pl
.infobox_config
.auto_switch
))
50 strcpy(profileKey
+ prefixLen
, "InfoBoxPanel");
51 if (!Profile::Get(profileKey
, pl
.infobox_config
.panel
))
54 strcpy(profileKey
+ prefixLen
, "Layout");
56 Profile::Get(profileKey
, temp
);
63 pl
.infobox_config
.enabled
= false;
67 if (pl
.infobox_config
.panel
>= InfoBoxSettings::MAX_PANELS
)
69 if (page
== 0 && !pl
.IsDefined())
72 strcpy(profileKey
+ prefixLen
, "Bottom");
73 if (!Profile::GetEnum(profileKey
, pl
.bottom
) ||
74 unsigned(pl
.bottom
) >= unsigned(PageLayout::Bottom::MAX
))
75 pl
.bottom
= PageLayout::Bottom::NOTHING
;
77 strcpy(profileKey
+ prefixLen
, "Main");
78 if (!Profile::GetEnum(profileKey
, pl
.main
) ||
79 unsigned(pl
.main
) >= unsigned(PageLayout::Main::MAX
))
80 pl
.main
= PageLayout::Main::MAP
;
86 Profile::Load(PageSettings
&settings
)
88 for (unsigned i
= 0; i
< PageSettings::MAX_PAGES
; ++i
)
89 ::Load(settings
.pages
[i
], i
);
93 Get(ProfileKeys::PagesDistinctZoom
, settings
.distinct_zoom
);
97 Profile::Save(const PageLayout
&page
, const unsigned i
)
100 unsigned prefixLen
= sprintf(profileKey
, "Page%u", i
);
103 strcpy(profileKey
+ prefixLen
, "InfoBoxMode");
104 Profile::Set(profileKey
, page
.infobox_config
.auto_switch
);
105 strcpy(profileKey
+ prefixLen
, "InfoBoxPanel");
106 Profile::Set(profileKey
, page
.infobox_config
.panel
);
108 strcpy(profileKey
+ prefixLen
, "Layout");
109 Profile::Set(profileKey
,
111 ? (page
.infobox_config
.enabled
116 strcpy(profileKey
+ prefixLen
, "Bottom");
117 Profile::Set(profileKey
, (unsigned)page
.bottom
);
119 strcpy(profileKey
+ prefixLen
, "Main");
120 Profile::Set(profileKey
, (unsigned)page
.main
);
125 Profile::Save(const PageSettings
&settings
)
127 for (unsigned i
= 0; i
< PageSettings::MAX_PAGES
; ++i
)
128 Save(settings
.pages
[i
], i
);