Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef DVDIALOG_INCLUDED
Toshihiro Shimizu 890ddd
#define DVDIALOG_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include "tmsgcore.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qdialog></qdialog>
Toshihiro Shimizu 890ddd
#include <qvboxlayout></qvboxlayout>
Toshihiro Shimizu 890ddd
#include <qstring></qstring>
Toshihiro Shimizu 890ddd
#include <qprogressbar></qprogressbar>
Toshihiro Shimizu 890ddd
#include <qframe></qframe>
Toshihiro Shimizu 890ddd
#include <qsettings></qsettings>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TOONZQT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// forward declaration
Toshihiro Shimizu 890ddd
class QAbstractButton;
Toshihiro Shimizu 890ddd
class QHBoxLayout;
Toshihiro Shimizu 890ddd
class QVBoxLayout;
Toshihiro Shimizu 890ddd
class QLayout;
Toshihiro Shimizu 890ddd
class QLabel;
Toshihiro Shimizu 890ddd
class TXsheetHandle;
Toshihiro Shimizu 890ddd
class TPalette;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
#pragma warning(disable : 4251)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
namespace DVGui
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
const int WidgetHeight = 20;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class Dialog;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI setDialogTitle(const QString &dialogTitle);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI MsgBoxInPopup(MsgType type, const QString &text);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// ATTENZIONE: Valore di ritorno
Toshihiro Shimizu 890ddd
// 0 = l'utente ha chiuso la finestra (dovrebbe corrispondere ad un cancel o ad un NO)
Toshihiro Shimizu 890ddd
// 1 = primo bottone da sx premuto
Toshihiro Shimizu 890ddd
// 2 = secondo bottone da sx premuto
Toshihiro Shimizu 890ddd
// 3 = terzo bottone da sx premuto
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int DVAPI MsgBox(MsgType type,
Toshihiro Shimizu 890ddd
				 const QString &text,
Toshihiro Shimizu 890ddd
				 const std::vector<qstring> &buttons,</qstring>
Toshihiro Shimizu 890ddd
				 int defaultButtonIndex = 0,
Toshihiro Shimizu 890ddd
				 QWidget *parent = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// QUESTION: due bottoni user defined
Toshihiro Shimizu 890ddd
int DVAPI MsgBox(const QString &text,
Toshihiro Shimizu 890ddd
				 const QString &button1,
Toshihiro Shimizu 890ddd
				 const QString &button2,
Toshihiro Shimizu 890ddd
				 int defaultButtonIndex = 0,
Toshihiro Shimizu 890ddd
				 QWidget *parent = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// QUESTION: tre bottoni user defined
Toshihiro Shimizu 890ddd
int DVAPI MsgBox(const QString &text,
Toshihiro Shimizu 890ddd
				 const QString &button1,
Toshihiro Shimizu 890ddd
				 const QString &button2,
Toshihiro Shimizu 890ddd
				 const QString &button3,
Toshihiro Shimizu 890ddd
				 int defaultButtonIndex = 0,
Toshihiro Shimizu 890ddd
				 QWidget *parent = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Dialog DVAPI *createMsgBox(MsgType type,
Toshihiro Shimizu 890ddd
						   const QString &text,
Toshihiro Shimizu 890ddd
						   const QStringList &buttons,
Toshihiro Shimizu 890ddd
						   int defaultButtonIndex,
Toshihiro Shimizu 890ddd
						   QWidget *parent = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//void DVAPI error(const QString &msg);
Toshihiro Shimizu 890ddd
//void DVAPI info(const QString &msg);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QString DVAPI getText(const QString &title, const QString &label,
Toshihiro Shimizu 890ddd
					  const QString &text = QString(), bool *ok = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
/*! \brief The Separator class provides a separator.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		Inherits \b QWidget.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		The separator can be text and line or only line. If QString \b name, passed to
Toshihiro Shimizu 890ddd
		constructor, is not empty, separator is composed by text \b name and line;
Toshihiro Shimizu 890ddd
		else separator is a line, this line width is DV dialog width, clearly taking care
Toshihiro Shimizu 890ddd
		DV dialog margin.
Toshihiro Shimizu 890ddd
		The separator can be horizontal (by default) or vertical, isVertical(), you can
Toshihiro Shimizu 890ddd
		set it using function \b setOrientation().
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		To add a separator to DV dialog \b Dialog you must create a new Separator
Toshihiro Shimizu 890ddd
		and recall \b Dialog::addWidget(), or recall \b Dialog::addSeparator().
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		\b Example: in a DV dialog \b Dialog 
Toshihiro Shimizu 890ddd
		\code
Toshihiro Shimizu 890ddd
			Separator* exampleNameAndLine = new Separator(QString("Example Name"));
Toshihiro Shimizu 890ddd
			addWidget(exampleNameAndLine);
Toshihiro Shimizu 890ddd
			Separator* exampleLine = new Separator("");
Toshihiro Shimizu 890ddd
			addWidget(exampleLine);
Toshihiro Shimizu 890ddd
		\endcode
Toshihiro Shimizu 890ddd
		or:
Toshihiro Shimizu 890ddd
		\code
Toshihiro Shimizu 890ddd
			addSeparator(QString("Example Name"));
Toshihiro Shimizu 890ddd
			addSeparator();
Toshihiro Shimizu 890ddd
		\endcode
Toshihiro Shimizu 890ddd
		\b Result
Toshihiro Shimizu 890ddd
			\image html DialogSeparator.jpg
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
class DVAPI Separator : public QFrame
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QString m_name;
Toshihiro Shimizu 890ddd
	bool m_isHorizontal;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	Separator(QString name = "", QWidget *parent = 0);
Toshihiro Shimizu 890ddd
	~Separator();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!	Set dialog saparator \b name to name, if name is empty dialog separator
Toshihiro Shimizu 890ddd
			is a line. */
Toshihiro Shimizu 890ddd
	void setName(const QString &name) { m_name = name; }
Toshihiro Shimizu 890ddd
	QString getName() { return m_name; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!	Set dialog saparator orientation to horizontal if \b isHorizontal is true,
Toshihiro Shimizu 890ddd
			otherwise to vertical. */
Toshihiro Shimizu 890ddd
	void setOrientation(bool isHorizontal) { m_isHorizontal = isHorizontal; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!	Return true if saparator orientation is horizontal, false otherwise. */
Toshihiro Shimizu 890ddd
	bool isHorizontal() { return m_isHorizontal; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	void paintEvent(QPaintEvent *event);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI Dialog : public QDialog
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
	static QSettings *m_settings;
Toshihiro Shimizu 890ddd
	// If the dialog has button then is modal too.
Toshihiro Shimizu 890ddd
	bool m_hasButton;
Toshihiro Shimizu 890ddd
	QString m_name;
Toshihiro Shimizu 890ddd
	// gmt. rendo m_buttonLayout protected per ovviare ad un problema
Toshihiro Shimizu 890ddd
	// sull'addButtonBarWidget(). cfr filebrowserpopup.cpp.
Toshihiro Shimizu 890ddd
	// Dobbiamo discutere di Dialog.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	QHBoxLayout *m_buttonLayout;
Toshihiro Shimizu 890ddd
	QList<qlabel *=""> m_labelList;</qlabel>
Toshihiro Shimizu 890ddd
	void resizeEvent(QResizeEvent *e);
Toshihiro Shimizu 890ddd
	void moveEvent(QMoveEvent *e);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	QVBoxLayout *m_topLayout;
Toshihiro Shimizu 890ddd
	QFrame *m_mainFrame, *m_buttonFrame;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QHBoxLayout *m_mainHLayout;
Toshihiro Shimizu 890ddd
	bool m_isMainHLayout;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QVBoxLayout *m_leftVLayout, *m_rightVLayout;
Toshihiro Shimizu 890ddd
	bool m_isMainVLayout;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int m_layoutSpacing;
Toshihiro Shimizu 890ddd
	int m_layoutMargin;
Toshihiro Shimizu 890ddd
	int m_labelWidth;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::vector<qwidget *=""> m_buttonBarWidgets;</qwidget>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	//if 'name' is not empty, the dialog will remember its geometry between Toonz sessions
Toshihiro Shimizu 890ddd
	Dialog(QWidget *parent = 0, bool hasButton = false, bool hasFixedSize = true, const QString &name = QString());
Toshihiro Shimizu 890ddd
	~Dialog();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void beginVLayout();
Toshihiro Shimizu 890ddd
	void endVLayout();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void beginHLayout();
Toshihiro Shimizu 890ddd
	void endHLayout();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void addWidget(QWidget *widget, bool isRight = true);
Toshihiro Shimizu 890ddd
	void addWidgets(QWidget *firstW, QWidget *secondW);
Toshihiro Shimizu 890ddd
	void addWidget(QString labelName, QWidget *widget);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void addLayout(QLayout *layout, bool isRight = true);
Toshihiro Shimizu 890ddd
	void addWidgetLayout(QWidget *widget, QLayout *layout);
Toshihiro Shimizu 890ddd
	void addLayout(QString labelName, QLayout *layout);
Toshihiro Shimizu 890ddd
	void addLayouts(QLayout *firstL, QLayout *secondL);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void addSpacing(int spacing);
Toshihiro Shimizu 890ddd
	void addSeparator(QString name = QString());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setAlignment(Qt::Alignment alignment);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setTopMargin(int margin);
Toshihiro Shimizu 890ddd
	void setTopSpacing(int spacing);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setLabelWidth(int labelWidth);
Toshihiro Shimizu 890ddd
	int getLabelWidth() const { return m_labelWidth; };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setLayoutInsertedSpacing(int spacing);
Toshihiro Shimizu 890ddd
	int getLayoutInsertedSpacing();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setButtonBarMargin(int margin);
Toshihiro Shimizu 890ddd
	void setButtonBarSpacing(int spacing);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void addButtonBarWidget(QWidget *widget);
Toshihiro Shimizu 890ddd
	void addButtonBarWidget(QWidget *first, QWidget *second);
Toshihiro Shimizu 890ddd
	void addButtonBarWidget(QWidget *first, QWidget *second, QWidget *third);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual void hideEvent(QHideEvent *event);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void clearButtonBar();
Toshihiro Shimizu 890ddd
signals:
Toshihiro Shimizu 890ddd
	void dialogClosed();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*! Is a modal dialog with exclusive list of radio button.
Toshihiro Shimizu 890ddd
    Exec value depend to checked button.
Toshihiro Shimizu 890ddd
    0 -> Cancel or Close Popup,
Toshihiro Shimizu 890ddd
    1,2,3,... -> checkbox clicked.
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka eabf18
class DVAPI RadioButtonDialog : public DVGui::Dialog
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int m_result;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	RadioButtonDialog(const QString &labelText, const QList<qstring> &radioButtonList,</qstring>
Toshihiro Shimizu 890ddd
					  QWidget *parent = 0, Qt::WindowFlags f = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public Q_SLOTS:
Toshihiro Shimizu 890ddd
	void onButtonClicked(int id);
Toshihiro Shimizu 890ddd
	void onCancel();
Toshihiro Shimizu 890ddd
	void onApply();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int DVAPI RadioButtonMsgBox(MsgType type, const QString &labelText,
Toshihiro Shimizu 890ddd
							const QList<qstring> &buttons, QWidget *parent = 0);</qstring>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka eabf18
class DVAPI ProgressDialog : public DVGui::Dialog
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QLabel *m_label;
Toshihiro Shimizu 890ddd
	QProgressBar *m_progressBar;
Toshihiro Shimizu 890ddd
	QPushButton *m_cancelButton;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	bool m_isCanceled;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	ProgressDialog(const QString &labelText, const QString &cancelButtonText,
Toshihiro Shimizu 890ddd
				   int minimum, int maximum, QWidget *parent = 0, Qt::WindowFlags f = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setLabelText(const QString &text);
Toshihiro Shimizu 890ddd
	void setCancelButton(QPushButton *cancelButton);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int maximum();
Toshihiro Shimizu 890ddd
	void setMaximum(int maximum);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int minimum();
Toshihiro Shimizu 890ddd
	void setMinimum(int minimum);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void reset();
Toshihiro Shimizu 890ddd
	int value();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool wasCanceled() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public Q_SLOTS:
Toshihiro Shimizu 890ddd
	void setValue(int progress);
Toshihiro Shimizu 890ddd
	virtual void onCancel();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	Q_SIGNALS : void canceled();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*! Return 2 if erase style,
Toshihiro Shimizu 890ddd
					 1 if don't erase style,
Toshihiro Shimizu 890ddd
					 0 if press cancel or close popup.
Toshihiro Shimizu 890ddd
	  If newPalette != 0 verify if styles to erase are in new palette before send question.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
int eraseStylesInDemand(TPalette *palette, const TXsheetHandle *xsheetHandle, TPalette *newPalette = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int eraseStylesInDemand(TPalette *palette, std::vector<int> styleIds, const TXsheetHandle *xsheetHandle);</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI featureNotAvelaible(QString applicationName = QString("Toonz Bravo Web"), QString url = QString("http://www.bravo.toonz.com"));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI requestTrialLicense(QString url = QString("http://www.toonz.com"), QString mail = QString("license@toonz.com"));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
} //namespace DVGui
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif // DVDIALOG_INCLUDED