|
|
@ -44,6 +44,7 @@
|
|
|
|
#include "ntqdrawutil.h"
|
|
|
|
#include "ntqdrawutil.h"
|
|
|
|
#include "ntqpixmap.h"
|
|
|
|
#include "ntqpixmap.h"
|
|
|
|
#include "ntqstyle.h"
|
|
|
|
#include "ntqstyle.h"
|
|
|
|
|
|
|
|
#include "ntqwmatrix.h"
|
|
|
|
#include "../kernel/qinternal_p.h"
|
|
|
|
#include "../kernel/qinternal_p.h"
|
|
|
|
#if defined(QT_ACCESSIBILITY_SUPPORT)
|
|
|
|
#if defined(QT_ACCESSIBILITY_SUPPORT)
|
|
|
|
#include "ntqaccessible.h"
|
|
|
|
#include "ntqaccessible.h"
|
|
|
@ -102,7 +103,8 @@ TQProgressBar::TQProgressBar( TQWidget *parent, const char *name, WFlags f )
|
|
|
|
center_indicator( TRUE ),
|
|
|
|
center_indicator( TRUE ),
|
|
|
|
auto_indicator( TRUE ),
|
|
|
|
auto_indicator( TRUE ),
|
|
|
|
percentage_visible( TRUE ),
|
|
|
|
percentage_visible( TRUE ),
|
|
|
|
d( 0 )
|
|
|
|
d( 0 ),
|
|
|
|
|
|
|
|
m_orientation( Horizontal )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ) );
|
|
|
|
setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ) );
|
|
|
|
initFrame();
|
|
|
|
initFrame();
|
|
|
@ -133,7 +135,8 @@ TQProgressBar::TQProgressBar( int totalSteps,
|
|
|
|
center_indicator( TRUE ),
|
|
|
|
center_indicator( TRUE ),
|
|
|
|
auto_indicator( TRUE ),
|
|
|
|
auto_indicator( TRUE ),
|
|
|
|
percentage_visible( TRUE ),
|
|
|
|
percentage_visible( TRUE ),
|
|
|
|
d( 0 )
|
|
|
|
d( 0 ),
|
|
|
|
|
|
|
|
m_orientation( Horizontal )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ) );
|
|
|
|
setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ) );
|
|
|
|
initFrame();
|
|
|
|
initFrame();
|
|
|
@ -234,9 +237,15 @@ TQSize TQProgressBar::sizeHint() const
|
|
|
|
constPolish();
|
|
|
|
constPolish();
|
|
|
|
TQFontMetrics fm = fontMetrics();
|
|
|
|
TQFontMetrics fm = fontMetrics();
|
|
|
|
int cw = style().pixelMetric(TQStyle::PM_ProgressBarChunkWidth, this);
|
|
|
|
int cw = style().pixelMetric(TQStyle::PM_ProgressBarChunkWidth, this);
|
|
|
|
return style().sizeFromContents(TQStyle::CT_ProgressBar, this,
|
|
|
|
TQSize sh = style().sizeFromContents(TQStyle::CT_ProgressBar, this,
|
|
|
|
TQSize( cw * 7 + fm.width( '0' ) * 4,
|
|
|
|
TQSize( cw * 7 + fm.width( '0' ) * 4,
|
|
|
|
fm.height() + 8));
|
|
|
|
fm.height() + 8));
|
|
|
|
|
|
|
|
if (m_orientation == TQt::Horizontal) {
|
|
|
|
|
|
|
|
return sh;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
return TQSize(sh.height(), sh.width());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -321,6 +330,22 @@ void TQProgressBar::styleChange( TQStyle& old )
|
|
|
|
TQFrame::styleChange( old );
|
|
|
|
TQFrame::styleChange( old );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQt::Orientation TQProgressBar::orientation() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return m_orientation;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQProgressBar::setOrientation(Orientation orient)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_orientation = orient;
|
|
|
|
|
|
|
|
if (m_orientation == TQt::Horizontal) {
|
|
|
|
|
|
|
|
setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
setSizePolicy( TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Expanding ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
This method is called to generate the text displayed in the center
|
|
|
|
This method is called to generate the text displayed in the center
|
|
|
@ -371,40 +396,71 @@ bool TQProgressBar::setIndicator( TQString & indicator, int progress,
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void TQProgressBar::drawContents( TQPainter *p )
|
|
|
|
void TQProgressBar::drawContents( TQPainter *p )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const TQRect bar = contentsRect();
|
|
|
|
const TQRect bar = contentsRect();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQSharedDoubleBuffer buffer( p, bar.x(), bar.y(), bar.width(), bar.height() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQPoint pn = backgroundOffset();
|
|
|
|
|
|
|
|
buffer.painter()->setBrushOrigin( -pn.x(), -pn.y() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const TQPixmap *bpm = paletteBackgroundPixmap();
|
|
|
|
|
|
|
|
if ( bpm ) {
|
|
|
|
|
|
|
|
buffer.painter()->fillRect( bar, TQBrush( paletteBackgroundColor(), *bpm ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
buffer.painter()->fillRect( bar, paletteBackgroundColor() );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer.painter()->setFont( p->font() );
|
|
|
|
|
|
|
|
|
|
|
|
TQSharedDoubleBuffer buffer( p, bar.x(), bar.y(), bar.width(), bar.height() );
|
|
|
|
TQStyle::SFlags flags = TQStyle::Style_Default;
|
|
|
|
|
|
|
|
if (isEnabled()) {
|
|
|
|
|
|
|
|
flags |= TQStyle::Style_Enabled;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasFocus()) {
|
|
|
|
|
|
|
|
flags |= TQStyle::Style_HasFocus;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasMouse()) {
|
|
|
|
|
|
|
|
flags |= TQStyle::Style_MouseOver;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQPoint pn = backgroundOffset();
|
|
|
|
style().drawControl(TQStyle::CE_ProgressBarGroove, buffer.painter(), this,
|
|
|
|
buffer.painter()->setBrushOrigin( -pn.x(), -pn.y() );
|
|
|
|
TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarGroove, this), this ),
|
|
|
|
|
|
|
|
colorGroup(), flags);
|
|
|
|
|
|
|
|
|
|
|
|
const TQPixmap *bpm = paletteBackgroundPixmap();
|
|
|
|
TQWMatrix oldMatrix = buffer.painter()->worldMatrix();
|
|
|
|
if ( bpm )
|
|
|
|
|
|
|
|
buffer.painter()->fillRect( bar, TQBrush( paletteBackgroundColor(), *bpm ) );
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
buffer.painter()->fillRect( bar, paletteBackgroundColor() );
|
|
|
|
|
|
|
|
buffer.painter()->setFont( p->font() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQStyle::SFlags flags = TQStyle::Style_Default;
|
|
|
|
TQStyleControlElementData ceData = populateControlElementDataFromWidget(this, TQStyleOption());
|
|
|
|
if (isEnabled())
|
|
|
|
TQStyle::ControlElementFlags elementFlags = getControlElementFlagsForObject(this, ceData.widgetObjectTypes, TQStyleOption());
|
|
|
|
flags |= TQStyle::Style_Enabled;
|
|
|
|
|
|
|
|
if (hasFocus())
|
|
|
|
|
|
|
|
flags |= TQStyle::Style_HasFocus;
|
|
|
|
|
|
|
|
if (hasMouse())
|
|
|
|
|
|
|
|
flags |= TQStyle::Style_MouseOver;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
style().drawControl(TQStyle::CE_ProgressBarGroove, buffer.painter(), this,
|
|
|
|
// Draw contents
|
|
|
|
TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarGroove, this), this ),
|
|
|
|
if (m_orientation == TQt::Vertical) {
|
|
|
|
colorGroup(), flags);
|
|
|
|
// If oriented vertically, apply a 90 degree rotation matrix to the painter
|
|
|
|
|
|
|
|
TQWMatrix m;
|
|
|
|
|
|
|
|
|
|
|
|
style().drawControl(TQStyle::CE_ProgressBarContents, buffer.painter(), this,
|
|
|
|
// // Upside down
|
|
|
|
TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarContents, this), this ),
|
|
|
|
// m.rotate(90.0);
|
|
|
|
colorGroup(), flags);
|
|
|
|
// m.translate(0, (bar.width())*(-1.0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Right side up
|
|
|
|
|
|
|
|
m.rotate(-90.0);
|
|
|
|
|
|
|
|
m.translate((bar.height())*(-1.0), 0);
|
|
|
|
|
|
|
|
|
|
|
|
if (percentageVisible())
|
|
|
|
buffer.painter()->setWorldMatrix(m, TRUE);
|
|
|
|
style().drawControl(TQStyle::CE_ProgressBarLabel, buffer.painter(), this,
|
|
|
|
|
|
|
|
TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarLabel, this), this ),
|
|
|
|
ceData.rect = TQRect(ceData.rect.y(), ceData.rect.x(), ceData.rect.height(), ceData.rect.width());
|
|
|
|
colorGroup(), flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
style().drawControl(TQStyle::CE_ProgressBarContents, buffer.painter(), ceData, elementFlags,
|
|
|
|
|
|
|
|
TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarContents, ceData, elementFlags, this), ceData, elementFlags),
|
|
|
|
|
|
|
|
colorGroup(), flags, TQStyleOption(), this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buffer.painter()->setWorldMatrix(oldMatrix, TRUE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (percentageVisible()) {
|
|
|
|
|
|
|
|
style().drawControl(TQStyle::CE_ProgressBarLabel, buffer.painter(), this,
|
|
|
|
|
|
|
|
TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarLabel, this), this ),
|
|
|
|
|
|
|
|
colorGroup(), flags);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|