00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef TOOLCHOOSER_H
00028 #define TOOLCHOOSER_H
00029
00030
00031 #include <QWidget>
00032
00033 #include "digest.h"
00034
00035 #include <QIcon>
00036 #include <QLabel>
00037 #include <QVBoxLayout>
00038
00039
00040
00041
00042 #include <QTabBar>
00043 class ToolTabBar : public QTabBar {
00044 public:
00045 ToolTabBar( QWidget* parent = 0 ) : QTabBar(parent) {}
00046 protected:
00047 QSize tabSizeHint( int index ) const {
00048
00049 return QSize( (index==count()-1)
00050 ? 31
00051 : 29, QTabBar::tabSizeHint(index).height()+2 );
00052 }
00053 };
00054
00055
00056 class ToolChooser : public QWidget {
00057
00058 Q_OBJECT
00059
00060 public:
00061 ToolChooser( QWidget* parent = 0 ) : QWidget(parent)
00062 {
00063 QVBoxLayout* layout = new QVBoxLayout( this );
00064 layout->setMargin( 3 );
00065
00066 tabBar = new ToolTabBar( this );
00067 tabBar->addTab( QIcon(":images/tools/SelectionTool.png"), QString() );
00068 tabBar->addTab( QIcon(":images/tools/ZoomTool.png"), QString() );
00069 tabBar->addTab( QIcon(":images/tools/ShapeTool.png"), QString() );
00070 tabBar->addTab( QIcon(":images/tools/PolygonTool.png"), QString() );
00071 tabBar->addTab( QIcon(":images/tools/PolylineTool.png"), QString() );
00072 tabBar->addTab( QIcon(":images/tools/TextTool.png"), QString() );
00073 layout->addWidget( tabBar );
00074
00075 connect( tabBar,
00076 SIGNAL(currentChanged(int)), SLOT(onTabBarCurrentChanged(int)) );
00077
00078 #if 0 // TODO: make the following optional
00079 QLabel* label = new QLabel( this );
00080 QFont f = label->font();
00081 f.setPointSize( 11 );
00082 label->setFont( f );
00083 label->setAlignment( Qt::AlignHCenter );
00084 label->setText( tr("Tool Mode") );
00085 layout->addWidget( label );
00086 #endif
00087 }
00088
00089 Digest::Tool currentTool() const {
00090 Q_ASSERT( tabBar != 0 );
00091 return (Digest::Tool )tabBar->currentIndex();
00092 }
00093
00094
00095 signals:
00096 void currentToolChanged( Digest::Tool tool );
00097
00098
00099 public slots:
00100 void setCurrentTool( Digest::Tool tool ) {
00101 Q_ASSERT( tabBar != 0 );
00102 tabBar->setCurrentIndex( (int)tool );
00103 }
00104
00105
00106 private slots:
00107 void onTabBarCurrentChanged( int index ) {
00108 emit currentToolChanged( (Digest::Tool)index );
00109 }
00110
00111
00112 private:
00113 ToolTabBar* tabBar;
00114 };
00115
00116
00117
00118 #endif // ! TOOLCHOOSER_H