/////////////////////////////////////////////////////////////////////////////
// Name:        cmdeditdlg.h
// Purpose:     wxPackageCommandEditDlg definition
// Author:      Francesco Montorsi
// Modified by:
// Created:     Sat 12 Aug 2006 16:34:58 CEST
// RCS-ID:      $Id: cmdeditdlg.h,v 1.2 2007/01/01 20:06:19 frm Exp $
// Copyright:   (c) 2006 Francesco Montorsi
// Licence:     wxWidgets license
/////////////////////////////////////////////////////////////////////////////

#ifndef _CMDEDITDLG_H_
#define _CMDEDITDLG_H_


/*!
 * Includes
 */

#include "wx/notebook.h"
#include "wxp/packagecmd.h"
#include "guicmn/condeditpanel.h"

/*!
 * Forward declarations
 */

////@begin forward declarations
class wxNotebook;
////@end forward declarations

/*!
 * Control identifiers
 */

////@begin control identifiers
#define ID_DIALOG 10011
#define SYMBOL_WXPACKAGECOMMANDEDITDLG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
#define SYMBOL_WXPACKAGECOMMANDEDITDLG_TITLE _("Build system command")
#define SYMBOL_WXPACKAGECOMMANDEDITDLG_IDNAME ID_DIALOG
#define SYMBOL_WXPACKAGECOMMANDEDITDLG_SIZE wxSize(400, 300)
#define SYMBOL_WXPACKAGECOMMANDEDITDLG_POSITION wxDefaultPosition
#define ID_CMDEDIT_CMD 10000
#define ID_CMDEDIT_WORKDIR 10001
////@end control identifiers



// ----------------------------------------------------------------------------
// wxPackageCommandEditDlg
// ----------------------------------------------------------------------------

class wxPackageCommandEditDlg: public wxDialog
{
    DECLARE_DYNAMIC_CLASS( wxPackageCommandEditDlg )
    DECLARE_EVENT_TABLE()

public:
    /// Constructors
    wxPackageCommandEditDlg( );
    wxPackageCommandEditDlg( wxWindow* parent, wxWindowID id = SYMBOL_WXPACKAGECOMMANDEDITDLG_IDNAME, const wxString& caption = SYMBOL_WXPACKAGECOMMANDEDITDLG_TITLE, const wxPoint& pos = SYMBOL_WXPACKAGECOMMANDEDITDLG_POSITION, const wxSize& size = SYMBOL_WXPACKAGECOMMANDEDITDLG_SIZE, long style = SYMBOL_WXPACKAGECOMMANDEDITDLG_STYLE );

    /// Creation
    bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WXPACKAGECOMMANDEDITDLG_IDNAME, const wxString& caption = SYMBOL_WXPACKAGECOMMANDEDITDLG_TITLE, const wxPoint& pos = SYMBOL_WXPACKAGECOMMANDEDITDLG_POSITION, const wxSize& size = SYMBOL_WXPACKAGECOMMANDEDITDLG_SIZE, long style = SYMBOL_WXPACKAGECOMMANDEDITDLG_STYLE );

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

    /// Should we show tooltips?
    static bool ShowToolTips();

public:     // event handlers

    void OnOK(wxCommandEvent &ev);

public:     // public API

    // NB: the stage is important as the cmd.GetCondition().GetStages() value
    //     cannot be used as it could comprise other stages (which is important
    //     to preserve to allow wxCommandSet to recognize commands from
    //     the wxPackageInfo' arrays)
    void SetCommand(const wxPackageCommand &cmd, wxPackageBuildSystemStage stage)
    {
        m_pCmd->SetValue(cmd.GetCommand());
        m_pWorkDir->SetValue(cmd.GetWorkingPath());
        m_pConditionPanel->SetCondition(cmd.GetCondition());

        m_pLabel->SetLabel(
            wxString::Format(wxT("This dialog allows you to edit the command for the %s stage.\nSince the command syntax is usually platform-dependent and also\nbuildsystem-dependent, you probably need to use the 'Condition' panel\nto restrict its validity."),
            wxPackageBuildSystemStage2String(stage).MakeUpper().c_str()));
    }

    wxPackageCommand GetCommand() const
    {
        wxPackageCommand ret(m_pCmd->GetValue(),
                             m_pWorkDir->GetValue(),
                             m_pConditionPanel->GetCondition());
        wxASSERT(ret.IsOk());
        return ret;
    }

protected:      // controls

////@begin wxPackageCommandEditDlg member variables
    wxNotebook* m_pNotebook;
    wxStaticText* m_pLabel;
    wxTextCtrl* m_pCmd;
    wxTextCtrl* m_pWorkDir;
////@end wxPackageCommandEditDlg member variables

    wxPackageConditionPanel *m_pConditionPanel;
};

#endif
// _CMDEDITDLG_H_
