Advertisement
Guest User

QmaxRollup.h

a guest
May 24th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.39 KB | None | 0 0
  1. // Copyright (c) 2016 Autodesk, Inc.
  2. // All rights reserved.
  3. //
  4. //  Use of this software is subject to the terms of the Autodesk license
  5. //  agreement provided at the time of installation or download, or which
  6. //  otherwise accompanies this software in either electronic or hard copy form.
  7.  
  8. #pragma once
  9.  
  10.  
  11. #include "CoreExport.h"
  12. #include "RollupConstants.h"
  13.  
  14. #pragma warning(push)
  15. #pragma warning(disable: 4127 4251 4275 4512 4800 )
  16. #include <QtWidgets/QWidget>
  17. #pragma warning(pop)
  18.  
  19. namespace MaxSDK
  20. {
  21.     class QmaxRollupContainer;
  22.     class QmaxRollupPrivate;
  23.    
  24.     /** \brief 3ds Max Qt Rollup class.
  25.      * This class provides access to the Qt implementation of the 3ds Max Rollup widget.  
  26.      * It exposes properties such as title and category, so they can be easily set
  27.      * in code or in the Qt Designer.
  28.      *
  29.      * Rollups are the base containers for other widgets for most plug-ins.  They are displayed
  30.      * on the 3ds Max command panel.  
  31.      *
  32.      * \note QmaxRollupContainer filters out wheel events for some children to prevent the user from
  33.      * inadvertently changing values of controls. Wheel events are filtered for children that inherit
  34.      * from QAbstractSpinBox, QLineEdit, QAbstractSlider, QComboBox, and QCalendarView.
  35.      */
  36.     class CoreExport QmaxRollup : public QWidget
  37.     {
  38.         Q_OBJECT
  39.         /** \brief The rollup title.  
  40.          * \see title(), setTitle() */
  41.         Q_PROPERTY( QString title READ title WRITE setTitle )
  42.         /** \brief The rollup open status.
  43.          * \see setOpen(), open(), close() */
  44.         Q_PROPERTY( bool open READ isOpen WRITE setOpen NOTIFY toggled )
  45.         /** \brief The rollup category.  
  46.          * \see category(), setCategory(), resetCategory() */
  47.         Q_PROPERTY( int category READ category WRITE setCategory )
  48.         Q_FLAGS( Options )
  49.  
  50.     public:
  51.  
  52.         // Note: These enum values match the legacy rollup flags (APPENDROLL_CLOSED, etc.)
  53.         /** \brief Create options for QmaxRollup. */
  54.         enum Option
  55.         {
  56.             NoOptions =     0x0, ///< Create rollup in a closed state.
  57.             DontAutoClose = 0x2, ///< Don't close this rollup when doing a "close all".
  58.             SaveCat =       0x4, ///< Save the category provided in the RollupOrder.cfg
  59.             BorderLess =    0x10, ///< Don't display a title or border, don't support drag-and-drop, right-click menu, or collapse/expand.
  60.             NoPadding =     0x20, ///< Create the rollup with minimal padding.  This is primarily for MaxScript, which performs its own padding.
  61.             FixedCat =      0x40 ///< Fixed rollups have no drag pattern in the header.
  62.         };
  63.  
  64.         /** \brief Creates a QmaxRollup with no title, with an optionally specified category and parent.  
  65.          * \param category The category.  For third-party plug-ins, this is usually ROLLUP_CAT_STANDARD.
  66.          * \param parent The widget parent.  You typically do not need to supply a parent, unless you are placing
  67.          * the rollup somewhere other than the command panel (such as in a dialog).
  68.          */
  69.         explicit QmaxRollup( int category = ROLLUP_CAT_STANDARD, QWidget* parent = nullptr );
  70.         /** \brief Creates a QmaxRollup with the specified title, and optional category and parent.  
  71.          * \param title The title for the rollup.
  72.          * \param category The category.  For third-party plug-ins, this is usually ROLLUP_CAT_STANDARD.
  73.          * \param parent The widget parent.  You typically do not need to supply a parent, unless you are placing
  74.          * the rollup somewhere other than the command panel (such as in a dialog).
  75.          */
  76.         explicit QmaxRollup( const QString& title, int category = ROLLUP_CAT_STANDARD, QWidget* parent = nullptr );
  77.         /** \brief Destructor */
  78.         virtual ~QmaxRollup();
  79.  
  80.         Q_DECLARE_FLAGS( Options, Option );
  81.  
  82.         /** \brief Sets the options for the rollup.
  83.          * \see Option, options()
  84.          */
  85.         void setOptions( Options options );
  86.         /** \brief Returns the options for the rollup. */
  87.         Options options() const;
  88.  
  89.  
  90.         /** \brief Returns the rollup's widget, or a nullptr if there is none.
  91.          * \see setWidget(), takeWidget()
  92.          */
  93.         QWidget *widget() const;
  94.  
  95.         /** \brief Puts a widget (such as a panel containing other widgets) into the rollup.
  96.          * The widget becomes a child of the rollup, and will be destroyed when
  97.          * the rollup is deleted or when a new widget is set.  If the rollup already contains
  98.          * a widget, it is destroyed.
  99.          * \see widget(), takeWidget()
  100.          */
  101.         virtual void setWidget( QWidget *widget );
  102.  
  103.         /** \brief Removes the rollup's widget, and passes ownership of the widget to
  104.          * the caller.  The widget is not destroyed.
  105.          * \return The containing widget
  106.          * \see widget(), setWidget */
  107.         virtual QWidget *takeWidget();
  108.        
  109.         /** \brief Returns whether the rollup is open or closed ("rolled up"). */
  110.         bool isOpen() const;
  111.        
  112.         /** \brief Returns the rollup's title. */
  113.         QString title() const;
  114.         /** \brief Sets the rollup's title.
  115.          * \param title The title string. */
  116.         void setTitle( const QString& title );
  117.  
  118.         int category() const;
  119.         /** \brief Sets the rollup's category. */
  120.         void setCategory( int category );
  121.         /** \brief Resets the rollup's category to its original category. */
  122.         void resetCategory();
  123.  
  124.         /** \brief Returns the container for the rollup. */
  125.         QmaxRollupContainer* container() const;
  126.  
  127.     public slots:
  128.  
  129.         /** \brief Sets the open/closed state of the rollup.
  130.          * \param isOpen If true, sets the rollup state to open. */
  131.         virtual void setOpen( bool isOpen = true );
  132.         /** \brief Sets the state of the rollup to open. */
  133.         inline void open(){ setOpen( true ); }
  134.         /** \brief Sets the state of the rollup to closed. */
  135.         inline void close(){ setOpen( false ); }
  136.        
  137.     signals:
  138.  
  139.         /** \brief Emitted when the open/close state of the rollup is changed.
  140.          * \param isOpen True when the rollup state is now open. */
  141.         void toggled( bool isOpen = false );
  142.         /** \brief Emitted when the rollup is opened. */
  143.         void opened();
  144.         /** \brief Emitted when the rollup is closed */
  145.         void closed();
  146.            
  147.     protected:
  148.  
  149.         explicit QmaxRollup( QmaxRollupPrivate* _d, const QString& title, QWidget* parent = nullptr );
  150.  
  151.         virtual void paintEvent( QPaintEvent* event ) override;
  152.  
  153.         virtual void mousePressEvent( QMouseEvent* event ) override;
  154.         virtual void mouseReleaseEvent( QMouseEvent* event ) override;
  155.         virtual void mouseMoveEvent( QMouseEvent* event ) override;
  156.  
  157.         virtual bool event( QEvent* event ) override;
  158.  
  159.         Q_DECLARE_PRIVATE( QmaxRollup );
  160.  
  161.     private:
  162.  
  163.         QmaxRollupPrivate* d_ptr;
  164.         Q_DISABLE_COPY( QmaxRollup );
  165.  
  166.         friend class QmaxRollupContainer;
  167.     };
  168.  
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement