/////////////////////////////////////////////////////////////////////////////
// Name:        compilerpanel.h
// Purpose:     wxCompilerSettingsPanel definition
// Author:      Francesco Montorsi
// Modified by: 
// Created:     08/07/2006 14:41:18
// RCS-ID:      $Id: compilerpanel.h,v 1.4 2007/02/01 20:28:14 frm Exp $
// Copyright:   (c) 2006 Francesco Montorsi
// Licence:     wxWidgets license
/////////////////////////////////////////////////////////////////////////////

#ifndef _PMCOMPILERSETTINGS_H_
#define _PMCOMPILERSETTINGS_H_


/*!
 * Includes
 */

#include "wxp/compiler.h"
#include "wxp/package.h"


/*!
 * Forward declarations
 */

class wxOptionEditorCtrl;
class wxConfigBase;
class wxPackage;


/*!
 * Control identifiers
 */

////@begin control identifiers
#define ID_COMPILERSETTINGS_DEFAULTCOMPILER 10036
#define ID_COMPILERSETTINGS_NOTES 10059
#define ID_COMPILERSETTINGS_PATHS 10000
#define ID_COMPILERSETTINGS_ADDPATH 10035
#define ID_COMPILERSETTINGS_EDITPATH 10058
#define ID_COMPILERSETTINGS_OPENPATH 10233
#define ID_COMPILERSETTINGS_DELETEPATH 10037
#define ID_COMPILERSETTINGS_AUTODETECT 10001
#define SYMBOL_WXCOMPILERSETTINGSPANEL_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
#define SYMBOL_WXCOMPILERSETTINGSPANEL_TITLE _("Dialog")
#define SYMBOL_WXCOMPILERSETTINGSPANEL_IDNAME wxID_ANY
#define SYMBOL_WXCOMPILERSETTINGSPANEL_SIZE wxSize(400, 300)
#define SYMBOL_WXCOMPILERSETTINGSPANEL_POSITION wxDefaultPosition
////@end control identifiers



// ----------------------------------------------------------------------------
// wxCompilerSettingsPanel
// ----------------------------------------------------------------------------

class wxCompilerSettingsPanel: public wxPanel
{    
    DECLARE_DYNAMIC_CLASS( wxCompilerSettingsPanel )
    DECLARE_EVENT_TABLE()

public:
    /// Constructors
    wxCompilerSettingsPanel( );
    wxCompilerSettingsPanel( wxWindow* parent, 
                             wxWindowID id = SYMBOL_WXCOMPILERSETTINGSPANEL_IDNAME, 
                             const wxPoint& pos = SYMBOL_WXCOMPILERSETTINGSPANEL_POSITION, 
                             const wxSize& size = SYMBOL_WXCOMPILERSETTINGSPANEL_SIZE, 
                             long style = SYMBOL_WXCOMPILERSETTINGSPANEL_STYLE );

    /// Creation
    bool Create( wxWindow* parent, 
                 wxWindowID id = SYMBOL_WXCOMPILERSETTINGSPANEL_IDNAME, 
                 const wxPoint& pos = SYMBOL_WXCOMPILERSETTINGSPANEL_POSITION, 
                 const wxSize& size = SYMBOL_WXCOMPILERSETTINGSPANEL_SIZE, 
                 long style = SYMBOL_WXCOMPILERSETTINGSPANEL_STYLE );

    /// Creates the controls and sizers
    void CreateControls();

    bool ShowToolTips();

public:     // event handlers

    void OnCompilerChanged(wxCommandEvent &);
    void OnAutodetect(wxCommandEvent &);

    void OnAddNewPath(wxCommandEvent &ev);
    void OnRemovePath(wxCommandEvent &ev);
    void OnEditPath(wxCommandEvent &);
    void OnOpenPath(wxCommandEvent &);

    void OnUpdateUI(wxUpdateUIEvent &);

public:     // public API
      /*
    bool Load(wxConfigBase *, const wxString &path);
    void Save(wxConfigBase *, const wxString &path) const;
*/
    void UpdatePathList();
    void UpdatePackageCompiler();
    void UpdateCompilerSettingsPaths();
    void UpdateNotes();

    wxPackage &GetPackage()
        { return m_pkg; }

    wxPackageCompilerFormat GetSelCompilerFormat() const;

public:     // one of these two function MUST be called after creation !!

    void InitAsGlobal();
    void SetPackage(const wxPackage &);

public:     // misc

    //! Interactively detects paths for the given format.
    static void InteractiveAutodetectPathsFor(wxPackageCompilerFormat f);

protected:      // autodetect helpers

    static bool AutodetectMSVC();
    static bool AutodetectBCC();
    static bool AutodetectMinGW();
    static bool AutodetectWatcom();

protected:      // internal utils

    wxString GetCompilerUserFriendlyName(wxPackageCompilerFormat f);

protected:      // controls

    wxChoice *m_pCompilerChoice;
    wxListBox *m_pPathList;
    wxTextCtrl *m_pNotes;

protected:

    wxPackage m_pkg;
};


#endif
    // _PMCOMPILERSETTINGS_H_
