/***************************************************************************
                           qcubelabel.cpp
                           -------------------
    copyright            : (C) 2004 by Jos van den Oever
    email                : jos@vandenoever.info
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#include "qcubelabel.h"
#include "questiongenerator.h"

QCubeLabel::QCubeLabel(QWidget* parent, const char* name, Qt::WFlags f)
	: Q3VBox(parent, name, f) {
	for (short i=0; i<6; i++) {
		picture[i] = NULL;
	}
	row1 = new Q3HBox(this);
	row1->setBackgroundOrigin(QWidget::WindowOrigin);
	row2 = new Q3HBox(this);
	row2->setBackgroundOrigin(QWidget::WindowOrigin);
	for (short i=0; i<3; i++) {
		picture[2*i] = new QPictureLabel(row1);
		picture[2*i+1] = new QPictureLabel(row2);
	}
	for (short i=0; i<6; i++) {
		picture[i]->setBackgroundOrigin(QWidget::WindowOrigin);
	}
}
void
QCubeLabel::setCube(const Cube &c) {
	short map[6];
	// make a random map to shuffle the sides
	QuestionGenerator::makemap(map, 6, 0, 6);
	for (short i=0; i<6; i++) {
		picture[map[i]]->setPicture(*c.getSide(i).picture());
	}
}
void
QCubeLabel::setVisibleSides(short vs) {
	for (short i=0; i<vs && i<6; i++) {
		picture[i]->show();
	}
	for (short i=(vs<0)?0:vs; i<6; i++) {
		picture[i]->hide();
	}
}
