20#include <progressbar.hxx>
22#include <com/sun/star/awt/XGraphics.hpp>
27using namespace ::
cppu;
38 : BaseControl ( rxContext )
50ProgressBar::~ProgressBar()
56Any SAL_CALL ProgressBar::queryInterface(
const Type& rType )
60 Any aReturn ( ::cppu::queryInterface( rType ,
61 static_cast< XControlModel*
> (
this ) ,
62 static_cast< XProgressBar*
> (
this )
67 if ( !aReturn.hasValue() )
70 aReturn = BaseControl::queryInterface( rType );
78void SAL_CALL ProgressBar::acquire() noexcept
84 BaseControl::acquire();
89void SAL_CALL ProgressBar::release() noexcept
95 BaseControl::release();
100Sequence< Type > SAL_CALL ProgressBar::getTypes()
102 static OTypeCollection ourTypeCollection(
105 BaseControl::getTypes() );
107 return ourTypeCollection.getTypes();
112void SAL_CALL ProgressBar::setForegroundColor( sal_Int32 nColor )
121 impl_paint ( 0, 0, impl_getGraphicsPeer() );
126void SAL_CALL ProgressBar::setBackgroundColor ( sal_Int32 nColor )
135 impl_paint ( 0, 0, impl_getGraphicsPeer() );
140void SAL_CALL ProgressBar::setValue ( sal_Int32 nValue )
151 DBG_ASSERT ( ((
nValue >= m_nMinRange ) && (
nValue <= m_nMaxRange )),
"ProgressBar::setValue()\nNot valid value.\n" );
155 (
nValue >= m_nMinRange ) &&
163 impl_paint ( 0, 0, impl_getGraphicsPeer() );
169void SAL_CALL ProgressBar::setRange ( sal_Int32 nMin, sal_Int32 nMax )
179 DBG_ASSERT ( ( nMin != nMax ) ,
"ProgressBar::setRange()\nValues for MIN and MAX are the same. This is not allowed!\n" );
199 if (m_nMinRange >= m_nValue || m_nValue >= m_nMaxRange)
200 m_nValue = m_nMinRange;
211sal_Int32 SAL_CALL ProgressBar::getValue ()
221void SAL_CALL ProgressBar::setPosSize (
232 BaseControl::setPosSize (nX, nY, nWidth, nHeight, nFlags);
236 ( nWidth != aBasePosSize.Width ) ||
237 ( nHeight != aBasePosSize.Height )
240 impl_recalcRange ( );
241 impl_paint ( 0, 0, impl_getGraphicsPeer () );
247sal_Bool SAL_CALL ProgressBar::setModel(
const Reference< XControlModel >& )
255Reference< XControlModel > SAL_CALL ProgressBar::getModel()
258 return Reference< XControlModel >();
263void ProgressBar::impl_paint ( sal_Int32 nX, sal_Int32 nY,
const Reference< XGraphics > & rGraphics )
266 DBG_ASSERT ( rGraphics.is(),
"ProgressBar::paint()\nCalled with invalid Reference< XGraphics > ." );
270 if ( !rGraphics.is () )
277 rGraphics->setFillColor ( sal_Int32(m_nBackgroundColor) );
278 rGraphics->setLineColor ( sal_Int32(m_nBackgroundColor) );
279 rGraphics->drawRect ( nX, nY, impl_getWidth(), impl_getHeight() );
282 rGraphics->setFillColor ( sal_Int32(m_nForegroundColor) );
283 rGraphics->setLineColor ( sal_Int32(m_nForegroundColor) );
285 sal_Int32 nBlockStart = 0;
286 sal_Int32 nBlockCount = m_nBlockValue!=0.00 ?
static_cast<sal_Int32
>((m_nValue-m_nMinRange)/m_nBlockValue) : 0;
295 for ( sal_Int32
i=1;
i<=nBlockCount; ++
i )
300 rGraphics->drawRect (nBlockStart, nY+
PROGRESSBAR_FREESPACE, m_aBlockSize.Width, m_aBlockSize.Height);
302 nBlockStart += m_aBlockSize.Width;
310 nBlockStart = nY+impl_getHeight();
311 nBlockStart -= m_aBlockSize.Height;
313 for ( sal_Int32
i=1;
i<=nBlockCount; ++
i )
318 rGraphics->drawRect (nX+
PROGRESSBAR_FREESPACE, nBlockStart, m_aBlockSize.Width, m_aBlockSize.Height);
320 nBlockStart -= m_aBlockSize.Height;
326 rGraphics->drawLine ( nX, nY, impl_getWidth(), nY );
327 rGraphics->drawLine ( nX, nY, nX , impl_getHeight() );
330 rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY );
331 rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX , impl_getHeight()-1 );
336void ProgressBar::impl_recalcRange ()
340 sal_Int32 nWindowWidth = impl_getWidth();
341 sal_Int32 nWindowHeight = impl_getHeight();
346 if( nWindowWidth > nWindowHeight )
348 m_bHorizontal =
true;
350 fBlockWidth = fBlockHeight;
355 m_bHorizontal =
false;
357 fBlockHeight = fBlockWidth;
361 double fRange = m_nMaxRange-m_nMinRange;
362 double fBlockValue = fRange/fMaxBlocks;
364 m_nBlockValue = fBlockValue;
365 m_aBlockSize.Height =
static_cast<sal_Int32
>(fBlockHeight);
366 m_aBlockSize.Width =
static_cast<sal_Int32
>(fBlockWidth);
371extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
373 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const&)
ProgressBar(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
#define DBG_ASSERT(sCon, aError)
constexpr Color PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR
constexpr bool PROGRESSBAR_DEFAULT_HORIZONTAL
constexpr auto PROGRESSBAR_DEFAULT_VALUE
constexpr auto PROGRESSBAR_DEFAULT_MAXRANGE
constexpr sal_Int32 PROGRESSBAR_LINECOLOR_BRIGHT
constexpr sal_Int32 PROGRESSBAR_LINECOLOR_SHADOW
constexpr auto PROGRESSBAR_DEFAULT_BLOCKVALUE
constexpr auto PROGRESSBAR_DEFAULT_MINRANGE
constexpr Color PROGRESSBAR_DEFAULT_BACKGROUNDCOLOR
constexpr auto PROGRESSBAR_FREESPACE
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * stardiv_UnoControls_ProgressBar_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
#define PROGRESSBAR_DEFAULT_BLOCKDIMENSION