1 /***************************************************************************
2 * Copyright (C) 2008-2012 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 ***************************************************************************/
29 #include "statusbar.h"
32 using Global::MainHeight
;
33 using Global::MainStartY
;
34 using Global::myScreen
;
36 Outputs
*myOutputs
= new Outputs
;
40 w
= new NC::Menu
<MPD::Output
>(0, MainStartY
, COLS
, MainHeight
, "", Config
.main_color
, NC::brNone
);
41 w
->cyclicScrolling(Config
.use_cyclic_scrolling
);
42 w
->centeredCursor(Config
.centered_cursor
);
43 w
->setHighlightColor(Config
.main_highlight_color
);
44 w
->setItemDisplayer(Display::Outputs
);
50 void Outputs::SwitchTo()
52 using Global::myLockedScreen
;
61 UpdateInactiveScreen(this);
63 if (hasToBeResized
|| myLockedScreen
)
66 if (myScreen
!= this && myScreen
->isTabbable())
67 Global::myPrevScreen
= myScreen
;
73 void Outputs::Resize()
75 size_t x_offset
, width
;
76 GetWindowResizeParams(x_offset
, width
);
77 w
->resize(width
, MainHeight
);
78 w
->moveTo(x_offset
, MainStartY
);
82 std::wstring
Outputs::Title()
87 void Outputs::EnterPressed()
89 if (w
->current().value().isEnabled())
91 if (Mpd
.DisableOutput(w
->choice()))
92 Statusbar::msg("Output \"%s\" disabled", w
->current().value().name().c_str());
96 if (Mpd
.EnableOutput(w
->choice()))
97 Statusbar::msg("Output \"%s\" enabled", w
->current().value().name().c_str());
99 if (!Mpd
.SupportsIdle())
103 void Outputs::MouseButtonPressed(MEVENT me
)
105 if (w
->empty() || !w
->hasCoords(me
.x
, me
.y
) || size_t(me
.y
) >= w
->size())
107 if (me
.bstate
& BUTTON1_PRESSED
|| me
.bstate
& BUTTON3_PRESSED
)
110 if (me
.bstate
& BUTTON3_PRESSED
)
114 Screen
< NC::Menu
<MPD::Output
> >::MouseButtonPressed(me
);
117 void Outputs::FetchList()
122 auto outputs
= Mpd
.GetOutputs();
123 for (auto o
= outputs
.begin(); o
!= outputs
.end(); ++o
)
124 w
->addItem(*o
, o
->isEnabled());
125 if (myScreen
== this)
129 #endif // ENABLE_OUTPUTS