/*
- Copyright 2007 Chris Tallon
+ Copyright 2007-2020 Chris Tallon
This file is part of VOMP.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
-#include "woptionpane.h"
#include "wtextbox.h"
#include "i18n.h"
#include "woptionbox.h"
#include "vdr.h"
#include "input.h"
#include "option.h"
+#include "woptionpane.h"
WOptionPane::WOptionPane()
{
{
int fontHeight = getFontHeight();
-
- options.resize(numOptions+1);
+ options.resize(numOptions + 1);
options[numOptions] = option;
WTextbox* tb = new WTextbox();
tb->setTextPos(0, 0);
add(tb);
- textBoxes.resize(numOptions+1);
+ textBoxes.resize(numOptions + 1);
textBoxes[numOptions] = tb;
WOptionBox* ob = new WOptionBox();
ob->setSize(190, fontHeight);
add(ob);
- optionBoxes.resize(numOptions+1);
+ optionBoxes.resize(numOptions + 1);
optionBoxes[numOptions] = ob;
if (option->optionType == Option::TYPE_TEXT ||
}
numOptions++;
-
}
void WOptionPane::deactivateAllControls()
{
- if (selectedOption >= 0) {
- optionBoxes[selectedOption]->setActive(0);
- selectedOption = -1;
- }
+ if (selectedOption >= 0)
+ {
+ optionBoxes[selectedOption]->setActive(0);
+ selectedOption = -1;
+ }
}
-
int WOptionPane::handleCommand(int command)
{
switch(command)
optionBoxes[selectedOption]->setActive(1);
return 1;
}
+ FALLTHROUGH // it doesn't really
}
case Input::DOWN:
{
selectedOption = -1;
return 4; // Signal return control to parent
}
+ FALLTHROUGH // it doesn't really
}
case Input::LEFT:
{
bool WOptionPane::mouseMove(int x, int y)
{
- UINT i;
- for (i=0;i<optionBoxes.size();i++) {
- if (optionBoxes[i]->mouseMove(x,y)) {
- if ( selectedOption!=(int)i) {
- if (selectedOption != -1 ) optionBoxes[selectedOption]->setActive(0);
- selectedOption=i;
- return true;
- } else {
- return false;
- }
- }
+ for (int i = 0; i < static_cast<int>(optionBoxes.size()); i++)
+ {
+ if (optionBoxes[i]->mouseMove(x, y))
+ {
+ if (selectedOption != i)
+ {
+ if (selectedOption != -1) optionBoxes[selectedOption]->setActive(0);
+ selectedOption = i;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
-
- return false;
+ }
+ return false;
}
bool WOptionPane::mouseLBDOWN(int x, int y)
{
- UINT i;
- for (i=0;i<optionBoxes.size();i++) {
- if (optionBoxes[i]->mouseLBDOWN(x,y)) {
- if ( selectedOption==(int)i) {
- optionBoxes[selectedOption]->cycle();
- return true;
- } else {
- return false;
- }
- }
+ for (int i = 0; i < static_cast<int>(optionBoxes.size()); i++)
+ {
+ if (optionBoxes[i]->mouseLBDOWN(x, y))
+ {
+ if (selectedOption == i)
+ {
+ optionBoxes[selectedOption]->cycle();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
- return false;
+ }
+ return false;
}
-
-
-
-