#ifndef __RV_DX_COMBOBOX_H_INCLUDED_
#define __RV_DX_COMBOBOX_H_INCLUDED_
 

#include "Button.h"
#include "scrollbar.h"
#include "..\incs\rvb\dsm.h"

#include <d3d9types.h>

//-----------------------------------------------------------------------------
// ComboBox control
//-----------------------------------------------------------------------------
typedef struct __uc_combobox_item_
{
    char strText[256];
    void*  pData;

    GRect  rcActive;
    BOOL   bVisible;
}UcComboBoxItem;


class CUcComboBox : public CUcButton
{
public:
    CUcComboBox( HANDLE hDelegater = NULL );
    virtual ~CUcComboBox();
    
    virtual void SetTextColor( D3DCOLOR color );
    virtual HRESULT OnInit() ;

    virtual BOOL HandleKeyboard( UINT uMsg, WPARAM wParam, LPARAM lParam );
    virtual BOOL HandleMouse( UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam );
    virtual void OnHotkey();

 //   virtual BOOL CanHaveFocus() { return (m_bVisible && m_bEnabled); }
    virtual void OnFocusOut();
  //  virtual void Render( IDirect3DDevice9* pd3dDevice, float fElapsedTime );

    virtual void UpdateRects(); 

    HRESULT AddItem( const char* strText, void* pData );
    void    RemoveAllItems();
    void    RemoveItem( UINT index );
    BOOL    ContainsItem( const char* strText, UINT iStart=0 );
    int     FindItem( const char* strText, UINT iStart=0 );
    void*   GetItemData( const char* strText );
    void*   GetItemData( int nIndex );
    void    SetDropHeight( UINT nHeight ) { m_nDropHeight = nHeight; UpdateRects(); }
    void    SetScrollBarWidth( int nWidth ) { m_nSBWidth = nWidth; UpdateRects(); }

    void*   GetSelectedData();
    UcComboBoxItem* GetSelectedItem();

    UINT    GetNumItems() { return rclGetCount(m_itemArray);};

    UcComboBoxItem* GetItem( UINT index ) { return (UcComboBoxItem*)rclGetAt(m_itemArray,  index ); }

    HRESULT SetSelectedByIndex( UINT index );
    HRESULT SetSelectedByText( const char* strText );
    HRESULT SetSelectedByData( void* pData );  

protected:
    int     m_iSelected;
    int     m_iFocused;
    int     m_nDropHeight;
    CUcScrollBar m_ScrollBar;
    int     m_nSBWidth;

    BOOL    m_bOpened;

    GRect m_rcText;
    GRect m_rcButton;
    GRect m_rcDropdown;
    GRect m_rcDropdownText;

    RvCluster    m_itemArray;

 //   CGrowableArray< UcComboBoxItem* > m_Items;

};




#endif //__RV_DX_COMBOBOX_H_INCLUDED_