summaryrefslogtreecommitdiffstats
path: root/src/combobutton.h
blob: 2f49a70e46f3c2cac91f22fb873783776a96375d (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


#ifndef COMBOBUTTON_H
#define COMBOBUTTON_H

#include <tqwidget.h>

class TQString;
class TQPixmap;
class KPushButton;
class KComboBox;

/**
 * @short ComboButton
 * @author Daniel Faust <hessijames@gmail.com>
 * @version 0.3
 */
class ComboButton : public TQWidget
{
    Q_OBJECT
  
public:
    enum SizeMode {
        Min, Max
    };

    /**
     * Constructor
     * @param parent The parent widget
     * @param name The name of the file list
     */
    ComboButton( TQWidget *parent, const char *name = 0 );

    /**
     * Destructor
     */
    virtual ~ComboButton();

    /**
     * Insert a new item with @p text at position @p index
     */
    void insertItem( const TQString &text, int index = -1 );
    /**
     * Insert a new item with an icon @p pixmap and @p text at position @p index
     */
    void insertItem( const TQPixmap &pixmap, const TQString &text, int index = -1 );

    /**
     * Increase the combobutton's height by @p height
     */
    void increaseHeight( int height );

    /**
     * Sets m_sizeMode to @p mode
     */
    void setSizeMode( int mode );

    /**
     * Returns the m_sizeMode
     */
    int sizeMode();

    /**
     * Sets the font of the combobutton
     */
    void setFont( const TQFont& font );

    /**
     * Returns the font of the button
     */
    TQFont font();

private:
    /** A pointer to the button */
    KPushButton *m_button;
    /** A pointer to the combobox */
    KComboBox *m_box;

    int m_increaseHeight;

    /** The actual size mode */
    int m_sizeMode;

    /** Recalculate the size of the combobutton */
    void balanceSize();
    /** The button gets a new label, etc. */
    void repaintButton();

//public slots:
    //void setCurrentItem(const TQString &item, bool insert=false, int index=-1);
    //void setCurrentItem(int index);

private slots:
    /**
     * Is called when the user selects an item from the popdown menu of the combobox
     */
    void boxActivated( int index );
    /**
     * Is called when the user clicks the button
     */
    void buttonClicked();

signals:
    /**
     * The signal clicked is emitted, when the user selects an item
     */
    void clicked( int index );

};

#endif // COMBOBUTTON_H