2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 07:32:15 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:32:15 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:32:15 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:32:15 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:32:15 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:32:15 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 10:53:07 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_vcl.hxx"
|
2007-06-27 19:06:03 +00:00
|
|
|
#include <vcl/decoview.hxx>
|
|
|
|
#include <vcl/event.hxx>
|
|
|
|
#include <vcl/fixed.hxx>
|
2009-09-14 12:09:22 +00:00
|
|
|
#include <vcl/controldata.hxx>
|
2008-07-22 06:50:36 +00:00
|
|
|
#include <vcl/window.h>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-01-06 12:19:05 +00:00
|
|
|
#include <tools/rc.h>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2000-12-07 13:36:20 +00:00
|
|
|
#define FIXEDLINE_TEXT_BORDER 4
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#define FIXEDTEXT_VIEW_STYLE (WB_3DLOOK | \
|
|
|
|
WB_LEFT | WB_CENTER | WB_RIGHT | \
|
|
|
|
WB_TOP | WB_VCENTER | WB_BOTTOM | \
|
|
|
|
WB_WORDBREAK | WB_NOLABEL | \
|
|
|
|
WB_INFO | WB_PATHELLIPSIS)
|
|
|
|
#define FIXEDLINE_VIEW_STYLE (WB_3DLOOK | WB_NOLABEL)
|
|
|
|
#define FIXEDBITMAP_VIEW_STYLE (WB_3DLOOK | \
|
|
|
|
WB_LEFT | WB_CENTER | WB_RIGHT | \
|
|
|
|
WB_TOP | WB_VCENTER | WB_BOTTOM | \
|
|
|
|
WB_SCALE)
|
|
|
|
#define FIXEDIMAGE_VIEW_STYLE (WB_3DLOOK | \
|
|
|
|
WB_LEFT | WB_CENTER | WB_RIGHT | \
|
|
|
|
WB_TOP | WB_VCENTER | WB_BOTTOM | \
|
|
|
|
WB_SCALE)
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
static Point ImplCalcPos( WinBits nStyle, const Point& rPos,
|
|
|
|
const Size& rObjSize, const Size& rWinSize )
|
|
|
|
{
|
|
|
|
long nX;
|
|
|
|
long nY;
|
|
|
|
|
|
|
|
if ( nStyle & WB_LEFT )
|
|
|
|
nX = 0;
|
|
|
|
else if ( nStyle & WB_RIGHT )
|
|
|
|
nX = rWinSize.Width()-rObjSize.Width();
|
|
|
|
else
|
|
|
|
nX = (rWinSize.Width()-rObjSize.Width())/2;
|
|
|
|
|
|
|
|
if ( nStyle & WB_TOP )
|
|
|
|
nY = 0;
|
|
|
|
else if ( nStyle & WB_BOTTOM )
|
2004-09-08 14:04:40 +00:00
|
|
|
nY = rWinSize.Height()-rObjSize.Height();
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
nY = (rWinSize.Height()-rObjSize.Height())/2;
|
|
|
|
|
|
|
|
if ( nStyle & WB_TOPLEFTVISIBLE )
|
|
|
|
{
|
|
|
|
if ( nX < 0 )
|
|
|
|
nX = 0;
|
|
|
|
if ( nY < 0 )
|
|
|
|
nY = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Point aPos( nX+rPos.X(), nY+rPos.Y() );
|
|
|
|
return aPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
void FixedText::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
|
|
|
nStyle = ImplInitStyle( nStyle );
|
|
|
|
Control::ImplInit( pParent, nStyle, NULL );
|
|
|
|
ImplInitSettings( TRUE, TRUE, TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
WinBits FixedText::ImplInitStyle( WinBits nStyle )
|
|
|
|
{
|
|
|
|
if ( !(nStyle & WB_NOGROUP) )
|
|
|
|
nStyle |= WB_GROUP;
|
|
|
|
return nStyle;
|
|
|
|
}
|
|
|
|
|
2009-09-14 12:09:22 +00:00
|
|
|
// -----------------------------------------------------------------
|
|
|
|
|
|
|
|
const Font& FixedText::GetCanonicalFont( const StyleSettings& _rStyle ) const
|
|
|
|
{
|
|
|
|
return ( GetStyle() & WB_INFO ) ? _rStyle.GetInfoFont() : _rStyle.GetLabelFont();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
const Color& FixedText::GetCanonicalTextColor( const StyleSettings& _rStyle ) const
|
|
|
|
{
|
|
|
|
return ( GetStyle() & WB_INFO ) ? _rStyle.GetInfoTextColor() : _rStyle.GetLabelTextColor();
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedText::ImplInitSettings( BOOL bFont,
|
|
|
|
BOOL bForeground, BOOL bBackground )
|
|
|
|
{
|
2009-09-14 12:09:22 +00:00
|
|
|
Control::ImplInitSettings( bFont, bForeground );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( bBackground )
|
|
|
|
{
|
|
|
|
Window* pParent = GetParent();
|
|
|
|
if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
|
|
|
|
{
|
|
|
|
EnableChildTransparentMode( TRUE );
|
|
|
|
SetParentClipMode( PARENTCLIPMODE_NOCLIP );
|
|
|
|
SetPaintTransparent( TRUE );
|
|
|
|
SetBackground();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableChildTransparentMode( FALSE );
|
|
|
|
SetParentClipMode( 0 );
|
|
|
|
SetPaintTransparent( FALSE );
|
|
|
|
|
|
|
|
if ( IsControlBackground() )
|
|
|
|
SetBackground( GetControlBackground() );
|
|
|
|
else
|
|
|
|
SetBackground( pParent->GetBackground() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FixedText::FixedText( Window* pParent, WinBits nStyle ) :
|
|
|
|
Control( WINDOW_FIXEDTEXT )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FixedText::FixedText( Window* pParent, const ResId& rResId ) :
|
|
|
|
Control( WINDOW_FIXEDTEXT )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_TEXT );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-07-22 06:50:36 +00:00
|
|
|
FixedText::FixedText( Window* pParent, const ResId& rResId, bool bDisableAccessibleLabelForRelation ) :
|
|
|
|
Control( WINDOW_FIXEDTEXT )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_TEXT );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
if ( bDisableAccessibleLabelForRelation )
|
|
|
|
ImplGetWindowImpl()->mbDisableAccessibleLabelForRelation = TRUE;
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
USHORT FixedText::ImplGetTextStyle( WinBits nWinStyle )
|
|
|
|
{
|
2002-10-17 13:47:00 +00:00
|
|
|
USHORT nTextStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_ENDELLIPSIS;
|
|
|
|
|
|
|
|
if( ! (nWinStyle & WB_NOMULTILINE) )
|
|
|
|
nTextStyle |= TEXT_DRAW_MULTILINE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( nWinStyle & WB_RIGHT )
|
|
|
|
nTextStyle |= TEXT_DRAW_RIGHT;
|
|
|
|
else if ( nWinStyle & WB_CENTER )
|
|
|
|
nTextStyle |= TEXT_DRAW_CENTER;
|
|
|
|
else
|
|
|
|
nTextStyle |= TEXT_DRAW_LEFT;
|
|
|
|
if ( nWinStyle & WB_BOTTOM )
|
|
|
|
nTextStyle |= TEXT_DRAW_BOTTOM;
|
|
|
|
else if ( nWinStyle & WB_VCENTER )
|
|
|
|
nTextStyle |= TEXT_DRAW_VCENTER;
|
|
|
|
else
|
|
|
|
nTextStyle |= TEXT_DRAW_TOP;
|
|
|
|
if ( nWinStyle & WB_WORDBREAK )
|
2008-08-19 08:58:41 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
nTextStyle |= TEXT_DRAW_WORDBREAK;
|
2008-12-01 12:31:27 +00:00
|
|
|
if ( (nWinStyle & WB_HYPHENATION ) == WB_HYPHENATION )
|
2008-08-19 08:58:41 +00:00
|
|
|
nTextStyle |= TEXT_DRAW_WORDBREAK_HYPHENATION;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nWinStyle & WB_NOLABEL )
|
|
|
|
nTextStyle &= ~TEXT_DRAW_MNEMONIC;
|
|
|
|
|
|
|
|
return nTextStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedText::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags,
|
2002-04-29 16:46:18 +00:00
|
|
|
const Point& rPos, const Size& rSize,
|
|
|
|
bool bFillLayout
|
|
|
|
) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
WinBits nWinStyle = GetStyle();
|
|
|
|
XubString aText( GetText() );
|
|
|
|
USHORT nTextStyle = FixedText::ImplGetTextStyle( nWinStyle );
|
2005-01-31 08:17:14 +00:00
|
|
|
Point aPos = rPos;
|
|
|
|
|
|
|
|
if ( nWinStyle & WB_EXTRAOFFSET )
|
|
|
|
aPos.X() += 2;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( nWinStyle & WB_PATHELLIPSIS )
|
|
|
|
{
|
|
|
|
nTextStyle &= ~(TEXT_DRAW_ENDELLIPSIS | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK);
|
|
|
|
nTextStyle |= TEXT_DRAW_PATHELLIPSIS;
|
|
|
|
}
|
|
|
|
if ( nDrawFlags & WINDOW_DRAW_NOMNEMONIC )
|
|
|
|
{
|
|
|
|
if ( nTextStyle & TEXT_DRAW_MNEMONIC )
|
|
|
|
{
|
|
|
|
aText = GetNonMnemonicString( aText );
|
|
|
|
nTextStyle &= ~TEXT_DRAW_MNEMONIC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !(nDrawFlags & WINDOW_DRAW_NODISABLE) )
|
|
|
|
{
|
|
|
|
if ( !IsEnabled() )
|
|
|
|
nTextStyle |= TEXT_DRAW_DISABLE;
|
|
|
|
}
|
|
|
|
if ( (nDrawFlags & WINDOW_DRAW_MONO) ||
|
|
|
|
(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
|
|
|
|
nTextStyle |= TEXT_DRAW_MONO;
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
if( bFillLayout )
|
2009-09-14 12:09:22 +00:00
|
|
|
mpControlData->mpLayoutData->m_aDisplayText = String();
|
|
|
|
|
#b6875455#
refactor the Control's "draw with reference device" functionality
In particular, use the existing DrawText/ImplGetTextLines methods, but provide
them with an optional ITextLayout interface, which replaces the usage of GetTextWidth and DrawText( Point, ... )
This way, the ref-device-rendering benefits from the existing implementations in DrawText( Rectangle, ... ),
in particular, it now respects all kind of TEXT_DRAW_ flags, i.e. alignment, word breaks, multi line text,
disabled drawing, etc.
2009-09-17 21:26:57 +00:00
|
|
|
Rectangle aRect( Rectangle( aPos, rSize ) );
|
|
|
|
DrawControlText( *pDev, aRect, aText, nTextStyle,
|
2009-09-14 12:09:22 +00:00
|
|
|
bFillLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL,
|
|
|
|
bFillLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL
|
|
|
|
);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2006-06-19 18:17:09 +00:00
|
|
|
void FixedText::Paint( const Rectangle& )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplDraw( this, 0, Point(), GetOutputSizePixel() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedText::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
|
|
|
|
ULONG nFlags )
|
|
|
|
{
|
2001-03-27 15:12:36 +00:00
|
|
|
ImplInitSettings( TRUE, TRUE, TRUE );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Point aPos = pDev->LogicToPixel( rPos );
|
|
|
|
Size aSize = pDev->LogicToPixel( rSize );
|
|
|
|
Font aFont = GetDrawPixelFont( pDev );
|
|
|
|
|
|
|
|
pDev->Push();
|
|
|
|
pDev->SetMapMode();
|
|
|
|
pDev->SetFont( aFont );
|
|
|
|
if ( nFlags & WINDOW_DRAW_MONO )
|
|
|
|
pDev->SetTextColor( Color( COL_BLACK ) );
|
|
|
|
else
|
|
|
|
pDev->SetTextColor( GetTextColor() );
|
|
|
|
pDev->SetTextFillColor();
|
|
|
|
|
2004-09-08 16:47:48 +00:00
|
|
|
BOOL bBorder = !(nFlags & WINDOW_DRAW_NOBORDER ) && (GetStyle() & WB_BORDER);
|
|
|
|
BOOL bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && IsControlBackground();
|
|
|
|
if ( bBorder || bBackground )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-09-08 16:47:48 +00:00
|
|
|
Rectangle aRect( aPos, aSize );
|
|
|
|
if ( bBorder )
|
|
|
|
{
|
|
|
|
ImplDrawFrame( pDev, aRect );
|
|
|
|
}
|
|
|
|
if ( bBackground )
|
|
|
|
{
|
|
|
|
pDev->SetFillColor( GetControlBackground() );
|
|
|
|
pDev->DrawRect( aRect );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ImplDraw( pDev, nFlags, aPos, aSize );
|
|
|
|
pDev->Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedText::Resize()
|
|
|
|
{
|
2002-05-08 15:05:42 +00:00
|
|
|
Control::Resize();
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedText::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
Control::StateChanged( nType );
|
|
|
|
|
|
|
|
if ( (nType == STATE_CHANGE_ENABLE) ||
|
|
|
|
(nType == STATE_CHANGE_TEXT) ||
|
|
|
|
(nType == STATE_CHANGE_UPDATEMODE) )
|
|
|
|
{
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_STYLE )
|
|
|
|
{
|
|
|
|
SetStyle( ImplInitStyle( GetStyle() ) );
|
|
|
|
if ( (GetPrevStyle() & FIXEDTEXT_VIEW_STYLE) !=
|
|
|
|
(GetStyle() & FIXEDTEXT_VIEW_STYLE) )
|
|
|
|
{
|
|
|
|
ImplInitSettings( TRUE, FALSE, FALSE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( (nType == STATE_CHANGE_ZOOM) ||
|
|
|
|
(nType == STATE_CHANGE_CONTROLFONT) )
|
|
|
|
{
|
|
|
|
ImplInitSettings( TRUE, FALSE, FALSE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
|
|
|
|
{
|
|
|
|
ImplInitSettings( FALSE, TRUE, FALSE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
|
|
|
|
{
|
|
|
|
ImplInitSettings( FALSE, FALSE, TRUE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedText::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
Control::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
|
|
|
|
(rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
|
|
|
|
((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE)) )
|
|
|
|
{
|
|
|
|
ImplInitSettings( TRUE, TRUE, TRUE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-01-14 12:05:27 +00:00
|
|
|
Size FixedText::CalcMinimumTextSize( Control const *pControl, long nMaxWidth )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2008-01-14 12:05:27 +00:00
|
|
|
USHORT nStyle = ImplGetTextStyle( pControl->GetStyle() );
|
|
|
|
if ( !( pControl->GetStyle() & WB_NOLABEL ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
nStyle |= TEXT_DRAW_MNEMONIC;
|
|
|
|
|
2008-01-14 12:05:27 +00:00
|
|
|
Size aSize = pControl->GetTextRect( Rectangle( Point(), Size( (nMaxWidth ? nMaxWidth : 0x7fffffff), 0x7fffffff ) ),
|
|
|
|
pControl->GetText(), nStyle ).GetSize();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2008-01-14 12:05:27 +00:00
|
|
|
if ( pControl->GetStyle() & WB_EXTRAOFFSET )
|
2005-01-31 08:17:14 +00:00
|
|
|
aSize.Width() += 2;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// GetTextRect verkraftet keinen leeren String:
|
|
|
|
if ( aSize.Width() < 0 )
|
|
|
|
aSize.Width() = 0;
|
|
|
|
if ( aSize.Height() <= 0 )
|
2008-01-14 12:05:27 +00:00
|
|
|
aSize.Height() = pControl->GetTextHeight();
|
|
|
|
|
|
|
|
return aSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
Size FixedText::CalcMinimumSize( long nMaxWidth ) const
|
|
|
|
{
|
|
|
|
return CalcWindowSize( CalcMinimumTextSize ( this, nMaxWidth ) );
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2008-01-14 12:05:27 +00:00
|
|
|
Size FixedText::GetOptimalSize(WindowSizeType eType) const
|
|
|
|
{
|
|
|
|
switch (eType) {
|
|
|
|
case WINDOWSIZE_MINIMUM:
|
|
|
|
return CalcMinimumSize();
|
|
|
|
default:
|
|
|
|
return Control::GetOptimalSize( eType );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedText::FillLayoutData() const
|
|
|
|
{
|
2009-09-14 12:09:22 +00:00
|
|
|
mpControlData->mpLayoutData = new vcl::ControlLayoutData();
|
2002-04-29 16:46:18 +00:00
|
|
|
ImplDraw( const_cast<FixedText*>(this), 0, Point(), GetOutputSizePixel(), true );
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
void FixedLine::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
|
|
|
nStyle = ImplInitStyle( nStyle );
|
|
|
|
Control::ImplInit( pParent, nStyle, NULL );
|
|
|
|
ImplInitSettings( TRUE, TRUE, TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
WinBits FixedLine::ImplInitStyle( WinBits nStyle )
|
|
|
|
{
|
|
|
|
if ( !(nStyle & WB_NOGROUP) )
|
|
|
|
nStyle |= WB_GROUP;
|
|
|
|
return nStyle;
|
|
|
|
}
|
|
|
|
|
2009-09-14 12:09:22 +00:00
|
|
|
// -----------------------------------------------------------------
|
|
|
|
|
|
|
|
const Font& FixedLine::GetCanonicalFont( const StyleSettings& _rStyle ) const
|
|
|
|
{
|
|
|
|
return _rStyle.GetGroupFont();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
const Color& FixedLine::GetCanonicalTextColor( const StyleSettings& _rStyle ) const
|
|
|
|
{
|
|
|
|
return _rStyle.GetGroupTextColor();
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedLine::ImplInitSettings( BOOL bFont,
|
|
|
|
BOOL bForeground, BOOL bBackground )
|
|
|
|
{
|
2009-09-14 12:09:22 +00:00
|
|
|
Control::ImplInitSettings( bFont, bForeground );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( bBackground )
|
|
|
|
{
|
|
|
|
Window* pParent = GetParent();
|
|
|
|
if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
|
|
|
|
{
|
|
|
|
EnableChildTransparentMode( TRUE );
|
|
|
|
SetParentClipMode( PARENTCLIPMODE_NOCLIP );
|
|
|
|
SetPaintTransparent( TRUE );
|
|
|
|
SetBackground();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableChildTransparentMode( FALSE );
|
|
|
|
SetParentClipMode( 0 );
|
|
|
|
SetPaintTransparent( FALSE );
|
|
|
|
|
|
|
|
if ( IsControlBackground() )
|
|
|
|
SetBackground( GetControlBackground() );
|
|
|
|
else
|
|
|
|
SetBackground( pParent->GetBackground() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
void FixedLine::ImplDraw( bool bLayout )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Size aOutSize = GetOutputSizePixel();
|
|
|
|
String aText = GetText();
|
|
|
|
WinBits nWinStyle = GetStyle();
|
2009-09-14 12:09:22 +00:00
|
|
|
MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
|
|
|
|
String* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-01-18 15:54:29 +01:00
|
|
|
DecorationView aDecoView( this );
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !aText.Len() || (nWinStyle & WB_VERT) )
|
|
|
|
{
|
2002-04-29 16:46:18 +00:00
|
|
|
if( !pVector )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-09-08 14:04:40 +00:00
|
|
|
long nX = 0;
|
|
|
|
long nY = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( nWinStyle & WB_VERT )
|
2002-04-29 16:46:18 +00:00
|
|
|
{
|
|
|
|
nX = (aOutSize.Width()-1)/2;
|
2010-01-18 15:54:29 +01:00
|
|
|
aDecoView.DrawSeparator( Point( nX, 0 ), Point( nX, aOutSize.Height()-1 ) );
|
2002-04-29 16:46:18 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2002-04-29 16:46:18 +00:00
|
|
|
{
|
|
|
|
nY = (aOutSize.Height()-1)/2;
|
2010-01-18 15:54:29 +01:00
|
|
|
aDecoView.DrawSeparator( Point( 0, nY ), Point( aOutSize.Width()-1, nY ), false );
|
2002-04-29 16:46:18 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
USHORT nStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS;
|
2000-12-01 13:54:47 +00:00
|
|
|
Rectangle aRect( 0, 0, aOutSize.Width(), aOutSize.Height() );
|
2010-01-18 15:54:29 +01:00
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( !IsEnabled() )
|
|
|
|
nStyle |= TEXT_DRAW_DISABLE;
|
|
|
|
if ( GetStyle() & WB_NOLABEL )
|
|
|
|
nStyle &= ~TEXT_DRAW_MNEMONIC;
|
|
|
|
if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
|
|
|
|
nStyle |= TEXT_DRAW_MONO;
|
|
|
|
|
2009-09-14 12:09:22 +00:00
|
|
|
DrawControlText( *this, aRect, aText, nStyle, pVector, pDisplayText );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
if( !pVector )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-04-29 16:46:18 +00:00
|
|
|
long nTop = aRect.Top() + ((aRect.GetHeight()-1)/2);
|
2010-01-18 15:54:29 +01:00
|
|
|
aDecoView.DrawSeparator( Point( aRect.Right()+FIXEDLINE_TEXT_BORDER, nTop ), Point( aOutSize.Width()-1, nTop ), false );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-04-29 16:46:18 +00:00
|
|
|
|
|
|
|
FixedLine::FixedLine( Window* pParent, WinBits nStyle ) :
|
|
|
|
Control( WINDOW_FIXEDLINE )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
SetSizePixel( Size( 2, 2 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FixedLine::FixedLine( Window* pParent, const ResId& rResId ) :
|
|
|
|
Control( WINDOW_FIXEDLINE )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_FIXEDLINE );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedLine::FillLayoutData() const
|
|
|
|
{
|
2009-09-14 12:09:22 +00:00
|
|
|
mpControlData->mpLayoutData = new vcl::ControlLayoutData();
|
2002-04-29 16:46:18 +00:00
|
|
|
const_cast<FixedLine*>(this)->ImplDraw( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2006-06-19 18:17:09 +00:00
|
|
|
void FixedLine::Paint( const Rectangle& )
|
2002-04-29 16:46:18 +00:00
|
|
|
{
|
|
|
|
ImplDraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-06-19 18:17:09 +00:00
|
|
|
void FixedLine::Draw( OutputDevice*, const Point&, const Size&, ULONG )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedLine::Resize()
|
|
|
|
{
|
2002-05-08 15:05:42 +00:00
|
|
|
Control::Resize();
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedLine::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
Control::StateChanged( nType );
|
|
|
|
|
|
|
|
if ( (nType == STATE_CHANGE_ENABLE) ||
|
|
|
|
(nType == STATE_CHANGE_TEXT) ||
|
|
|
|
(nType == STATE_CHANGE_UPDATEMODE) )
|
|
|
|
{
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_STYLE )
|
|
|
|
{
|
|
|
|
SetStyle( ImplInitStyle( GetStyle() ) );
|
|
|
|
if ( (GetPrevStyle() & FIXEDLINE_VIEW_STYLE) !=
|
|
|
|
(GetStyle() & FIXEDLINE_VIEW_STYLE) )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( (nType == STATE_CHANGE_ZOOM) ||
|
|
|
|
(nType == STATE_CHANGE_STYLE) ||
|
|
|
|
(nType == STATE_CHANGE_CONTROLFONT) )
|
|
|
|
{
|
|
|
|
ImplInitSettings( TRUE, FALSE, FALSE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
|
|
|
|
{
|
|
|
|
ImplInitSettings( FALSE, TRUE, FALSE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
|
|
|
|
{
|
|
|
|
ImplInitSettings( FALSE, FALSE, TRUE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedLine::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
Control::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
|
|
|
|
(rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
|
|
|
|
((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE)) )
|
|
|
|
{
|
|
|
|
ImplInitSettings( TRUE, TRUE, TRUE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-14 12:05:27 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Size FixedLine::GetOptimalSize(WindowSizeType eType) const
|
|
|
|
{
|
|
|
|
switch (eType) {
|
|
|
|
case WINDOWSIZE_MINIMUM:
|
|
|
|
return CalcWindowSize( FixedText::CalcMinimumTextSize ( this ) );
|
|
|
|
default:
|
|
|
|
return Control::GetOptimalSize( eType );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
void FixedBitmap::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
|
|
|
nStyle = ImplInitStyle( nStyle );
|
|
|
|
Control::ImplInit( pParent, nStyle, NULL );
|
|
|
|
ImplInitSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
WinBits FixedBitmap::ImplInitStyle( WinBits nStyle )
|
|
|
|
{
|
|
|
|
if ( !(nStyle & WB_NOGROUP) )
|
|
|
|
nStyle |= WB_GROUP;
|
|
|
|
return nStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedBitmap::ImplInitSettings()
|
|
|
|
{
|
|
|
|
Window* pParent = GetParent();
|
|
|
|
if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
|
|
|
|
{
|
|
|
|
EnableChildTransparentMode( TRUE );
|
|
|
|
SetParentClipMode( PARENTCLIPMODE_NOCLIP );
|
|
|
|
SetPaintTransparent( TRUE );
|
|
|
|
SetBackground();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableChildTransparentMode( FALSE );
|
|
|
|
SetParentClipMode( 0 );
|
|
|
|
SetPaintTransparent( FALSE );
|
|
|
|
|
|
|
|
if ( IsControlBackground() )
|
|
|
|
SetBackground( GetControlBackground() );
|
|
|
|
else
|
|
|
|
SetBackground( pParent->GetBackground() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedBitmap::ImplLoadRes( const ResId& rResId )
|
|
|
|
{
|
|
|
|
Control::ImplLoadRes( rResId );
|
|
|
|
|
2005-01-03 16:39:30 +00:00
|
|
|
ULONG nObjMask = ReadLongRes();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( RSC_FIXEDBITMAP_BITMAP & nObjMask )
|
|
|
|
{
|
2007-04-26 08:28:17 +00:00
|
|
|
maBitmap = Bitmap( ResId( (RSHEADER_TYPE*)GetClassRes(), *rResId.GetResMgr() ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FixedBitmap::FixedBitmap( Window* pParent, WinBits nStyle ) :
|
|
|
|
Control( WINDOW_FIXEDBITMAP )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FixedBitmap::FixedBitmap( Window* pParent, const ResId& rResId ) :
|
|
|
|
Control( WINDOW_FIXEDBITMAP )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_FIXEDBITMAP );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FixedBitmap::~FixedBitmap()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedBitmap::ImplDraw( OutputDevice* pDev, ULONG /* nDrawFlags */,
|
|
|
|
const Point& rPos, const Size& rSize )
|
|
|
|
{
|
2002-04-18 07:11:17 +00:00
|
|
|
USHORT nStyle = 0;
|
|
|
|
Bitmap* pBitmap = &maBitmap;
|
|
|
|
Color aCol;
|
|
|
|
|
|
|
|
if( nStyle & IMAGE_DRAW_COLORTRANSFORM )
|
|
|
|
{
|
|
|
|
// only images support IMAGE_DRAW_COLORTRANSFORM
|
|
|
|
Image aImage( maBitmap );
|
|
|
|
if ( !(!aImage) )
|
|
|
|
{
|
|
|
|
if ( GetStyle() & WB_SCALE )
|
|
|
|
pDev->DrawImage( rPos, rSize, aImage, nStyle );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Point aPos = ImplCalcPos( GetStyle(), rPos, aImage.GetSizePixel(), rSize );
|
|
|
|
pDev->DrawImage( aPos, aImage, nStyle );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Haben wir ueberhaupt eine Bitmap
|
|
|
|
if ( !(!(*pBitmap)) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-04-18 07:11:17 +00:00
|
|
|
if ( GetStyle() & WB_SCALE )
|
|
|
|
pDev->DrawBitmap( rPos, rSize, *pBitmap );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Point aPos = ImplCalcPos( GetStyle(), rPos, pBitmap->GetSizePixel(), rSize );
|
|
|
|
pDev->DrawBitmap( aPos, *pBitmap );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2006-06-19 18:17:09 +00:00
|
|
|
void FixedBitmap::Paint( const Rectangle& )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplDraw( this, 0, Point(), GetOutputSizePixel() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedBitmap::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
|
|
|
|
ULONG nFlags )
|
|
|
|
{
|
|
|
|
Point aPos = pDev->LogicToPixel( rPos );
|
|
|
|
Size aSize = pDev->LogicToPixel( rSize );
|
|
|
|
Rectangle aRect( aPos, aSize );
|
|
|
|
|
|
|
|
pDev->Push();
|
|
|
|
pDev->SetMapMode();
|
|
|
|
|
|
|
|
// Border
|
|
|
|
if ( !(nFlags & WINDOW_DRAW_NOBORDER) && (GetStyle() & WB_BORDER) )
|
|
|
|
{
|
|
|
|
DecorationView aDecoView( pDev );
|
|
|
|
aRect = aDecoView.DrawFrame( aRect, FRAME_DRAW_DOUBLEIN );
|
|
|
|
}
|
|
|
|
pDev->IntersectClipRegion( aRect );
|
|
|
|
ImplDraw( pDev, nFlags, aRect.TopLeft(), aRect.GetSize() );
|
|
|
|
|
|
|
|
pDev->Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedBitmap::Resize()
|
|
|
|
{
|
2002-05-08 15:05:42 +00:00
|
|
|
Control::Resize();
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedBitmap::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
Control::StateChanged( nType );
|
|
|
|
|
|
|
|
if ( (nType == STATE_CHANGE_DATA) ||
|
|
|
|
(nType == STATE_CHANGE_UPDATEMODE) )
|
|
|
|
{
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_STYLE )
|
|
|
|
{
|
|
|
|
SetStyle( ImplInitStyle( GetStyle() ) );
|
|
|
|
if ( (GetPrevStyle() & FIXEDBITMAP_VIEW_STYLE) !=
|
|
|
|
(GetStyle() & FIXEDBITMAP_VIEW_STYLE) )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
|
|
|
|
{
|
|
|
|
ImplInitSettings();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedBitmap::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
Control::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
|
|
|
|
{
|
|
|
|
ImplInitSettings();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedBitmap::SetBitmap( const Bitmap& rBitmap )
|
|
|
|
{
|
|
|
|
maBitmap = rBitmap;
|
|
|
|
StateChanged( STATE_CHANGE_DATA );
|
|
|
|
}
|
|
|
|
|
2002-03-05 08:20:36 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-11-13 00:35:47 -08:00
|
|
|
BOOL FixedBitmap::SetModeBitmap( const Bitmap& rBitmap )
|
2002-03-05 08:20:36 +00:00
|
|
|
{
|
2010-11-13 00:35:47 -08:00
|
|
|
SetBitmap( rBitmap );
|
2002-03-05 08:20:36 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-11-13 00:35:47 -08:00
|
|
|
const Bitmap& FixedBitmap::GetModeBitmap( ) const
|
2002-03-05 08:20:36 +00:00
|
|
|
{
|
2010-11-13 00:35:47 -08:00
|
|
|
return maBitmap;
|
2002-03-05 08:20:36 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
void FixedImage::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
|
|
|
nStyle = ImplInitStyle( nStyle );
|
|
|
|
mbInUserDraw = FALSE;
|
|
|
|
Control::ImplInit( pParent, nStyle, NULL );
|
|
|
|
ImplInitSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
WinBits FixedImage::ImplInitStyle( WinBits nStyle )
|
|
|
|
{
|
|
|
|
if ( !(nStyle & WB_NOGROUP) )
|
|
|
|
nStyle |= WB_GROUP;
|
|
|
|
return nStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedImage::ImplInitSettings()
|
|
|
|
{
|
|
|
|
Window* pParent = GetParent();
|
|
|
|
if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
|
|
|
|
{
|
|
|
|
EnableChildTransparentMode( TRUE );
|
|
|
|
SetParentClipMode( PARENTCLIPMODE_NOCLIP );
|
|
|
|
SetPaintTransparent( TRUE );
|
|
|
|
SetBackground();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableChildTransparentMode( FALSE );
|
|
|
|
SetParentClipMode( 0 );
|
|
|
|
SetPaintTransparent( FALSE );
|
|
|
|
|
|
|
|
if ( IsControlBackground() )
|
|
|
|
SetBackground( GetControlBackground() );
|
|
|
|
else
|
|
|
|
SetBackground( pParent->GetBackground() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedImage::ImplLoadRes( const ResId& rResId )
|
|
|
|
{
|
|
|
|
Control::ImplLoadRes( rResId );
|
|
|
|
|
2005-01-03 16:39:30 +00:00
|
|
|
ULONG nObjMask = ReadLongRes();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( RSC_FIXEDIMAGE_IMAGE & nObjMask )
|
|
|
|
{
|
2007-04-26 08:28:17 +00:00
|
|
|
maImage = Image( ResId( (RSHEADER_TYPE*)GetClassRes(), *rResId.GetResMgr() ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FixedImage::FixedImage( Window* pParent, WinBits nStyle ) :
|
|
|
|
Control( WINDOW_FIXEDIMAGE )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FixedImage::FixedImage( Window* pParent, const ResId& rResId ) :
|
|
|
|
Control( WINDOW_FIXEDIMAGE )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_FIXEDIMAGE );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FixedImage::~FixedImage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedImage::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags,
|
|
|
|
const Point& rPos, const Size& rSize )
|
|
|
|
{
|
|
|
|
USHORT nStyle = 0;
|
|
|
|
if ( !(nDrawFlags & WINDOW_DRAW_NODISABLE) )
|
|
|
|
{
|
|
|
|
if ( !IsEnabled() )
|
|
|
|
nStyle |= IMAGE_DRAW_DISABLE;
|
|
|
|
}
|
|
|
|
|
2002-04-18 07:11:17 +00:00
|
|
|
Image *pImage = &maImage;
|
|
|
|
Color aCol;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// Haben wir ueberhaupt ein Image
|
2002-04-18 07:11:17 +00:00
|
|
|
if ( !(!(*pImage)) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( GetStyle() & WB_SCALE )
|
2002-04-18 07:11:17 +00:00
|
|
|
pDev->DrawImage( rPos, rSize, *pImage, nStyle );
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
{
|
2002-04-18 07:11:17 +00:00
|
|
|
Point aPos = ImplCalcPos( GetStyle(), rPos, pImage->GetSizePixel(), rSize );
|
|
|
|
pDev->DrawImage( aPos, *pImage, nStyle );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mbInUserDraw = TRUE;
|
|
|
|
UserDrawEvent aUDEvt( pDev, Rectangle( rPos, rSize ), 0, nStyle );
|
|
|
|
UserDraw( aUDEvt );
|
|
|
|
mbInUserDraw = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2006-06-19 18:17:09 +00:00
|
|
|
void FixedImage::Paint( const Rectangle& )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplDraw( this, 0, Point(), GetOutputSizePixel() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2009-07-22 17:16:34 +00:00
|
|
|
Size FixedImage::GetOptimalSize( WindowSizeType ) const
|
|
|
|
{
|
2010-11-13 00:35:47 -08:00
|
|
|
const Image* pImage = &maImage;
|
2009-07-22 17:16:34 +00:00
|
|
|
return pImage->GetSizePixel();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void FixedImage::UserDraw( const UserDrawEvent& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedImage::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
|
|
|
|
ULONG nFlags )
|
|
|
|
{
|
|
|
|
Point aPos = pDev->LogicToPixel( rPos );
|
|
|
|
Size aSize = pDev->LogicToPixel( rSize );
|
|
|
|
Rectangle aRect( aPos, aSize );
|
|
|
|
|
|
|
|
pDev->Push();
|
|
|
|
pDev->SetMapMode();
|
|
|
|
|
|
|
|
// Border
|
|
|
|
if ( !(nFlags & WINDOW_DRAW_NOBORDER) && (GetStyle() & WB_BORDER) )
|
|
|
|
{
|
2004-09-08 16:47:48 +00:00
|
|
|
ImplDrawFrame( pDev, aRect );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
pDev->IntersectClipRegion( aRect );
|
|
|
|
ImplDraw( pDev, nFlags, aRect.TopLeft(), aRect.GetSize() );
|
|
|
|
|
|
|
|
pDev->Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedImage::Resize()
|
|
|
|
{
|
2002-05-08 15:05:42 +00:00
|
|
|
Control::Resize();
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedImage::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
Control::StateChanged( nType );
|
|
|
|
|
|
|
|
if ( (nType == STATE_CHANGE_ENABLE) ||
|
|
|
|
(nType == STATE_CHANGE_DATA) ||
|
|
|
|
(nType == STATE_CHANGE_UPDATEMODE) )
|
|
|
|
{
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_STYLE )
|
|
|
|
{
|
|
|
|
SetStyle( ImplInitStyle( GetStyle() ) );
|
|
|
|
if ( (GetPrevStyle() & FIXEDIMAGE_VIEW_STYLE) !=
|
|
|
|
(GetStyle() & FIXEDIMAGE_VIEW_STYLE) )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
|
|
|
|
{
|
|
|
|
ImplInitSettings();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedImage::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
Control::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
|
|
|
|
{
|
|
|
|
ImplInitSettings();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FixedImage::SetImage( const Image& rImage )
|
|
|
|
{
|
|
|
|
if ( rImage != maImage )
|
|
|
|
{
|
|
|
|
maImage = rImage;
|
|
|
|
StateChanged( STATE_CHANGE_DATA );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-11-13 00:35:47 -08:00
|
|
|
BOOL FixedImage::SetModeImage( const Image& rImage )
|
2002-04-18 07:11:17 +00:00
|
|
|
{
|
2010-11-13 00:35:47 -08:00
|
|
|
SetImage( rImage );
|
2002-04-18 07:11:17 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-11-13 00:35:47 -08:00
|
|
|
const Image& FixedImage::GetModeImage( ) const
|
2002-04-18 07:11:17 +00:00
|
|
|
{
|
2010-11-13 00:35:47 -08:00
|
|
|
return maImage;
|
2002-04-18 07:11:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Point FixedImage::CalcImagePos( const Point& rPos,
|
|
|
|
const Size& rObjSize, const Size& rWinSize )
|
|
|
|
{
|
|
|
|
return ImplCalcPos( GetStyle(), rPos, rObjSize, rWinSize );
|
|
|
|
}
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|