File: stabctl.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 (120 lines) | stat: -rw-r--r-- 3,412 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
/***************************************************************************
                         STabCtl part of KDEStudio
                             -------------------
    copyright            : (C) 1999 by Judin Maximus
    email                : novaprint@mtu-net.ru
 ***************************************************************************/

#ifndef STABCTL_H
#define STABCTL_H

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

#include "stabbar.h"

struct TabCtlData
{
  TabCtlData( QWidget* _widget, int _id )
  {
    widget = _widget;
    id = _id;
    enabled = true;
  }
  ~TabCtlData(){;}

  QWidget* widget;
  int      id;
  bool     enabled;
};

class STabCtl : public QWidget
{ Q_OBJECT
public:

  STabCtl( QWidget *parent = 0, const char *name = 0 );
  ~STabCtl();

  void setTabPos( STabBar::TabPos );
  STabBar::TabPos getTabPos(){ return tabPos; }

  int insertPage( QWidget *, const QString &label, int id = -1 );

/***********************************************************************/
  void setPageCaption( int id, const QString &caption ){ setPageCaption( page(id), caption ); }
  void setPageCaption( QWidget*, const QString & );

  QString pageCaption( int id ){ return pageCaption( page(id) ); }
  QString pageCaption( QWidget* );
/***********************************************************************/
  void setPixmap( int id, const QPixmap &pix ){ setPixmap( page(id), pix ); }
  void setPixmap( QWidget* , const QPixmap &pix );

/***********************************************************************/
  void setTabTextColor( int id, const QColor &color ){ setTabTextColor( page(id), color ); }
  void setTabTextColor( QWidget*, const QColor &color );

  const QColor& tabTextColor( int id ){ return tabTextColor( page(id) ); }
  const QColor& tabTextColor( QWidget* );
/***********************************************************************/
  bool isPageEnabled( int id ){ return isPageEnabled( page(id) ); }
  bool isPageEnabled( QWidget* );

  void setPageEnabled( int id, bool enabled  ){ setPageEnabled( page(id), enabled ); }
  void setPageEnabled( QWidget*, bool );
/***********************************************************************/

  QWidget* page( int );
  int id( QWidget* );

  void removePage( QWidget* );
  void removePage( int id ){ removePage( page(id) ); }

  QWidget* visiblePage();
  int visiblePageId(){ return id( visiblePage() ); }

  void setVisiblePage( QWidget*, bool allowDisable = false );

  void setTabFont( const QFont &font );
  QFont tabFont();

  void showTabIcon( bool );
  bool isShowTabIcon();

  int  pageCount(){ return mainData->count(); }
  QWidget* getFirstPage();
  QWidget* getLastPage();
  QWidget* getNextPage( QWidget* );
  QWidget* getPrevPage( QWidget* );

  virtual void show();

public slots:
  virtual void setEnabled( bool );
  void setVisiblePage(int id){ setVisiblePage( page(id) ); }

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

signals:
  void aboutToShow( QWidget* );
  void pageSelected( QWidget* );
  void tabShowPopup( int, QPoint );

protected slots:
  void rightButtonPress( int, QPoint );

private:
  TabCtlData* findData( QWidget* );
  TabCtlData* findData( int id );
  void showPage( QWidget*, bool allowDisable = false );
  QRect getChildRect() const;

  QList<TabCtlData> *mainData;
  QWidget* currentPage;
  STabBar* tabs;
  STabBar::TabPos tabPos;
};

#endif