/*
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
 * http://www.gnu.org/licenses/gpl-3.0.html
 */

#ifndef ASSOCIATIONS_H
#define ASSOCIATIONS_H

#include "scrollingdialog.h"

#ifdef __WXMSW__
    #define DDE_SERVICE "CODEBLOCKS"
#else
    #define DDE_SERVICE "/tmp/CODEBLOCKS%s.socket"
#endif
#define DDE_TOPIC "CodeBlocksDDEServer"

class wxCheckListBox;
class wxCommandEvent;
class wxString;
class wxWindow;

namespace Associations
{
    struct Assoc
    {
    wxString ext;
    wxString descr;
    int index;
    bool core;
    };

    unsigned int CountAssocs();

    void SetCore();
    void SetAll();
    void ClearAll();
    void SetBatchBuildOnly();
    bool Check();

    void DoSetAssociation(const wxString& ext, const wxString& descr, const wxString& exe, int icoNum);
    bool DoCheckAssociation(const wxString& ext, const wxString& descr, const wxString& exe, int icoNum);  // TODO: descriptions are not checked at all, and actually it's not necessary
                                                                                                           //       (extension + executable is actually enough)
                                                                                                           //        ---> decide whether to remove parameter from "Check" function or implement
    void DoClearAssociation(const wxString& ext);

    void UpdateChanges();
}

class ManageAssocsDialog : public wxScrollingDialog
{
    wxCheckListBox* list;

    public:
        ManageAssocsDialog(wxWindow* parent);
    protected:
        void OnApply(wxCommandEvent& event);
        void OnCancel(wxCommandEvent& event);
        void OnClearAll(wxCommandEvent& event);
    private:
        DECLARE_EVENT_TABLE()
};

#define ASC_ASSOC_DLG_NO_DONT_ASK       0
#define ASC_ASSOC_DLG_NO_ONLY_NOW       1
#define ASC_ASSOC_DLG_YES_C_FILES       2
#define ASC_ASSOC_DLG_YES_ALL_FILES     3

class AskAssocDialog : public wxScrollingDialog
{
    public:
        AskAssocDialog(wxWindow* parent);
    protected:
        void OnOK(wxCommandEvent& event);
        void OnESC(wxCommandEvent& event);
        void OnCharHook(wxKeyEvent& event);
    private:
        DECLARE_EVENT_TABLE()
};



#endif // ASSOCIATIONS_H
