/***************************************************************************
    begin                : Tuesday Nov 15 2005
    copyright            : (C) 2005 by Holger Danielsson
    email                : holger.danielsson@t-online.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include "kilestatswidget.h"
  
#include <kdialog.h>
#include <klocale.h>

#include <tqvariant.h>
#include <tqlabel.h>
#include <tqbuttongroup.h>
#include <tqlayout.h>
#include <tqtooltip.h>
#include <tqwhatsthis.h>
#include "kiledebug.h"

KileWidgetStatistics::KileWidgetStatistics( TQWidget* parent, const char* name, WFlags fl )
    : TQWidget( parent, name, fl )
{
	TQVBoxLayout *vbox = new TQVBoxLayout(parent, 5,KDialog::spacingHint() );

	// characters groupbox
	TQGroupBox *chargroup = new TQGroupBox( i18n("Characters"),parent); 
	chargroup->setColumnLayout(0, Qt::Vertical );
	chargroup->tqlayout()->setSpacing( 6 );
	chargroup->tqlayout()->setMargin( 11 );
	chargrouptqlayout = new TQGridLayout( chargroup->tqlayout() );
	chargrouptqlayout->tqsetAlignment( TQt::AlignTop );

	m_wordCharText = new TQLabel(i18n("Words and numbers:"), chargroup);
	m_commandCharText = new TQLabel(i18n("LaTeX commands and environments:"), chargroup);
	m_whitespaceCharText = new TQLabel(i18n("Punctuation, delimiter and whitespaces:"), chargroup);
	m_totalCharText = new TQLabel(i18n("Total characters:"), chargroup);
	m_wordChar = new TQLabel( chargroup, "m_wordChar" );
	m_commandChar = new TQLabel( chargroup, "m_commandChar" );
	m_whitespaceChar = new TQLabel( chargroup, "m_whitespaceChar" );
	m_totalChar = new TQLabel( chargroup, "m_totalChar" );

	TQFrame *charframe = new TQFrame(chargroup);
	charframe->setFrameStyle(TQFrame::HLine | TQFrame::Sunken);
	charframe->setLineWidth(1);

	chargrouptqlayout->addWidget( m_wordCharText, 0,0 );
	chargrouptqlayout->addWidget( m_commandCharText, 1,0 );
	chargrouptqlayout->addWidget( m_whitespaceCharText, 2,0 );
	chargrouptqlayout->addWidget( m_totalCharText, 4,0 );
	chargrouptqlayout->addWidget( m_wordChar, 0,2,TQt::AlignRight );
	chargrouptqlayout->addWidget( m_commandChar, 1,2,TQt::AlignRight );
	chargrouptqlayout->addWidget( m_whitespaceChar, 2,2,TQt::AlignRight );
	chargrouptqlayout->addMultiCellWidget( charframe, 3,3,1,2 );
	chargrouptqlayout->addWidget( m_totalChar, 4,2,TQt::AlignRight );
	chargrouptqlayout->setColSpacing(1,16);
	chargrouptqlayout->setColSpacing(3,1);
	chargrouptqlayout->setColStretch(3,1);

	// string groupbox
	TQGroupBox *stringgroup = new TQGroupBox( i18n("Strings"),parent);
	stringgroup->setColumnLayout(0, Qt::Vertical );
	stringgroup->tqlayout()->setSpacing( 6 );
	stringgroup->tqlayout()->setMargin( 11 );
	stringgrouptqlayout = new TQGridLayout( stringgroup->tqlayout() );
	stringgrouptqlayout->tqsetAlignment( TQt::AlignTop );

	m_wordStringText = new TQLabel(i18n("Words:"), stringgroup);
	m_commandStringText = new TQLabel(i18n("LaTeX commands:"), stringgroup);
	m_environmentStringText = new TQLabel(i18n("LaTeX environments:"), stringgroup);
	m_totalStringText = new TQLabel(i18n("Total strings:"), stringgroup);
	m_wordString = new TQLabel( stringgroup, "m_wordString" );
	m_commandString = new TQLabel( stringgroup, "m_commandStringText" );
	m_environmentString = new TQLabel( stringgroup, "m_environmentStringText" );
	m_totalString = new TQLabel( stringgroup, "m_totalStringText" );

	TQFrame *stringframe = new TQFrame(stringgroup);
	stringframe->setFrameStyle(TQFrame::HLine | TQFrame::Sunken);
	stringframe->setLineWidth(1);

	stringgrouptqlayout->addWidget( m_wordStringText, 0,0 );
	stringgrouptqlayout->addWidget( m_commandStringText, 1,0 );
	stringgrouptqlayout->addWidget( m_environmentStringText, 2,0 );
	stringgrouptqlayout->addWidget( m_totalStringText, 4,0 );
	stringgrouptqlayout->addWidget( m_wordString, 0,2,TQt::AlignRight );
	stringgrouptqlayout->addWidget( m_commandString, 1,2,TQt::AlignRight );
	stringgrouptqlayout->addWidget( m_environmentString, 2,2,TQt::AlignRight );
	stringgrouptqlayout->addMultiCellWidget( stringframe, 3,3,1,2 );
	stringgrouptqlayout->addWidget( m_totalString, 4,2,TQt::AlignRight );
	stringgrouptqlayout->setColSpacing(1,16);
	stringgrouptqlayout->setColSpacing(3,1);
	stringgrouptqlayout->setColStretch(3,1);

	m_commentAboutHelp = new TQLabel(parent);
	m_warning =  new TQLabel(parent);
 
	vbox->addWidget(chargroup);
	vbox->addWidget(stringgroup);
	vbox->addSpacing(12);
	vbox->addWidget(m_commentAboutHelp);
	vbox->addWidget(m_warning);
	vbox->addStretch(1);

	int w = m_commandCharText->tqsizeHint().width();
	if ( m_whitespaceCharText->tqsizeHint().width() > w )
		w = m_whitespaceCharText->tqsizeHint().width();
	stringgrouptqlayout->setColSpacing(0,w);

}

KileWidgetStatistics::~KileWidgetStatistics()
{
}

void KileWidgetStatistics::updateColumns()
{
	int w = m_totalChar->tqsizeHint().width();
	if ( m_totalString->tqsizeHint().width() > w )
		w = m_totalString->tqsizeHint().width();
	chargrouptqlayout->setColSpacing(2,w);
	stringgrouptqlayout->setColSpacing(2,w);
}


#include "kilestatswidget.moc"
