summaryrefslogtreecommitdiffstats
path: root/yakuake/src/tabbed_widget.h
blob: f9d6c9110e4dfaf1fc66775e7f7fe5653c247b21 (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
*/

/*
  Copyright (C) 2005 Francois Chazal <neptune3k@free.fr>
  Copyright (C) 2006-2007 Eike Hein <hein@kde.org>
*/


#ifndef TABBED_WIDGET_H
#define TABBED_WIDGET_H


#include "translucent_widget.h"

#include <tqfont.h>
#include <tqcolor.h>
#include <tqpoint.h>
#include <tqpixmap.h>
#include <tqpainter.h>
#include <tqlineedit.h>
#include <tqvaluelist.h>
#include <tqfontmetrics.h>

#include <tdelocale.h>
#include <krootpixmap.h>
#include <kinputdialog.h>


class TDEPopupMenu;

class TabbedWidget : public TranslucentWidget
{
    Q_OBJECT
  

    public:
        explicit TabbedWidget(TQWidget* parent = 0, const char* name = 0, bool translucency = false);
        ~TabbedWidget();

        int pressedPosition();
        void resetPressedPosition() { pressed_position = -1; }

        void addItem(int session_id);
        int removeItem(int session_id);

        int tabPositionForSessionId(int session_id);
        int sessionIdForTabPosition(int position);

        void selectItem(int session_id);
        void selectPosition(int position);

        void selectNextItem();
        void selectPreviousItem();

        void moveItemLeft();
        void moveItemLeft(int position);

        void moveItemRight();
        void moveItemRight(int position);

        const TQString itemName(int session_id);
        void renameItem(int session_id, const TQString& name);

        void interactiveRename();
        void interactiveRename(int position);

        void setFontColor(const TQColor& color);
        void setBackgroundPixmap(const TQString& path);
        void setSeparatorPixmap(const TQString& path);

        void setUnselectedPixmap(const TQString& path);

        void setSelectedPixmap(const TQString& path);
        void setSelectedLeftPixmap(const TQString& path);
        void setSelectedRightPixmap(const TQString& path);

        void refreshBuffer();


    signals:
        void addItem();
        void itemSelected(int session_id);


    protected:
        virtual void keyPressEvent(TQKeyEvent*);

        virtual void wheelEvent(TQWheelEvent*);
        virtual void mousePressEvent(TQMouseEvent*);
        virtual void mouseReleaseEvent(TQMouseEvent*);
        virtual void mouseDoubleClickEvent(TQMouseEvent*);

        virtual void leaveEvent(TQEvent*);

        virtual void paintEvent(TQPaintEvent*);


    private:
        void createContextMenu();
        const int drawButton(int position, TQPainter& painter);
        TQString defaultTabCaption(int session_id);
        TQString lowestAvailableCaption();

        int current_position;
        bool pressed;
        int pressed_position;
        int edited_position;

        /* Tabs properties */
        TQColor font_color;
        TQFont selected_font;
        TQFont unselected_font;

        /* Inline renaming */
        TQLineEdit* inline_edit;

        /* Widget's pixmaps */
        TQPixmap background_image;

        TQPixmap separator_image;
        TQPixmap unselected_image;

        TQPixmap selected_image;
        TQPixmap selected_left_image;
        TQPixmap selected_right_image;

        /* Widget's appearance */
        TQPixmap buffer_image;
        TQPixmap desktop_image;

        /* Tabs value lists */
        TQValueList<int> items;
        TQValueList<int> areas;
        TQValueList<TQString> captions;

        TDEPopupMenu* context_menu;


    private slots:
        void slotRenameSelected();
        void slotUpdateBuffer(const TQPixmap& pixmap);
        void slotResetEditedPosition();
};

#endif /* TABBED_WIDGET_H */