#pragma once

#include <tqwidget.h>
#include <tqstring.h>
#include <tqpixmap.h>
#include <tqptrlist.h>

class AudioDevice;
class PulseModel;
class KLed;
class KLedButton;
class LevelMeter;
class TQSlider;
class BalanceKnob;
class TQLabel;
class TQRadioButton;
class TQContextMenuEvent;
class TQFrame;

class DeviceWidget : public TQWidget
{
    TQ_OBJECT

public:
    DeviceWidget( AudioDevice *device, PulseModel *model, TQWidget *parent = 0 );
    ~DeviceWidget() {}

    AudioDevice *device() const { return m_device; }
    LevelMeter  *levelMeter() const { return m_levelMeter; }
    void setSeparatorVisible( bool v );

protected:
    void contextMenuEvent( TQContextMenuEvent *e );
    void wheelEvent( TQWheelEvent *e );

private slots:
    void onVolumeChanged( int v );
    void onBalanceChanged( int v );
    void onMuteClicked();
    void onToggleMute();
    void onDefaultClicked();
    void onMoveToSink( int id );
    void onDefaultChanged( AudioDevice *dev );
    void onRecordingActive( bool active );

    void onDeviceVolume( int v );
    void onDeviceMute( bool m );
    void onDevicePan( int p );
    void onDeviceLevel( float level );
    void onDeviceName( const TQString &name );

private:
    AudioDevice  *m_device;
    PulseModel   *m_model;
    TQFrame       *m_sep;
    TQSlider      *m_volSlider;
    BalanceKnob   *m_balanceDial;
    KLedButton    *m_muteLed;
    KLed          *m_recordingLed;  // null unless Input
    TQRadioButton  *m_defaultBtn;   // null for Playback/Recording
    TQLabel       *m_volLabel;
    LevelMeter   *m_levelMeter;
    TQWidget      *m_label;
    TQLabel       *m_iconLabel;

    TQPtrList<AudioDevice> m_moveTargets;  // populated by context menu build
};
