/////////////////////////////////////////////////////////////////////////////
// Name:        commandlistbox.h
// Purpose:     wxCommandListBox definition
// Author:      Francesco Montorsi
// Modified by:
// Created:     15/06/2006 21:21:22
// RCS-ID:      $Id: commandlistbox.h,v 1.2 2007/01/23 23:05:40 frm Exp $
// Copyright:   (c) 2006 Francesco Montorsi
// Licence:     wxWidgets license
/////////////////////////////////////////////////////////////////////////////

#ifndef _CMDLISTBOX_H_
#define _CMDLISTBOX_H_


/*!
 * Includes
 */

#include <wx/htmllbox.h>
#include "wxp/package.h"


// ----------------------------------------------------------------------------
// wxCommandListBox
// ----------------------------------------------------------------------------

class wxCommandListBox : public wxHtmlListBox
{
public:
    wxCommandListBox(wxWindow* parent, wxWindowID id = wxID_ANY, 
                     const wxPoint& pos = wxDefaultPosition, 
                     const wxSize& size = wxDefaultSize, 
                     long style = 0, const wxString& name = wxT("commandlistbox"));

public:     // misc

    void Clear()
        { m_arr.Clear(); TransferDataToWindow(); }

public:     // setters

    void Append(const wxPackageCommand &item)
        { m_arr.Add(item); TransferDataToWindow(); }

    // NB: call TransferDataToWindow() after all calls to SetString !!
    void SetCommand(unsigned int n, const wxPackageCommand &item)
        { m_arr[n] = item; }

    void SetCommands(const wxPackageCommandArray &arr)
        { m_arr=arr; TransferDataToWindow(); }
    void SetBuildSystemType(wxPackageBuildSystemType type)
        { m_buildsys = type; TransferDataToWindow(); }
    void SetCompilerFormats(long formats)
        { m_formats = formats; TransferDataToWindow(); }

    void DeleteSelected();

    // does m_arr => m_items filtering
    bool TransferDataToWindow();

public:     // getters
    
    //! Returns the number of commands shown i.e. filtered.
    unsigned int GetCount() const
        { return m_index.GetCount(); }
    
    wxPackageCommand &GetCommand(unsigned int n)
        { return m_arr[m_index[n]]; }

    wxPackageCommandArray &GetCommands()
        { return m_arr; }

protected:
    virtual wxString OnGetItem(size_t n) const;
    virtual wxColour GetSelectedTextBgColour(const wxColour& colBg, size_t n) const;
    virtual wxColour GetSelectedTextColour(const wxColour& colFg, size_t n) const;

protected:

    wxPackageCommandArray m_arr;

    // filters of the m_arr commands above:
    wxPackageBuildSystemType m_buildsys;
    long m_formats;

    // the indexes of the items of m_arr which passed through the filters
    wxArrayInt m_index;

private:
    DECLARE_NO_COPY_CLASS(wxCommandListBox)
};


#endif
    // _CMDLISTBOX_H_
