summaryrefslogtreecommitdiffstats
path: root/kmix/viewbase.h
blob: bda3aa06d7d33e940f0a6c9c204da5d15c20fd49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef ViewBase_h
#define ViewBase_h

// QT
#include "tqwidget.h"

// KDE
class TDEActionCollection;
class TDEPopupMenu;
class MixSet;
class Mixer;
class MixDevice;

/**
  * The ViewBase is a virtual base class, to be used for subclassing the real Mixer Views.
  */
class ViewBase : public TQWidget
{
    TQ_OBJECT
  
public:

    typedef uint ViewFlags;
    enum ViewFlagsEnum {
	// Regular flags
        HasMenuBar     = 0x0001,
        MenuBarVisible = 0x0002,
        Horizontal     = 0x0004,
        Vertical       = 0x0008,
	// Experimental flags
	Experimental_SurroundView = 0x1000,
	Experimental_GridView = 0x2000
    };

    ViewBase(TQWidget* parent, const char* name, const TQString & caption, Mixer* mixer, WFlags=0, ViewFlags vflags=0);
    virtual ~ViewBase();

    // Subclasses must define this method. It is called by the ViewBase() constuctor.
    // The view class must initialize here the _mixSet. This will normally be a subset
    // of the passed mixset.
    // After that the subclass must be prepared for
    // being fed MixDevice's via the add() method.
    virtual void setMixSet(MixSet *mixset);

    // Returns the number of accepted MixDevice's from setMixerSet(). This is
    // normally smaller that mixset->count(), except when the class creates virtual
    // devices
    virtual int count() = 0;
    // returns an advice about whether this view should be used at all. The returned
    // value is a percentage (0-100). A view without accepted devices would return 0,
    // a "3D sound View" would return 75, if all vital but some optional devices are
    // not available.
    virtual int advice() = 0;

    // This method is called by ViewBase at the end of createDeviceWidgets(). The default
    // implementation does nothing. Subclasses can override this method for doing final
    // touches. This is very much like polish(), but called at an exactly well-known time.
    // Also I do not want Views to interfere with polish()
    virtual void constructionFinished() = 0;

    // This method is called after a configuration update (in other words: after the user
    // has clicked "OK" on the "show/hide" configuration dialog. The default implementation
    // does nothing.
    virtual void configurationUpdate();

    /**
     * Creates the widgets for all supported devices. The default implementation loops
     * over the supported MixDevice's and calls add() for each of it.
     */
    virtual void createDeviceWidgets();

    /**
     * Creates a suitable representation for the given MixDevice.
     * The default implementation creates a label
     */
    virtual TQWidget* add(MixDevice *);

    /**
     * Popup stuff
     */
    virtual TDEPopupMenu* getPopup();
    virtual void popupReset();
    virtual void showContextMenu();

    Mixer* getMixer();

    /**
     * Contains the widgets for the _mixSet. There is a 1:1 relationship, which means:
     * _mdws[i] is the Widget for the MixDevice _mixSet[i].
     * Hint: The new ViewSurround class shows that a 1:1 relationship does not work in a general scenario.
     *       I actually DID expect this. The solution is unclear yet, probably there will be a virtual mapper method.
     */
    TQPtrList<TQWidget> _mdws; // this obsoletes the former Channel class
    
    TQString caption() const { return _caption; }

protected:
    void init();

    Mixer *_mixer;
    MixSet *_mixSet;
    TDEPopupMenu *_popMenu;
    TDEActionCollection* _actions;
    ViewFlags _vflags;

public slots:
   virtual void refreshVolumeLevels();
   virtual void configureView(); 
   void toggleMenuBarSlot();
   void selectMixerSlot();

protected slots:
   void mousePressEvent( TQMouseEvent *e );

signals:
   void toggleMenuBar();
   void selectMixer();
   
private:
   TQString _caption;
};

#endif