1 /***************************************************************************
2 * Copyright (C) 2008-2010 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
28 using Global::MainHeight
;
29 using Global::MainStartY
;
30 using Global::myScreen
;
32 Outputs
*myOutputs
= new Outputs
;
36 w
= new Menu
<MPD::Output
>(0, MainStartY
, COLS
, MainHeight
, "", Config
.main_color
, brNone
);
37 w
->CyclicScrolling(Config
.use_cyclic_scrolling
);
38 w
->CenteredCursor(Config
.centered_cursor
);
39 w
->HighlightColor(Config
.main_highlight_color
);
40 w
->SetItemDisplayer(Display::Pairs
);
46 void Outputs::SwitchTo()
57 if (myScreen
!= this && myScreen
->isTabbable())
58 Global::myPrevScreen
= myScreen
;
62 Global::RedrawHeader
= 1;
65 void Outputs::Resize()
67 w
->Resize(COLS
, MainHeight
);
68 w
->MoveTo(0, MainStartY
);
72 std::basic_string
<my_char_t
> Outputs::Title()
77 void Outputs::EnterPressed()
79 if (w
->Current().second
)
81 if (Mpd
.DisableOutput(w
->Choice()))
82 ShowMessage("Output \"%s\" disabled", w
->Current().first
.c_str());
86 if (Mpd
.EnableOutput(w
->Choice()))
87 ShowMessage("Output \"%s\" enabled", w
->Current().first
.c_str());
91 void Outputs::MouseButtonPressed(MEVENT me
)
93 if (w
->Empty() || !w
->hasCoords(me
.x
, me
.y
) || size_t(me
.y
) >= w
->Size())
95 if (me
.bstate
& BUTTON1_PRESSED
|| me
.bstate
& BUTTON3_PRESSED
)
98 if (me
.bstate
& BUTTON3_PRESSED
)
102 Screen
< Menu
<MPD::Output
> >::MouseButtonPressed(me
);
105 void Outputs::FetchList()
112 for (MPD::OutputList::const_iterator it
= ol
.begin(); it
!= ol
.end(); ++it
)
113 w
->AddOption(*it
, it
->second
);
114 if (myScreen
== this)
118 #endif // ENABLE_OUTPUTS