File: stabbar.h

package info (click to toggle)
kdbg 1.2.4-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,504 kB
  • ctags: 1,945
  • sloc: cpp: 15,961; sh: 8,183; makefile: 481; perl: 71; ansic: 16
file content (142 lines) | stat: -rw-r--r-- 2,864 bytes parent folder | download
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
/***************************************************************************
                         STabBar part of KDEStudio
                             -------------------
    copyright            : (C) 1999 by Judin Maximus
    email                : novaprint@mtu-net.ru
 ***************************************************************************/

#ifndef STABBAR_H
#define STABBAR_H

#include <qwidget.h>
#include <qlist.h>
#include <qpixmap.h>

class QPushButton;

struct TabBarData
{
  TabBarData( int _id, const char* _label )
  {
    id = _id;
    width = 0;
    label = _label;
    pix = 0L;
    enabled = true;
#if QT_VERSION >= 200
    textColor = Qt::black;
#else
    textColor = black;
#endif
  }
  ~TabBarData()
  {
    if ( pix != 0L ) delete pix;
  }
  int      id;
  int      width;
  QString  label;
  QPixmap* pix;
  bool     enabled;
  QColor   textColor;
};

class BarPainter;

class STabBar: public QWidget
{Q_OBJECT
friend class BarPainter;
public:
  STabBar( QWidget * parent = 0, const char * name = 0 );
  ~STabBar();

  enum TabPos{
    TAB_TOP,
    TAB_RIGHT
  };
  void setTabPos( TabPos );

  int insertTab( const QString &label, int id = -1 );

  void setPixmap( int id, const QPixmap &pix );

  void setTextColor( int id, const QColor &color );
  const QColor& textColor( int id );

  void removeTab( int );

  int  currentTab(){ return _currentTab; }
  void setCurrentTab( int id, bool allowDisable = false );

  void setTabEnabled( int, bool );
  bool isTabEnabled( int );

  void setTabCaption( int id, const QString &caption );
  QString tabCaption( int id );

  virtual void show();
  virtual void setFont( const QFont & );

  void showTabIcon( bool );
  bool isShowTabIcon(){ return iconShow; }

signals:
  void tabSelected( int );
  void rightButtonPress( int, QPoint );

protected slots:
  void leftClicked();
  void rightClicked();

protected:
  virtual void paintEvent( QPaintEvent* );
  virtual void resizeEvent( QResizeEvent* );

private:
  void setButtonPixmap();
  void updateHeight();

  TabBarData* findData( int id );
  int tabsWidth();
  void tabsRecreate();

  TabPos tabPos;
  BarPainter* barPainter;
  QList<TabBarData> *mainData;
  int _currentTab;
  int leftTab;

  QPixmap* up_xpm;
  QPixmap* down_xpm;
  QPixmap* left_xpm;
  QPixmap* right_xpm;

  QPushButton *right;
  QPushButton *left;
  bool rightscroll;
  bool leftscroll;
  bool iconShow;
};

class BarPainter: public QWidget
{Q_OBJECT
friend class STabBar;
private:
  BarPainter( STabBar * parent );
  ~BarPainter();

  void drawBuffer();
  int findBarByPos( int x, int y );
  QPixmap* buffer;
  int mousePressTab;
  int delta;

protected:
  virtual void mousePressEvent ( QMouseEvent * );
  virtual void mouseReleaseEvent ( QMouseEvent * );

  virtual void resizeEvent( QResizeEvent * );
  virtual void paintEvent( QPaintEvent * );
};

#endif