/////////////////////////////////////////////////////////////////////////////
// Name:        extcmdoptionspanel.h
// Purpose:     wxExtCmdOptionsPanel definition
// Author:      Julian Smart, Francesco Montorsi
// Modified by:
// Created:     15/06/2006 21:21:22
// RCS-ID:      $Id: extcmdoptionspanel.h,v 1.4 2007/01/28 15:56:10 frm Exp $
// Copyright:   (c) 2006 Francesco Montorsi
// Licence:     wxWidgets license
/////////////////////////////////////////////////////////////////////////////

#ifndef _PMEXTCMDOPTIONSPANEL_H_
#define _PMEXTCMDOPTIONSPANEL_H_


/*!
 * Includes
 */

#include <wx/listctrl.h>
#include <wx/htmllbox.h>

#include "wxp/package.h"
#include "guipm/opteditctrl.h"

class wxPropertyGridEvent;
class wxCommandListBox;



/*!
 * Control identifiers
 */

////@begin control identifiers
#define ID_EXTCMD_RESET 10041
#define ID_EXTCMD_OPTIONS 10029
#define ID_EXTCMD_WXBUILD 10022
#define ID_EXTCMD_EDIT 10066
#define ID_EXTCMD_TARGET 10028
#define ID_EXTCMD_ONLYCHANGED 10001
#define ID_EXTCMD_COMMANDS 10000
#define SYMBOL_WXEXTCMDOPTIONSPANEL_STYLE 0
#define SYMBOL_WXEXTCMDOPTIONSPANEL_TITLE _("Options")
#define SYMBOL_WXEXTCMDOPTIONSPANEL_IDNAME wxID_ANY
#define SYMBOL_WXEXTCMDOPTIONSPANEL_SIZE wxSize(400, 300)
#define SYMBOL_WXEXTCMDOPTIONSPANEL_POSITION wxDefaultPosition
////@end control identifiers

#define SYMBOL_WXEXTCMDOPTIONSPANEL_NAME wxT("Build")


// ----------------------------------------------------------------------------
// wxExtCmdOptionsPanel
// ----------------------------------------------------------------------------

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

public:
    /// Constructors
    wxExtCmdOptionsPanel( );
    wxExtCmdOptionsPanel( wxWindow* parent,
                          wxWindowID id = SYMBOL_WXEXTCMDOPTIONSPANEL_IDNAME,
                          const wxPoint& pos = SYMBOL_WXEXTCMDOPTIONSPANEL_POSITION,
                          const wxSize& size = SYMBOL_WXEXTCMDOPTIONSPANEL_SIZE,
                          long style = SYMBOL_WXEXTCMDOPTIONSPANEL_STYLE,
                          const wxString &name = SYMBOL_WXEXTCMDOPTIONSPANEL_NAME );

    /// Creation
    bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WXEXTCMDOPTIONSPANEL_IDNAME,
                 const wxPoint& pos = SYMBOL_WXEXTCMDOPTIONSPANEL_POSITION,
                 const wxSize& size = SYMBOL_WXEXTCMDOPTIONSPANEL_SIZE,
                 long style = SYMBOL_WXEXTCMDOPTIONSPANEL_STYLE,
                 const wxString &name = SYMBOL_WXEXTCMDOPTIONSPANEL_NAME);

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

public:     // event handlers

    void OnOptionChanged(wxCommandEvent &ev);
    void OnTargetChanged(wxCommandEvent &ev);
    void OnWxBuildChanged(wxCommandEvent &ev);
    void OnOnlyChanged(wxCommandEvent &ev);

    void OnReset(wxCommandEvent &ev);
    void OnEditWxBuild(wxCommandEvent &ev);

    void OnUpdateUI(wxUpdateUIEvent &ev);

public:

    //! Sets the array of commands (options) which will be modified by the user.
    void SetPackage(const wxPackage &p, wxPackageBuildSystemStage stage);

    const wxPackage &GetPackage() const
        { return m_pkg; }
    wxPackage &GetPackage()
        { return m_pkg; }

    wxPackageBuildSystemStage GetPackageBuildSystemStage() const
        { return m_stage; }

    void UpdateCommands();
    bool TransferDataFromWindow();

public:     // function to programmatically change option values while
            // the panel is shown

    //! Returns the user-edited command option array.
    //! Note that this function can be called only when the panel has
    //! been created and not destroyed yet.
    wxPackageCommandOptionArray &GetOptions()
        { return m_pOptionsList->GetOptions(); }

    void RefreshOptions()
        { m_pOptionsList->TransferDataToWindow(); }

    void SelectWxBuild(size_t sel);

    void InitWxBuildList();

protected:      // controls

    wxOptionEditorCtrl *m_pOptionsList;
    wxCommandListBox *m_pCommandList;
    wxChoice *m_pSelBuild;
    wxChoice *m_pTargetList;
    wxStaticText *m_pLabel1, *m_pLabel2;
    wxCheckBox *m_pOnlyChangedBox;

protected:

    wxPackage m_pkg;
    wxPackageBuildSystemStage m_stage;

    //! The cached array of *valid* commands for the m_pkg already substituted.
    wxPackageCommandArray m_cmd;

    // the currently selected wxbuild; can be -1
    int m_selWxBuild;
};


#endif
    // _PMEXTCMDOPTIONSPANEL_H_
