#ifndef __WU_Q_MACRO_WIDGET_TYPE_ENUM_H__
#define __WU_Q_MACRO_WIDGET_TYPE_ENUM_H__

/*LICENSE_START*/
/*
 *  Copyright (C) 2018 Washington University School of Medicine
 *
 *  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.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
/*LICENSE_END*/


#include <stdint.h>
#include <vector>
#include "AString.h"

namespace caret {

class WuQMacroWidgetTypeEnum {

public:
    /**
     * Enumerated values.
     */
    enum Enum {
        /** Invalid type */
        INVALID,
        /** a QAction (not checkable) */
        ACTION,
        /** a Checkable QAction */
        ACTION_CHECKABLE,
        /** a QAction Group */
        ACTION_GROUP,
        /** a QButtonGroup */
        BUTTON_GROUP,
        /** a QCheckBox */
        CHECK_BOX,
        /** a QComboBox */
        COMBO_BOX,
        /** a QDoubleSpinBox */
        DOUBLE_SPIN_BOX,
        /** a QLineEdit */
        LINE_EDIT,
        /** a QListWidget */
        LIST_WIDGET,
        /** a Macro Widget Action */
        MACRO_WIDGET_ACTION,
        /** a QMenu */
        MENU,
        /** a QPushButton(not checkable) */
        PUSH_BUTTON,
        /** a Checkable QPushButton */
        PUSH_BUTTON_CHECKABLE,
        /** a QRadioButton */
        RADIO_BUTTON,
        /** a QSlider */
        SLIDER,
        /** a QSpinBox */
        SPIN_BOX,
        /** a QTabBar */
        TAB_BAR,
        /** a QTabWidget */
        TAB_WIDGET,
        /** a QToolButton (not checkable) */
        TOOL_BUTTON,
        /** a Checkable QToolButton */
        TOOL_BUTTON_CHECKABLE
    };

/*
 switch (m_objectType) {
 case WuQMacroWidgetTypeEnum::ACTION:
 break;
 case WuQMacroWidgetTypeEnum::CHECK_BOX:
 break;
 case WuQMacroWidgetTypeEnum::COMBO_BOX:
 break;
 case WuQMacroWidgetTypeEnum::DOUBLE_SPIN_BOX:
 break;
 case WuQMacroWidgetTypeEnum::INVALID:
 break;
 case WuQMacroWidgetTypeEnum::LINE_EDIT:
 break;
 case WuQMacroWidgetTypeEnum::LIST_WIDGET:
 break;
 case WuQMacroWidgetTypeEnum::MENU:
 break;
 case WuQMacroWidgetTypeEnum::PUSH_BUTTON:
 break;
 case WuQMacroWidgetTypeEnum::RADIO_BUTTON:
 break;
 case WuQMacroWidgetTypeEnum::SLIDER:
 break;
 case WuQMacroWidgetTypeEnum::SPIN_BOX:
 break;
 case WuQMacroWidgetTypeEnum::TAB_BAR:
 break;
 case WuQMacroWidgetTypeEnum::TAB_WIDGET:
 break;
 case WuQMacroWidgetTypeEnum::TOOL_BUTTON:
 break;
 }
 */

    ~WuQMacroWidgetTypeEnum();

    static AString toName(Enum enumValue);
    
    static Enum fromName(const AString& name, bool* isValidOut);
    
    static AString toGuiName(Enum enumValue);
    
    static Enum fromGuiName(const AString& guiName, bool* isValidOut);
    
    static int32_t toIntegerCode(Enum enumValue);
    
    static Enum fromIntegerCode(const int32_t integerCode, bool* isValidOut);

    static void getAllEnums(std::vector<Enum>& allEnums);

    static void getAllNames(std::vector<AString>& allNames, const bool isSorted);

    static void getAllGuiNames(std::vector<AString>& allGuiNames, const bool isSorted);

    static void addWidgetClassNameAlias(const QString& widgetName,
                                        const QString& aliasWidgetName);
    
private:
    WuQMacroWidgetTypeEnum(const Enum enumValue,
                 const AString& name,
                 const AString& guiName);

    static const WuQMacroWidgetTypeEnum* findData(const Enum enumValue);

    /** Holds all instance of enum values and associated metadata */
    static std::vector<WuQMacroWidgetTypeEnum> enumData;

    /** Initialize instances that contain the enum values and metadata */
    static void initialize();

    /** Indicates instance of enum values and metadata have been initialized */
    static bool initializedFlag;
    
    /** Auto generated integer codes */
    static int32_t integerCodeCounter;
    
    /** The enumerated type value for an instance */
    Enum enumValue;

    /** The integer code associated with an enumerated value */
    int32_t integerCode;

    /** The name, a text string that is identical to the enumerated value */
    AString name;
    
    /** A user-friendly name that is displayed in the GUI */
    AString guiName;
    
    /** Aliases for widget 'first' is QWidget, 'second' is alias */
    static std::vector<std::pair<QString, QString>> s_widgetClassNameAliases;
};

#ifdef __WU_Q_MACRO_WIDGET_TYPE_ENUM_DECLARE__
    std::vector<WuQMacroWidgetTypeEnum> WuQMacroWidgetTypeEnum::enumData;
    bool WuQMacroWidgetTypeEnum::initializedFlag = false;
    int32_t WuQMacroWidgetTypeEnum::integerCodeCounter = 0;
    std::vector<std::pair<QString, QString>> WuQMacroWidgetTypeEnum::s_widgetClassNameAliases;
#endif // __WU_Q_MACRO_WIDGET_TYPE_ENUM_DECLARE__

} // namespace
#endif  //__WU_Q_MACRO_WIDGET_TYPE_ENUM_H__
