aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc162
1 files changed, 96 insertions, 66 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index daa87dc..0677a14 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -183,7 +183,7 @@ int calcSquareDistance(int x1, int y1, int x2, int y2) {
183 183
184class TabPlacementMenuItem: public FbTk::RadioMenuItem { 184class TabPlacementMenuItem: public FbTk::RadioMenuItem {
185public: 185public:
186 TabPlacementMenuItem(const FbTk::FbString & label, BScreen &screen, 186 TabPlacementMenuItem(FbTk::FbString & label, BScreen &screen,
187 FbWinFrame::TabPlacement place, 187 FbWinFrame::TabPlacement place,
188 FbTk::RefCount<FbTk::Command<void> > &cmd): 188 FbTk::RefCount<FbTk::Command<void> > &cmd):
189 FbTk::RadioMenuItem(label, cmd), 189 FbTk::RadioMenuItem(label, cmd),
@@ -208,28 +208,6 @@ void clampMenuDelay(int& delay) {
208 delay = FbTk::Util::clamp(delay, 0, 5000); 208 delay = FbTk::Util::clamp(delay, 0, 5000);
209} 209}
210 210
211
212struct TabPlacementString {
213 FbWinFrame::TabPlacement placement;
214 const char* str;
215};
216
217const TabPlacementString placement_strings[] = {
218 { FbWinFrame::TOPLEFT, "TopLeft" },
219 { FbWinFrame::TOP, "Top" },
220 { FbWinFrame::TOPRIGHT, "TopRight" },
221 { FbWinFrame::BOTTOMLEFT, "BottomLeft" },
222 { FbWinFrame::BOTTOM, "Bottom" },
223 { FbWinFrame::BOTTOMRIGHT, "BottomRight" },
224 { FbWinFrame::LEFTBOTTOM, "LeftBottom" },
225 { FbWinFrame::LEFT, "Left" },
226 { FbWinFrame::LEFTTOP, "LeftTop" },
227 { FbWinFrame::RIGHTBOTTOM, "RightBottom" },
228 { FbWinFrame::RIGHT, "Right" },
229 { FbWinFrame::RIGHTTOP, "RightTop" }
230};
231
232
233} // end anonymous namespace 211} // end anonymous namespace
234 212
235 213
@@ -239,25 +217,77 @@ namespace FbTk {
239template<> 217template<>
240string FbTk::Resource<FbWinFrame::TabPlacement>:: 218string FbTk::Resource<FbWinFrame::TabPlacement>::
241getString() const { 219getString() const {
242 220 switch (m_value) {
243 size_t i = (m_value == FbTk::Util::clamp(m_value, FbWinFrame::TOPLEFT, FbWinFrame::RIGHTTOP) 221 case FbWinFrame::TOPLEFT:
244 ? m_value 222 return string("TopLeft");
245 : FbWinFrame::DEFAULT) - 1; 223 break;
246 return placement_strings[i].str; 224 case FbWinFrame::BOTTOMLEFT:
225 return string("BottomLeft");
226 break;
227 case FbWinFrame::TOP:
228 return string("Top");
229 break;
230 case FbWinFrame::BOTTOM:
231 return string("Bottom");
232 break;
233 case FbWinFrame::TOPRIGHT:
234 return string("TopRight");
235 break;
236 case FbWinFrame::BOTTOMRIGHT:
237 return string("BottomRight");
238 break;
239 case FbWinFrame::LEFTTOP:
240 return string("LeftTop");
241 break;
242 case FbWinFrame::LEFT:
243 return string("Left");
244 break;
245 case FbWinFrame::LEFTBOTTOM:
246 return string("LeftBottom");
247 break;
248 case FbWinFrame::RIGHTTOP:
249 return string("RightTop");
250 break;
251 case FbWinFrame::RIGHT:
252 return string("Right");
253 break;
254 case FbWinFrame::RIGHTBOTTOM:
255 return string("RightBottom");
256 break;
257 }
258 //default string
259 return string("TopLeft");
247} 260}
248 261
249template<> 262template<>
250void FbTk::Resource<FbWinFrame::TabPlacement>:: 263void FbTk::Resource<FbWinFrame::TabPlacement>::
251setFromString(const char *strval) { 264setFromString(const char *strval) {
252 265 if (strcasecmp(strval, "TopLeft") == 0)
253 size_t i; 266 m_value = FbWinFrame::TOPLEFT;
254 for (i = 0; i < sizeof(placement_strings)/sizeof(TabPlacementString); ++i) { 267 else if (strcasecmp(strval, "BottomLeft") == 0)
255 if (strcasecmp(strval, placement_strings[i].str) == 0) { 268 m_value = FbWinFrame::BOTTOMLEFT;
256 m_value = placement_strings[i].placement; 269 else if (strcasecmp(strval, "Top") == 0)
257 return; 270 m_value = FbWinFrame::TOP;
258 } 271 else if (strcasecmp(strval, "Bottom") == 0)
259 } 272 m_value = FbWinFrame::BOTTOM;
260 setDefaultValue(); 273 else if (strcasecmp(strval, "TopRight") == 0)
274 m_value = FbWinFrame::TOPRIGHT;
275 else if (strcasecmp(strval, "BottomRight") == 0)
276 m_value = FbWinFrame::BOTTOMRIGHT;
277 else if (strcasecmp(strval, "LeftTop") == 0)
278 m_value = FbWinFrame::LEFTTOP;
279 else if (strcasecmp(strval, "Left") == 0)
280 m_value = FbWinFrame::LEFT;
281 else if (strcasecmp(strval, "LeftBottom") == 0)
282 m_value = FbWinFrame::LEFTBOTTOM;
283 else if (strcasecmp(strval, "RightTop") == 0)
284 m_value = FbWinFrame::RIGHTTOP;
285 else if (strcasecmp(strval, "Right") == 0)
286 m_value = FbWinFrame::RIGHT;
287 else if (strcasecmp(strval, "RightBottom") == 0)
288 m_value = FbWinFrame::RIGHTBOTTOM;
289 else
290 setDefaultValue();
261} 291}
262 292
263} // end namespace FbTk 293} // end namespace FbTk
@@ -1619,41 +1649,41 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1619 tab_width_item->setCommand(save_and_reconftabs); 1649 tab_width_item->setCommand(save_and_reconftabs);
1620 tab_menu->insert(tab_width_item); 1650 tab_menu->insert(tab_width_item);
1621 1651
1652
1653 typedef pair<FbTk::FbString, FbWinFrame::TabPlacement> PlacementP;
1654 typedef list<PlacementP> Placements;
1655 Placements place_menu;
1656
1622 // menu is 3 wide, 5 down 1657 // menu is 3 wide, 5 down
1623 struct PlacementP { 1658 place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), FbWinFrame::TOPLEFT));
1624 const FbTk::FbString label; 1659 place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), FbWinFrame::LEFTTOP));
1625 FbWinFrame::TabPlacement placement; 1660 place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftCenter, "Left Center", "Left Center"), FbWinFrame::LEFT));
1626 }; 1661 place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), FbWinFrame::LEFTBOTTOM));
1627 static const PlacementP place_menu[] = { 1662 place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), FbWinFrame::BOTTOMLEFT));
1628 1663 place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopCenter, "Top Center", "Top Center"), FbWinFrame::TOP));
1629 { _FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), FbWinFrame::TOPLEFT}, 1664 place_menu.push_back(PlacementP("", FbWinFrame::TOPLEFT));
1630 { _FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), FbWinFrame::LEFTTOP}, 1665 place_menu.push_back(PlacementP("", FbWinFrame::TOPLEFT));
1631 { _FB_XTEXT(Align, LeftCenter, "Left Center", "Left Center"), FbWinFrame::LEFT}, 1666 place_menu.push_back(PlacementP("", FbWinFrame::TOPLEFT));
1632 { _FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), FbWinFrame::LEFTBOTTOM}, 1667 place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), FbWinFrame::BOTTOM));
1633 { _FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), FbWinFrame::BOTTOMLEFT}, 1668 place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), FbWinFrame::TOPRIGHT));
1634 { _FB_XTEXT(Align, TopCenter, "Top Center", "Top Center"), FbWinFrame::TOP}, 1669 place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), FbWinFrame::RIGHTTOP));
1635 { "", FbWinFrame::TOPLEFT}, 1670 place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightCenter, "Right Center", "Right Center"), FbWinFrame::RIGHT));
1636 { "", FbWinFrame::TOPLEFT}, 1671 place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), FbWinFrame::RIGHTBOTTOM));
1637 { "", FbWinFrame::TOPLEFT}, 1672 place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), FbWinFrame::BOTTOMRIGHT));
1638 { _FB_XTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), FbWinFrame::BOTTOM},
1639 { _FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), FbWinFrame::TOPRIGHT},
1640 { _FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), FbWinFrame::RIGHTTOP},
1641 { _FB_XTEXT(Align, RightCenter, "Right Center", "Right Center"), FbWinFrame::RIGHT},
1642 { _FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), FbWinFrame::RIGHTBOTTOM},
1643 { _FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), FbWinFrame::BOTTOMRIGHT}
1644 };
1645 1673
1646 tabplacement_menu->setMinimumSublevels(3); 1674 tabplacement_menu->setMinimumSublevels(3);
1647 // create items in sub menu 1675 // create items in sub menu
1648 for (size_t i=0; i< sizeof(place_menu)/sizeof(PlacementP); ++i) { 1676 for (size_t i=0; i<15; ++i) {
1649 const PlacementP& p = place_menu[i]; 1677 FbTk::FbString &str = place_menu.front().first;
1650 if (p.label == "") { 1678 FbWinFrame::TabPlacement placement = place_menu.front().second;
1651 tabplacement_menu->insert(p.label); 1679 if (str == "") {
1680 tabplacement_menu->insert("");
1652 tabplacement_menu->setItemEnabled(i, false); 1681 tabplacement_menu->setItemEnabled(i, false);
1653 } else 1682 } else {
1654 tabplacement_menu->insert(new TabPlacementMenuItem(p.label, *this, p.placement, save_and_reconftabs)); 1683 tabplacement_menu->insert(new TabPlacementMenuItem(str, *this, placement, save_and_reconftabs));
1684 }
1685 place_menu.pop_front();
1655 } 1686 }
1656
1657 tabplacement_menu->updateMenu(); 1687 tabplacement_menu->updateMenu();
1658 1688
1659 menu.insert(tabmenu_label, tab_menu); 1689 menu.insert(tabmenu_label, tab_menu);