/////////////////////////////////////////////////////////////////////////////
// Name:        mainfrm.h
// Purpose:     Main packager frame
// Author:      Francesco Montorsi
// Modified by:
// Created:     2006-06-08
// RCS-ID:      $Id: mainfrm.h,v 1.6 2007/01/30 20:45:46 frm Exp $
// Copyright:   (c) Francesco Montorsi
// Licence:     wxWidgets licence
/////////////////////////////////////////////////////////////////////////////

#ifndef _MAINFRM_H_
#define _MAINFRM_H_

// Includes
#include <wx/frame.h>
#include <wx/help.h>
#include <wx/docview.h>
#include <wx/html/helpctrl.h>

#include "wxp/packagewxp.h"

// Forward declarations
class wxPackagePropertiesPanel;


// ----------------------------------------------------------------------------
// wxPackagerFrame
// ----------------------------------------------------------------------------

class wxPackagerFrame : public wxFrame
{
public:
    wxPackagerFrame() {}

    // size & position are loaded from global wxConfig
    bool Create();

public:     // event handlers

    void OnCloseWindow(wxCloseEvent& event);
    void OnUpdateUI(wxUpdateUIEvent& event);
    void OnPropPanelUserChange(wxCommandEvent& event);

    // file menu:

    void OnExit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);
    void OnHelp(wxCommandEvent& event);

    void OnNewPackage(wxCommandEvent& event);
    void OnOpenPackage(wxCommandEvent& event);
    void OnOpenMRUPackage(wxCommandEvent& event);
    void OnSavePackage(wxCommandEvent& event);
    void OnSaveAsPackage(wxCommandEvent& event);
    void OnClosePackage(wxCommandEvent& event);

    // package menu:

    void OnCheck(wxCommandEvent& event);
    void OnRepackage(wxCommandEvent& event);
    void OnUpload(wxCommandEvent& event);

public:

    void Open(const wxString &filename);
    void Save();
    void Close();
    void AskBeforeClosing();

    bool CheckForErrors(bool showProceedQuestion = true);
    wxFileName GetPackageFileName(const wxPackage &pkg) const;
    void UpdateFrameTitle();

protected:
    wxPackagePropertiesPanel* m_prop;
    wxHtmlHelpController m_bestHelp;
    wxFileHistory m_mru;

    // data about the currently loaded WXP:

    wxString m_current;     // its filename
    wxPackageXMLDescriptor m_currentXml;

    DECLARE_EVENT_TABLE()
    DECLARE_CLASS(wxPackagerFrame)
};

#endif
  // _MAINFRM_H_

