Shinya Kitaoka 810553
#pragma once
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
//=============================================================================
Shinya Kitaoka 120a6e
namespace DVGui {
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
Shinya Kitaoka 120a6e
// 0 = l'utente ha chiuso la finestra (dovrebbe corrispondere ad un cancel o ad
Jeremy Bullock 33e7d1
// un NO) - closed window
Jeremy Bullock 33e7d1
// 1 = primo bottone da sx premuto - first button selected
Jeremy Bullock 33e7d1
// 2 = secondo bottone da sx premuto - second button
Jeremy Bullock 33e7d1
// 3 = terzo bottone da sx premuto - third button
Jeremy Bullock 33e7d1
// 4 = fourth button
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int DVAPI MsgBox(MsgType type, const QString &text,
Shinya Kitaoka 120a6e
                 const std::vector<qstring> &buttons,</qstring>
Shinya Kitaoka 120a6e
                 int defaultButtonIndex = 0, QWidget *parent = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// QUESTION: due bottoni user defined
Shinya Kitaoka 120a6e
int DVAPI MsgBox(const QString &text, const QString &button1,
Shinya Kitaoka 120a6e
                 const QString &button2, int defaultButtonIndex = 0,
Shinya Kitaoka 120a6e
                 QWidget *parent = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// QUESTION: tre bottoni user defined
Shinya Kitaoka 120a6e
int DVAPI MsgBox(const QString &text, const QString &button1,
Shinya Kitaoka 120a6e
                 const QString &button2, const QString &button3,
Shinya Kitaoka 120a6e
                 int defaultButtonIndex = 0, QWidget *parent = 0);
Shinya Kitaoka 120a6e
Jeremy Bullock 33e7d1
// QUESTION: four botton user defined
Jeremy Bullock 33e7d1
int DVAPI MsgBox(const QString &text, const QString &button1,
Jeremy Bullock 33e7d1
                 const QString &button2, const QString &button3,
Jeremy Bullock 33e7d1
                 const QString &button4, int defaultButtonIndex = 0,
Jeremy Bullock 33e7d1
                 QWidget *parent = 0);
Jeremy Bullock 33e7d1
Shinya Kitaoka 120a6e
Dialog DVAPI *createMsgBox(MsgType type, const QString &text,
Shinya Kitaoka 120a6e
                           const QStringList &buttons, int defaultButtonIndex,
Shinya Kitaoka 120a6e
                           QWidget *parent = 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
// void DVAPI error(const QString &msg);
Shinya Kitaoka 120a6e
// 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,
Shinya Kitaoka 120a6e
                      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
Shinya Kitaoka 120a6e
                Inherits \b QWidget.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
                The separator can be text and line or only line. If QString \b
Shinya Kitaoka 120a6e
   name, passed to
Shinya Kitaoka 120a6e
                constructor, is not empty, separator is composed by text \b name
Shinya Kitaoka 120a6e
   and line;
Shinya Kitaoka 120a6e
                else separator is a line, this line width is DV dialog width,
Shinya Kitaoka 120a6e
   clearly taking care
Shinya Kitaoka 120a6e
                DV dialog margin.
Shinya Kitaoka 120a6e
                The separator can be horizontal (by default) or vertical,
Shinya Kitaoka 120a6e
   isVertical(), you can
Shinya Kitaoka 120a6e
                set it using function \b setOrientation().
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
                To add a separator to DV dialog \b Dialog you must create a new
Shinya Kitaoka 120a6e
   Separator
Shinya Kitaoka 120a6e
                and recall \b Dialog::addWidget(), or recall \b
Shinya Kitaoka 120a6e
   Dialog::addSeparator().
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
                \b Example: in a DV dialog \b Dialog
Shinya Kitaoka 120a6e
                \code
Shinya Kitaoka 120a6e
                        Separator* exampleNameAndLine = new
Shinya Kitaoka 120a6e
   Separator(QString("Example Name"));
Shinya Kitaoka 120a6e
                        addWidget(exampleNameAndLine);
Shinya Kitaoka 120a6e
                        Separator* exampleLine = new Separator("");
Shinya Kitaoka 120a6e
                        addWidget(exampleLine);
Shinya Kitaoka 120a6e
                \endcode
Shinya Kitaoka 120a6e
                or:
Shinya Kitaoka 120a6e
                \code
Shinya Kitaoka 120a6e
                        addSeparator(QString("Example Name"));
Shinya Kitaoka 120a6e
                        addSeparator();
Shinya Kitaoka 120a6e
                \endcode
Shinya Kitaoka 120a6e
                \b Result
Shinya Kitaoka 120a6e
                        \image html DialogSeparator.jpg
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka d1f6c4
class DVAPI Separator final : public QFrame {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QString m_name;
Shinya Kitaoka 120a6e
  bool m_isHorizontal;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Separator(QString name = "", QWidget *parent = 0);
Shinya Kitaoka 120a6e
  ~Separator();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!	Set dialog saparator \b name to name, if name is empty dialog separator
Shinya Kitaoka 120a6e
                  is a line. */
Shinya Kitaoka 120a6e
  void setName(const QString &name) { m_name = name; }
Shinya Kitaoka 120a6e
  QString getName() { return m_name; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!	Set dialog saparator orientation to horizontal if \b isHorizontal is
Shinya Kitaoka 120a6e
     true,
Shinya Kitaoka 120a6e
                  otherwise to vertical. */
Shinya Kitaoka 120a6e
  void setOrientation(bool isHorizontal) { m_isHorizontal = isHorizontal; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!	Return true if saparator orientation is horizontal, false otherwise. */
Shinya Kitaoka 120a6e
  bool isHorizontal() { return m_isHorizontal; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 473e70
  void paintEvent(QPaintEvent *event) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI Dialog : public QDialog {
Shinya Kitaoka 120a6e
  Q_OBJECT
Shinya Kitaoka 120a6e
  static QSettings *m_settings;
Shinya Kitaoka 120a6e
  // If the dialog has button then is modal too.
Shinya Kitaoka 120a6e
  bool m_hasButton;
Shinya Kitaoka 120a6e
  QString m_name;
Shinya Kitaoka 120a6e
  // gmt. rendo m_buttonLayout protected per ovviare ad un problema
Shinya Kitaoka 120a6e
  // sull'addButtonBarWidget(). cfr filebrowserpopup.cpp.
Shinya Kitaoka 120a6e
  // Dobbiamo discutere di Dialog.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  QHBoxLayout *m_buttonLayout;
Shinya Kitaoka 120a6e
  QList<qlabel *=""> m_labelList;</qlabel>
Shinya Kitaoka 473e70
  void resizeEvent(QResizeEvent *e) override;
Shinya Kitaoka 473e70
  void moveEvent(QMoveEvent *e) override;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  QVBoxLayout *m_topLayout;
Shinya Kitaoka 120a6e
  QFrame *m_mainFrame, *m_buttonFrame;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QHBoxLayout *m_mainHLayout;
Shinya Kitaoka 120a6e
  bool m_isMainHLayout;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QVBoxLayout *m_leftVLayout, *m_rightVLayout;
Shinya Kitaoka 120a6e
  bool m_isMainVLayout;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_layoutSpacing;
Shinya Kitaoka 120a6e
  int m_layoutMargin;
Shinya Kitaoka 120a6e
  int m_labelWidth;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::vector<qwidget *=""> m_buttonBarWidgets;</qwidget>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  // if 'name' is not empty, the dialog will remember its geometry between Toonz
Shinya Kitaoka 120a6e
  // sessions
Shinya Kitaoka 120a6e
  Dialog(QWidget *parent = 0, bool hasButton = false, bool hasFixedSize = true,
Shinya Kitaoka 120a6e
         const QString &name = QString());
Shinya Kitaoka 120a6e
  ~Dialog();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void beginVLayout();
Shinya Kitaoka 120a6e
  void endVLayout();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void beginHLayout();
Shinya Kitaoka 120a6e
  void endHLayout();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void addWidget(QWidget *widget, bool isRight = true);
Shinya Kitaoka 120a6e
  void addWidgets(QWidget *firstW, QWidget *secondW);
Shinya Kitaoka 120a6e
  void addWidget(QString labelName, QWidget *widget);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void addLayout(QLayout *layout, bool isRight = true);
Shinya Kitaoka 120a6e
  void addWidgetLayout(QWidget *widget, QLayout *layout);
Shinya Kitaoka 120a6e
  void addLayout(QString labelName, QLayout *layout);
Shinya Kitaoka 120a6e
  void addLayouts(QLayout *firstL, QLayout *secondL);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void addSpacing(int spacing);
Shinya Kitaoka 120a6e
  void addSeparator(QString name = QString());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setAlignment(Qt::Alignment alignment);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setTopMargin(int margin);
Shinya Kitaoka 120a6e
  void setTopSpacing(int spacing);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setLabelWidth(int labelWidth);
Shinya Kitaoka 120a6e
  int getLabelWidth() const { return m_labelWidth; };
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setLayoutInsertedSpacing(int spacing);
Shinya Kitaoka 120a6e
  int getLayoutInsertedSpacing();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setButtonBarMargin(int margin);
Shinya Kitaoka 120a6e
  void setButtonBarSpacing(int spacing);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void addButtonBarWidget(QWidget *widget);
Shinya Kitaoka 120a6e
  void addButtonBarWidget(QWidget *first, QWidget *second);
Shinya Kitaoka 120a6e
  void addButtonBarWidget(QWidget *first, QWidget *second, QWidget *third);
Jeremy Bullock 33e7d1
  void addButtonBarWidget(QWidget *first, QWidget *second, QWidget *third,
Jeremy Bullock 33e7d1
                          QWidget *fourth);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void hideEvent(QHideEvent *event) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void clearButtonBar();
Toshihiro Shimizu 890ddd
signals:
Shinya Kitaoka 120a6e
  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 d1f6c4
class DVAPI RadioButtonDialog final : public DVGui::Dialog {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_result;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  RadioButtonDialog(const QString &labelText,
Shinya Kitaoka 120a6e
                    const QList<qstring> &radioButtonList, QWidget *parent = 0,</qstring>
Shinya Kitaoka 120a6e
                    Qt::WindowFlags f = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public Q_SLOTS:
Shinya Kitaoka 120a6e
  void onButtonClicked(int id);
Shinya Kitaoka 120a6e
  void onCancel();
Shinya Kitaoka 120a6e
  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,
Shinya Kitaoka 120a6e
                            const QList<qstring> &buttons, QWidget *parent = 0);</qstring>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI ProgressDialog : public DVGui::Dialog {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QLabel *m_label;
Shinya Kitaoka 120a6e
  QProgressBar *m_progressBar;
Shinya Kitaoka 120a6e
  QPushButton *m_cancelButton;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  bool m_isCanceled;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ProgressDialog(const QString &labelText, const QString &cancelButtonText,
Shinya Kitaoka 120a6e
                 int minimum, int maximum, QWidget *parent = 0,
Shinya Kitaoka 120a6e
                 Qt::WindowFlags f = 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setLabelText(const QString &text);
Shinya Kitaoka 120a6e
  void setCancelButton(QPushButton *cancelButton);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int maximum();
Shinya Kitaoka 120a6e
  void setMaximum(int maximum);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int minimum();
Shinya Kitaoka 120a6e
  void setMinimum(int minimum);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void reset();
Shinya Kitaoka 120a6e
  int value();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool wasCanceled() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public Q_SLOTS:
Shinya Kitaoka 120a6e
  void setValue(int progress);
Shinya Kitaoka 120a6e
  virtual void onCancel();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
Q_SIGNALS:
Shinya Kitaoka 120a6e
  void canceled();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*! Return 2 if erase style,
Shinya Kitaoka 120a6e
                                         1 if don't erase style,
Shinya Kitaoka 120a6e
                                         0 if press cancel or close popup.
Shinya Kitaoka 120a6e
          If newPalette != 0 verify if styles to erase are in new palette before
Shinya Kitaoka 120a6e
   send question.
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 120a6e
int eraseStylesInDemand(TPalette *palette, const TXsheetHandle *xsheetHandle,
Shinya Kitaoka 120a6e
                        TPalette *newPalette = 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int eraseStylesInDemand(TPalette *palette, std::vector<int> styleIds,</int>
Shinya Kitaoka 120a6e
                        const TXsheetHandle *xsheetHandle);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
}  // namespace DVGui
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // DVDIALOG_INCLUDED