24#include <KoTabChooser.h>
26#include <tqpopupmenu.h>
32class KoTabChooserPrivate {
34 KoTabChooserPrivate() {
36 ~KoTabChooserPrivate() {}
46KoTabChooser::KoTabChooser( TQWidget *parent,
int _flags )
47 : TQFrame( parent,
"" )
49 setFrameStyle( MenuBarPanel );
51 d=
new KoTabChooserPrivate();
57 if ( flags & TAB_DEC_PNT ) currType = TAB_DEC_PNT;
58 if ( flags & TAB_CENTER ) currType = TAB_CENTER;
59 if ( flags & TAB_RIGHT ) currType = TAB_RIGHT;
60 if ( flags & TAB_LEFT ) currType = TAB_LEFT;
66void KoTabChooser::mousePressEvent( TQMouseEvent *e )
68 if ( currType == 0 )
return;
73 switch ( e->button() ) {
74 case TQt::LeftButton:
case TQt::MidButton: {
77 if ( flags & TAB_CENTER ) currType = TAB_CENTER;
78 else if ( flags & TAB_RIGHT ) currType = TAB_RIGHT;
79 else if ( flags & TAB_DEC_PNT ) currType = TAB_DEC_PNT;
82 if ( flags & TAB_DEC_PNT ) currType = TAB_DEC_PNT;
83 else if ( flags & TAB_LEFT ) currType = TAB_LEFT;
84 else if ( flags & TAB_CENTER ) currType = TAB_CENTER;
87 if ( flags & TAB_RIGHT ) currType = TAB_RIGHT;
88 else if ( flags & TAB_DEC_PNT ) currType = TAB_DEC_PNT;
89 else if ( flags & TAB_LEFT ) currType = TAB_LEFT;
92 if ( flags & TAB_LEFT ) currType = TAB_LEFT;
93 else if ( flags & TAB_CENTER ) currType = TAB_CENTER;
94 else if ( flags & TAB_RIGHT ) currType = TAB_RIGHT;
99 case TQt::RightButton: {
100 TQPoint pnt( TQCursor::pos() );
102 rb_menu->setItemChecked( mLeft,
false );
103 rb_menu->setItemChecked( mCenter,
false );
104 rb_menu->setItemChecked( mRight,
false );
105 rb_menu->setItemChecked( mDecPoint,
false );
107 switch ( currType ) {
108 case TAB_LEFT: rb_menu->setItemChecked( mLeft,
true );
110 case TAB_CENTER: rb_menu->setItemChecked( mCenter,
true );
112 case TAB_RIGHT: rb_menu->setItemChecked( mRight,
true );
114 case TAB_DEC_PNT: rb_menu->setItemChecked( mDecPoint,
true );
118 rb_menu->popup( pnt );
125void KoTabChooser::drawContents( TQPainter *painter )
127 if ( currType == 0 )
return;
129 painter->setPen( TQPen( black, 2, SolidLine ) );
131 switch ( currType ) {
133 painter->drawLine( 4, height() - 4, width() - 4, height() - 4 );
134 painter->drawLine( 5, 4, 5, height() - 4 );
137 painter->drawLine( 4, height() - 4, width() - 4, height() - 4 );
138 painter->drawLine( width() / 2, 4, width() / 2, height() - 4 );
141 painter->drawLine( 4, height() - 4, width() - 4, height() - 4 );
142 painter->drawLine( width() - 5, 4, width() - 5, height() - 4 );
145 painter->drawLine( 4, height() - 4, width() - 4, height() - 4 );
146 painter->drawLine( width() / 2, 4, width() / 2, height() - 4 );
147 painter->fillRect( width() / 2 + 2, height() - 9, 3, 3, black );
154void KoTabChooser::setupMenu()
156 rb_menu =
new TQPopupMenu();
157 TQ_CHECK_PTR( rb_menu );
158 mLeft = rb_menu->insertItem( i18n(
"Tabulator &Left" ),
this, TQ_SLOT( rbLeft() ) );
159 mCenter = rb_menu->insertItem( i18n(
"Tabulator &Center" ),
this, TQ_SLOT( rbCenter() ) );
160 mRight = rb_menu->insertItem( i18n(
"Tabulator &Right" ),
this, TQ_SLOT( rbRight() ) );
161 mDecPoint = rb_menu->insertItem( i18n(
"Tabulator &Decimal Point" ),
this, TQ_SLOT( rbDecPoint() ) );
162 rb_menu->setCheckable(
false );
165KoTabChooser::~KoTabChooser() {
170void KoTabChooser::setReadWrite(
bool _readWrite)
172 d->m_bReadWrite=_readWrite;
175#include <KoTabChooser.moc>