2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 07:30:09 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:30:09 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:30:09 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:30:09 +00:00
|
|
|
* $RCSfile: button.cxx,v $
|
2008-05-30 07:06:39 +00:00
|
|
|
* $Revision: 1.61 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:30:09 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 07:30:09 +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:30:09 +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:30:09 +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:51:29 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_vcl.hxx"
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <tools/debug.hxx>
|
|
|
|
|
|
|
|
#ifndef _SV_SVIDS_HRC
|
2007-07-24 09:05:47 +00:00
|
|
|
#include <vcl/svids.hrc>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
2007-06-27 19:04:30 +00:00
|
|
|
#include <vcl/svdata.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef _SV_IAMGE_HXX
|
2007-06-27 19:04:30 +00:00
|
|
|
#include <vcl/image.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
2007-06-27 19:04:30 +00:00
|
|
|
#include <vcl/bitmap.hxx>
|
|
|
|
#include <vcl/bitmapex.hxx>
|
|
|
|
#include <vcl/decoview.hxx>
|
|
|
|
#include <vcl/event.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/dialog.hxx>
|
|
|
|
#include <vcl/fixed.hxx>
|
2004-01-06 12:15:55 +00:00
|
|
|
#include <tools/poly.hxx>
|
2007-06-27 19:04:30 +00:00
|
|
|
#include <vcl/button.hxx>
|
2007-07-24 09:05:47 +00:00
|
|
|
#include <vcl/window.h>
|
2007-06-27 19:04:30 +00:00
|
|
|
#include <vcl/controllayout.hxx>
|
2004-05-10 14:45:59 +00:00
|
|
|
#ifndef _SV_NATIVEWIDGET_HXX
|
2007-06-27 19:04:30 +00:00
|
|
|
#include <vcl/salnativewidgets.hxx>
|
2004-05-10 14:45:59 +00:00
|
|
|
#endif
|
2007-06-27 19:04:30 +00:00
|
|
|
#include <vcl/edit.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#ifndef _SV_RC_H
|
2004-01-06 12:15:55 +00:00
|
|
|
#include <tools/rc.h>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
|
2003-12-01 12:10:05 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
#define PUSHBUTTON_VIEW_STYLE (WB_3DLOOK | \
|
|
|
|
WB_LEFT | WB_CENTER | WB_RIGHT | \
|
|
|
|
WB_TOP | WB_VCENTER | WB_BOTTOM | \
|
|
|
|
WB_WORDBREAK | WB_NOLABEL | \
|
|
|
|
WB_DEFBUTTON | WB_NOLIGHTBORDER | \
|
2004-07-05 14:41:27 +00:00
|
|
|
WB_RECTSTYLE | WB_SMALLSTYLE | \
|
|
|
|
WB_TOGGLE )
|
2000-09-18 16:07:07 +00:00
|
|
|
#define RADIOBUTTON_VIEW_STYLE (WB_3DLOOK | \
|
|
|
|
WB_LEFT | WB_CENTER | WB_RIGHT | \
|
|
|
|
WB_TOP | WB_VCENTER | WB_BOTTOM | \
|
|
|
|
WB_WORDBREAK | WB_NOLABEL)
|
|
|
|
#define CHECKBOX_VIEW_STYLE (WB_3DLOOK | \
|
|
|
|
WB_LEFT | WB_CENTER | WB_RIGHT | \
|
|
|
|
WB_TOP | WB_VCENTER | WB_BOTTOM | \
|
|
|
|
WB_WORDBREAK | WB_NOLABEL)
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
class ImplCommonButtonData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Rectangle maFocusRect;
|
|
|
|
USHORT mnButtonState;
|
2005-02-25 12:10:56 +00:00
|
|
|
BOOL mbSmallSymbol;
|
2004-07-05 14:41:27 +00:00
|
|
|
|
|
|
|
Image maImage;
|
|
|
|
Image maImageHC;
|
|
|
|
BitmapEx* mpBitmapEx;
|
|
|
|
BitmapEx* mpBitmapExHC;
|
|
|
|
ImageAlign meImageAlign;
|
2005-02-25 12:10:56 +00:00
|
|
|
SymbolAlign meSymbolAlign;
|
2004-07-05 14:41:27 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
ImplCommonButtonData();
|
|
|
|
~ImplCommonButtonData();
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
ImplCommonButtonData::ImplCommonButtonData()
|
|
|
|
{
|
|
|
|
mnButtonState = 0;
|
2005-02-25 12:10:56 +00:00
|
|
|
mbSmallSymbol = FALSE;
|
2004-07-05 14:41:27 +00:00
|
|
|
|
|
|
|
mpBitmapEx = NULL;
|
|
|
|
mpBitmapExHC = NULL;
|
|
|
|
meImageAlign = IMAGEALIGN_TOP;
|
2005-02-25 12:10:56 +00:00
|
|
|
meSymbolAlign = SYMBOLALIGN_LEFT;
|
2004-07-05 14:41:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
ImplCommonButtonData::~ImplCommonButtonData()
|
|
|
|
{
|
|
|
|
delete mpBitmapEx;
|
|
|
|
delete mpBitmapExHC;
|
|
|
|
}
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Button::Button( WindowType nType ) :
|
|
|
|
Control( nType )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
mpButtonData = new ImplCommonButtonData;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Button::Button( Window* pParent, WinBits nStyle ) :
|
|
|
|
Control( WINDOW_BUTTON )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
mpButtonData = new ImplCommonButtonData;
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplInit( pParent, nStyle, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Button::Button( Window* pParent, const ResId& rResId ) :
|
|
|
|
Control( WINDOW_BUTTON )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_BUTTON );
|
2004-07-05 14:41:27 +00:00
|
|
|
mpButtonData = new ImplCommonButtonData;
|
2000-09-18 16:07:07 +00:00
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle, NULL );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
Button::~Button()
|
|
|
|
{
|
|
|
|
delete mpButtonData;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void Button::Click()
|
|
|
|
{
|
2004-10-22 11:12:18 +00:00
|
|
|
ImplCallEventListenersAndHandler( VCLEVENT_BUTTON_CLICK, maClickHdl, this );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
XubString Button::GetStandardText( StandardButtonType eButton )
|
|
|
|
{
|
2005-09-28 13:39:27 +00:00
|
|
|
static struct
|
|
|
|
{
|
|
|
|
sal_uInt32 nResId;
|
|
|
|
const char* pDefText;
|
|
|
|
} aResIdAry[BUTTON_COUNT] =
|
|
|
|
{
|
|
|
|
{ SV_BUTTONTEXT_OK, "~OK" },
|
|
|
|
{ SV_BUTTONTEXT_CANCEL, "~Cancel" },
|
|
|
|
{ SV_BUTTONTEXT_YES, "~Yes" },
|
|
|
|
{ SV_BUTTONTEXT_NO, "~No" },
|
|
|
|
{ SV_BUTTONTEXT_RETRY, "~Retry" },
|
|
|
|
{ SV_BUTTONTEXT_HELP, "~Help" },
|
|
|
|
{ SV_BUTTONTEXT_CLOSE, "~Close" },
|
|
|
|
{ SV_BUTTONTEXT_MORE, "~More" },
|
|
|
|
{ SV_BUTTONTEXT_IGNORE, "~Ignore" },
|
|
|
|
{ SV_BUTTONTEXT_ABORT, "~Abort" },
|
|
|
|
{ SV_BUTTONTEXT_LESS, "~Less" }
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
2005-09-28 13:39:27 +00:00
|
|
|
String aText;
|
|
|
|
ResMgr* pResMgr = ImplGetResMgr();
|
|
|
|
if( pResMgr )
|
|
|
|
{
|
2007-04-26 08:27:13 +00:00
|
|
|
ResId aResId( aResIdAry[(USHORT)eButton].nResId, *pResMgr );
|
2005-09-28 13:39:27 +00:00
|
|
|
aText = String( aResId );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ByteString aT( aResIdAry[(USHORT)eButton].pDefText );
|
|
|
|
aText = String( aT, RTL_TEXTENCODING_ASCII_US );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
return aText;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
XubString Button::GetStandardHelpText( StandardButtonType /* eButton */ )
|
|
|
|
{
|
|
|
|
XubString aHelpText;
|
|
|
|
return aHelpText;
|
|
|
|
}
|
2004-07-05 14:41:27 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
BOOL Button::SetModeImage( const Image& rImage, BmpColorMode eMode )
|
|
|
|
{
|
|
|
|
if( eMode == BMP_COLOR_NORMAL )
|
|
|
|
{
|
|
|
|
if ( rImage != mpButtonData->maImage )
|
|
|
|
{
|
|
|
|
delete mpButtonData->mpBitmapEx;
|
|
|
|
|
|
|
|
mpButtonData->mpBitmapEx = NULL;
|
|
|
|
mpButtonData->maImage = rImage;
|
|
|
|
|
|
|
|
StateChanged( STATE_CHANGE_DATA );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( eMode == BMP_COLOR_HIGHCONTRAST )
|
|
|
|
{
|
|
|
|
if( rImage != mpButtonData->maImageHC )
|
|
|
|
{
|
|
|
|
delete mpButtonData->mpBitmapExHC;
|
|
|
|
|
|
|
|
mpButtonData->mpBitmapExHC = NULL;
|
|
|
|
mpButtonData->maImageHC = rImage;
|
|
|
|
|
|
|
|
StateChanged( STATE_CHANGE_DATA );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
const Image Button::GetModeImage( BmpColorMode eMode ) const
|
|
|
|
{
|
|
|
|
if( eMode == BMP_COLOR_NORMAL )
|
|
|
|
{
|
|
|
|
return mpButtonData->maImage;
|
|
|
|
}
|
|
|
|
else if( eMode == BMP_COLOR_HIGHCONTRAST )
|
|
|
|
{
|
|
|
|
return mpButtonData->maImageHC;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return Image();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
BOOL Button::HasImage() const
|
|
|
|
{
|
|
|
|
return !!(mpButtonData->maImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void Button::SetImageAlign( ImageAlign eAlign )
|
|
|
|
{
|
|
|
|
if ( mpButtonData->meImageAlign != eAlign )
|
|
|
|
{
|
|
|
|
mpButtonData->meImageAlign = eAlign;
|
|
|
|
StateChanged( STATE_CHANGE_DATA );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
ImageAlign Button::GetImageAlign() const
|
|
|
|
{
|
|
|
|
return mpButtonData->meImageAlign;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
BOOL Button::SetModeBitmap( const BitmapEx& rBitmap, BmpColorMode eMode )
|
|
|
|
{
|
|
|
|
if ( SetModeImage( rBitmap, eMode ) )
|
|
|
|
{
|
|
|
|
if( eMode == BMP_COLOR_NORMAL )
|
|
|
|
{
|
|
|
|
if ( !mpButtonData->mpBitmapEx )
|
|
|
|
mpButtonData->mpBitmapEx = new BitmapEx( rBitmap );
|
|
|
|
}
|
|
|
|
else if ( eMode == BMP_COLOR_HIGHCONTRAST )
|
|
|
|
{
|
|
|
|
if ( !mpButtonData->mpBitmapExHC )
|
|
|
|
mpButtonData->mpBitmapExHC = new BitmapEx( rBitmap );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
BitmapEx Button::GetModeBitmap( BmpColorMode eMode ) const
|
|
|
|
{
|
|
|
|
BitmapEx aBmp;
|
|
|
|
|
|
|
|
if ( eMode == BMP_COLOR_NORMAL )
|
|
|
|
{
|
|
|
|
if ( mpButtonData->mpBitmapEx )
|
|
|
|
aBmp = *( mpButtonData->mpBitmapEx );
|
|
|
|
}
|
|
|
|
else if ( eMode == BMP_COLOR_HIGHCONTRAST )
|
|
|
|
{
|
|
|
|
if ( mpButtonData->mpBitmapExHC )
|
|
|
|
aBmp = *( mpButtonData->mpBitmapExHC );
|
|
|
|
}
|
|
|
|
|
|
|
|
return aBmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void Button::SetFocusRect( const Rectangle& rFocusRect )
|
|
|
|
{
|
|
|
|
ImplSetFocusRect( rFocusRect );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
const Rectangle& Button::GetFocusRect() const
|
|
|
|
{
|
|
|
|
return ImplGetFocusRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
USHORT Button::ImplGetTextStyle( XubString& rText, WinBits nWinStyle,
|
|
|
|
ULONG nDrawFlags )
|
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
USHORT nTextStyle = FixedText::ImplGetTextStyle( nWinStyle & ~WB_DEFBUTTON );
|
|
|
|
|
|
|
|
if ( nDrawFlags & WINDOW_DRAW_NOMNEMONIC )
|
|
|
|
{
|
|
|
|
if ( nTextStyle & TEXT_DRAW_MNEMONIC )
|
|
|
|
{
|
|
|
|
rText = GetNonMnemonicString( rText );
|
|
|
|
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;
|
|
|
|
|
|
|
|
return nTextStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Button::ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos,
|
|
|
|
Size& rSize, BOOL bLayout,
|
|
|
|
ULONG nImageSep, ULONG nDrawFlags,
|
|
|
|
USHORT nTextStyle, Rectangle *pSymbolRect )
|
|
|
|
{
|
|
|
|
XubString aText( GetText() );
|
|
|
|
BOOL bDrawImage = HasImage() && ! ( ImplGetButtonState() & BUTTON_DRAW_NOIMAGE );
|
|
|
|
BOOL bDrawText = aText.Len() && ! ( ImplGetButtonState() & BUTTON_DRAW_NOTEXT );
|
|
|
|
BOOL bHasSymbol = pSymbolRect ? TRUE : FALSE;
|
|
|
|
|
|
|
|
// No text and no image => nothing to do => return
|
|
|
|
if ( !bDrawImage && !bDrawText && !bHasSymbol )
|
|
|
|
return;
|
|
|
|
|
|
|
|
WinBits nWinStyle = GetStyle();
|
|
|
|
Rectangle aOutRect( rPos, rSize );
|
|
|
|
MetricVector *pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : NULL;
|
|
|
|
String *pDisplayText = bLayout ? &mpLayoutData->m_aDisplayText : NULL;
|
|
|
|
ImageAlign eImageAlign = mpButtonData->meImageAlign;
|
|
|
|
Size aImageSize = mpButtonData->maImage.GetSizePixel();
|
|
|
|
|
|
|
|
if ( ( nDrawFlags & WINDOW_DRAW_NOMNEMONIC ) &&
|
|
|
|
( nTextStyle & TEXT_DRAW_MNEMONIC ) )
|
|
|
|
{
|
|
|
|
aText = GetNonMnemonicString( aText );
|
|
|
|
nTextStyle &= ~TEXT_DRAW_MNEMONIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
aImageSize.Width() = CalcZoom( aImageSize.Width() );
|
|
|
|
aImageSize.Height() = CalcZoom( aImageSize.Height() );
|
|
|
|
|
|
|
|
// Drawing text or symbol only is simple, use style and output rectangle
|
|
|
|
if ( bHasSymbol && !bDrawImage && !bDrawText )
|
|
|
|
{
|
|
|
|
*pSymbolRect = aOutRect;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if ( bDrawText && !bDrawImage && !bHasSymbol )
|
|
|
|
{
|
|
|
|
aOutRect = pDev->GetTextRect( aOutRect, aText, nTextStyle );
|
|
|
|
rSize = aOutRect.GetSize();
|
|
|
|
rPos = aOutRect.TopLeft();
|
|
|
|
|
|
|
|
ImplSetFocusRect( aOutRect );
|
|
|
|
|
|
|
|
pDev->DrawText( aOutRect, aText, nTextStyle, pVector, pDisplayText );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for HC mode ( image only! )
|
|
|
|
Image *pImage = &(mpButtonData->maImage);
|
|
|
|
BitmapEx *pBitmapEx = mpButtonData->mpBitmapEx;
|
|
|
|
|
|
|
|
Color aBackCol;
|
|
|
|
if( !!(mpButtonData->maImageHC) && ImplGetCurrentBackgroundColor( aBackCol ) )
|
|
|
|
{
|
|
|
|
if( aBackCol.IsDark() )
|
|
|
|
{
|
|
|
|
pImage = &(mpButtonData->maImageHC);
|
|
|
|
pBitmapEx = mpButtonData->mpBitmapExHC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pBitmapEx && ( pDev->GetOutDevType() == OUTDEV_PRINTER ) )
|
|
|
|
{
|
|
|
|
// Die Groesse richtet sich nach dem Bildschirm, soll auf
|
|
|
|
// dem Drucker genau so aussehen...
|
|
|
|
MapMode aMap100thMM( MAP_100TH_MM );
|
|
|
|
aImageSize = PixelToLogic( aImageSize, aMap100thMM );
|
|
|
|
aImageSize = pDev->LogicToPixel( aImageSize, aMap100thMM );
|
|
|
|
}
|
|
|
|
|
|
|
|
Size aTextSize;
|
|
|
|
Size aSymbolSize;
|
|
|
|
Size aMax;
|
|
|
|
Point aImagePos = rPos;
|
|
|
|
Point aTextPos = rPos;
|
|
|
|
Rectangle aUnion = Rectangle( aImagePos, aImageSize );
|
|
|
|
Rectangle aSymbol;
|
|
|
|
long nSymbolHeight = 0;
|
|
|
|
|
|
|
|
if ( bDrawText || bHasSymbol )
|
|
|
|
{
|
|
|
|
// Get the size of the text output area ( the symbol will be drawn in
|
|
|
|
// this area as well, so the symbol rectangle will be calculated here, too )
|
|
|
|
|
|
|
|
Rectangle aRect = Rectangle( Point(), rSize );
|
|
|
|
Size aTSSize;
|
|
|
|
|
|
|
|
if ( bHasSymbol )
|
|
|
|
{
|
|
|
|
if ( bDrawText )
|
|
|
|
{
|
|
|
|
nSymbolHeight = pDev->GetTextHeight();
|
2005-02-25 12:10:56 +00:00
|
|
|
if ( mpButtonData->mbSmallSymbol )
|
|
|
|
nSymbolHeight = nSymbolHeight * 3 / 4;
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
aSymbol = Rectangle( Point(), Size( nSymbolHeight, nSymbolHeight ) );
|
|
|
|
ImplCalcSymbolRect( aSymbol );
|
2005-02-25 12:10:56 +00:00
|
|
|
aRect.Left() += 3 * nSymbolHeight / 2;
|
|
|
|
aTSSize.Width() = 3 * nSymbolHeight / 2;
|
2004-07-05 14:41:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aSymbol = Rectangle( Point(), rSize );
|
|
|
|
ImplCalcSymbolRect( aSymbol );
|
|
|
|
aTSSize.Width() = aSymbol.GetWidth();
|
|
|
|
}
|
|
|
|
aTSSize.Height() = aSymbol.GetHeight();
|
|
|
|
aSymbolSize = aSymbol.GetSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bDrawText )
|
|
|
|
{
|
|
|
|
if ( ( eImageAlign == IMAGEALIGN_LEFT_TOP ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_LEFT ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_LEFT_BOTTOM ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_RIGHT_TOP ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_RIGHT ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_RIGHT_BOTTOM ) )
|
|
|
|
{
|
|
|
|
aRect.Right() -= ( aImageSize.Width() + nImageSep );
|
|
|
|
}
|
|
|
|
else if ( ( eImageAlign == IMAGEALIGN_TOP_LEFT ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_TOP ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_TOP_RIGHT ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_BOTTOM_LEFT ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_BOTTOM ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_BOTTOM_RIGHT ) )
|
|
|
|
{
|
|
|
|
aRect.Bottom() -= ( aImageSize.Height() + nImageSep );
|
|
|
|
}
|
|
|
|
|
|
|
|
aRect = pDev->GetTextRect( aRect, aText, nTextStyle );
|
|
|
|
aTextSize = aRect.GetSize();
|
|
|
|
|
|
|
|
aTSSize.Width() += aTextSize.Width();
|
|
|
|
|
|
|
|
if ( aTSSize.Height() < aTextSize.Height() )
|
|
|
|
aTSSize.Height() = aTextSize.Height();
|
|
|
|
}
|
|
|
|
|
|
|
|
aMax.Width() = aTSSize.Width() > aImageSize.Width() ? aTSSize.Width() : aImageSize.Width();
|
|
|
|
aMax.Height() = aTSSize.Height() > aImageSize.Height() ? aTSSize.Height() : aImageSize.Height();
|
|
|
|
|
|
|
|
// Now calculate the output area for the image and the text acording to the image align flags
|
|
|
|
|
|
|
|
if ( ( eImageAlign == IMAGEALIGN_LEFT ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_RIGHT ) )
|
|
|
|
{
|
|
|
|
aImagePos.Y() = rPos.Y() + ( aMax.Height() - aImageSize.Height() ) / 2;
|
|
|
|
aTextPos.Y() = rPos.Y() + ( aMax.Height() - aTSSize.Height() ) / 2;
|
|
|
|
}
|
|
|
|
else if ( ( eImageAlign == IMAGEALIGN_LEFT_BOTTOM ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_RIGHT_BOTTOM ) )
|
|
|
|
{
|
|
|
|
aImagePos.Y() = rPos.Y() + aMax.Height() - aImageSize.Height();
|
|
|
|
aTextPos.Y() = rPos.Y() + aMax.Height() - aTSSize.Height();
|
|
|
|
}
|
|
|
|
else if ( ( eImageAlign == IMAGEALIGN_TOP ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_BOTTOM ) )
|
|
|
|
{
|
|
|
|
aImagePos.X() = rPos.X() + ( aMax.Width() - aImageSize.Width() ) / 2;
|
|
|
|
aTextPos.X() = rPos.X() + ( aMax.Width() - aTSSize.Width() ) / 2;
|
|
|
|
}
|
|
|
|
else if ( ( eImageAlign == IMAGEALIGN_TOP_RIGHT ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_BOTTOM_RIGHT ) )
|
|
|
|
{
|
|
|
|
aImagePos.X() = rPos.X() + aMax.Width() - aImageSize.Width();
|
|
|
|
aTextPos.X() = rPos.X() + aMax.Width() - aTSSize.Width();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ( eImageAlign == IMAGEALIGN_LEFT_TOP ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_LEFT ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_LEFT_BOTTOM ) )
|
|
|
|
{
|
|
|
|
aTextPos.X() = rPos.X() + aImageSize.Width() + nImageSep;
|
|
|
|
}
|
|
|
|
else if ( ( eImageAlign == IMAGEALIGN_RIGHT_TOP ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_RIGHT ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_RIGHT_BOTTOM ) )
|
|
|
|
{
|
|
|
|
aImagePos.X() = rPos.X() + aTSSize.Width() + nImageSep;
|
|
|
|
}
|
|
|
|
else if ( ( eImageAlign == IMAGEALIGN_TOP_LEFT ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_TOP ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_TOP_RIGHT ) )
|
|
|
|
{
|
|
|
|
aTextPos.Y() = rPos.Y() + aImageSize.Height() + nImageSep;
|
|
|
|
}
|
|
|
|
else if ( ( eImageAlign == IMAGEALIGN_BOTTOM_LEFT ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_BOTTOM ) ||
|
|
|
|
( eImageAlign == IMAGEALIGN_BOTTOM_RIGHT ) )
|
|
|
|
{
|
|
|
|
aImagePos.Y() = rPos.Y() + aTSSize.Height() + nImageSep;
|
|
|
|
}
|
|
|
|
else if ( eImageAlign == IMAGEALIGN_CENTER )
|
|
|
|
{
|
|
|
|
aImagePos.X() = rPos.X() + ( aMax.Width() - aImageSize.Width() ) / 2;
|
|
|
|
aImagePos.Y() = rPos.Y() + ( aMax.Height() - aImageSize.Height() ) / 2;
|
|
|
|
aTextPos.X() = rPos.X() + ( aMax.Width() - aTSSize.Width() ) / 2;
|
|
|
|
aTextPos.Y() = rPos.Y() + ( aMax.Height() - aTSSize.Height() ) / 2;
|
|
|
|
}
|
|
|
|
aUnion = Rectangle( aImagePos, aImageSize );
|
|
|
|
aUnion.Union( Rectangle( aTextPos, aTSSize ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now place the combination of text and image in the output area of the button
|
|
|
|
// according to the window style (WinBits)
|
|
|
|
long nXOffset = 0;
|
|
|
|
long nYOffset = 0;
|
|
|
|
|
|
|
|
if ( nWinStyle & WB_CENTER )
|
|
|
|
{
|
|
|
|
nXOffset = ( rSize.Width() - aUnion.GetWidth() ) / 2;
|
|
|
|
}
|
|
|
|
else if ( nWinStyle & WB_RIGHT )
|
|
|
|
{
|
|
|
|
nXOffset = rSize.Width() - aUnion.GetWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nWinStyle & WB_VCENTER )
|
|
|
|
{
|
|
|
|
nYOffset = ( rSize.Height() - aUnion.GetHeight() ) / 2;
|
|
|
|
}
|
|
|
|
else if ( nWinStyle & WB_BOTTOM )
|
|
|
|
{
|
|
|
|
nYOffset = rSize.Height() - aUnion.GetHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
// the top left corner should always be visible, so we don't allow negative offsets
|
|
|
|
if ( nXOffset < 0 ) nXOffset = 0;
|
|
|
|
if ( nYOffset < 0 ) nYOffset = 0;
|
|
|
|
|
|
|
|
aImagePos.X() += nXOffset;
|
|
|
|
aImagePos.Y() += nYOffset;
|
|
|
|
aTextPos.X() += nXOffset;
|
|
|
|
aTextPos.Y() += nYOffset;
|
|
|
|
|
|
|
|
// set rPos and rSize to the union
|
|
|
|
rSize = aUnion.GetSize();
|
|
|
|
rPos.X() += nXOffset;
|
|
|
|
rPos.Y() += nYOffset;
|
|
|
|
|
|
|
|
if ( bHasSymbol )
|
|
|
|
{
|
2005-02-25 12:10:56 +00:00
|
|
|
if ( mpButtonData->meSymbolAlign == SYMBOLALIGN_RIGHT )
|
|
|
|
{
|
|
|
|
Point aRightPos = Point( aTextPos.X() + aTextSize.Width() + aSymbolSize.Width()/2, aTextPos.Y() );
|
|
|
|
*pSymbolRect = Rectangle( aRightPos, aSymbolSize );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*pSymbolRect = Rectangle( aTextPos, aSymbolSize );
|
|
|
|
aTextPos.X() += ( 3 * nSymbolHeight / 2 );
|
|
|
|
}
|
|
|
|
if ( mpButtonData->mbSmallSymbol )
|
|
|
|
{
|
|
|
|
nYOffset = (aUnion.GetHeight() - aSymbolSize.Height())/2;
|
|
|
|
pSymbolRect->setY( aTextPos.Y() + nYOffset );
|
|
|
|
}
|
2004-07-05 14:41:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
USHORT nStyle = 0;
|
|
|
|
|
|
|
|
if ( ! ( nDrawFlags & WINDOW_DRAW_NODISABLE ) &&
|
|
|
|
! IsEnabled() )
|
|
|
|
nStyle |= IMAGE_DRAW_DISABLE;
|
|
|
|
|
|
|
|
if ( pBitmapEx && ( pDev->GetOutDevType() == OUTDEV_PRINTER ) )
|
|
|
|
{
|
|
|
|
// Fuer die BitmapEx ueberlegt sich KA noch, wie man die disablete
|
|
|
|
// Darstellung hinbekommt...
|
|
|
|
pBitmapEx->Draw( pDev, aImagePos, aImageSize /*, nStyle*/ );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( IsZoom() )
|
|
|
|
pDev->DrawImage( aImagePos, aImageSize, *pImage, nStyle );
|
|
|
|
else
|
|
|
|
pDev->DrawImage( aImagePos, *pImage, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bDrawText )
|
|
|
|
{
|
|
|
|
ImplSetFocusRect( Rectangle( aTextPos, aTextSize ) );
|
|
|
|
pDev->DrawText( Rectangle( aTextPos, aTextSize ), aText, nTextStyle, pVector, pDisplayText );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ImplSetFocusRect( Rectangle( aImagePos, aImageSize ) );
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void Button::ImplSetFocusRect( const Rectangle &rFocusRect )
|
|
|
|
{
|
|
|
|
Rectangle aFocusRect = rFocusRect;
|
|
|
|
Rectangle aOutputRect = Rectangle( Point(), GetOutputSizePixel() );
|
|
|
|
|
|
|
|
if ( ! aFocusRect.IsEmpty() )
|
|
|
|
{
|
|
|
|
aFocusRect.Left()--;
|
|
|
|
aFocusRect.Top()--;
|
|
|
|
aFocusRect.Right()++;
|
|
|
|
aFocusRect.Bottom()++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( aFocusRect.Left() < aOutputRect.Left() ) aFocusRect.Left() = aOutputRect.Left();
|
|
|
|
if ( aFocusRect.Top() < aOutputRect.Top() ) aFocusRect.Top() = aOutputRect.Top();
|
|
|
|
if ( aFocusRect.Right() > aOutputRect.Right() ) aFocusRect.Right() = aOutputRect.Right();
|
|
|
|
if ( aFocusRect.Bottom() > aOutputRect.Bottom() ) aFocusRect.Bottom() = aOutputRect.Bottom();
|
|
|
|
|
|
|
|
mpButtonData->maFocusRect = aFocusRect;
|
|
|
|
}
|
2002-07-04 17:17:19 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2004-07-05 14:41:27 +00:00
|
|
|
const Rectangle& Button::ImplGetFocusRect() const
|
|
|
|
{
|
|
|
|
return mpButtonData->maFocusRect;
|
|
|
|
}
|
2002-07-04 17:17:19 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
USHORT& Button::ImplGetButtonState()
|
|
|
|
{
|
|
|
|
return mpButtonData->mnButtonState;
|
2002-07-04 17:17:19 +00:00
|
|
|
}
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
USHORT Button::ImplGetButtonState() const
|
|
|
|
{
|
|
|
|
return mpButtonData->mnButtonState;
|
|
|
|
}
|
2002-07-04 17:17:19 +00:00
|
|
|
|
2005-02-25 12:10:56 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void Button::ImplSetSymbolAlign( SymbolAlign eAlign )
|
|
|
|
{
|
|
|
|
if ( mpButtonData->meSymbolAlign != eAlign )
|
|
|
|
{
|
|
|
|
mpButtonData->meSymbolAlign = eAlign;
|
|
|
|
StateChanged( STATE_CHANGE_DATA );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
SymbolAlign Button::ImplGetSymbolAlign() const
|
|
|
|
{
|
|
|
|
return mpButtonData->meSymbolAlign;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void Button::ImplSetSmallSymbol( BOOL bSmall )
|
|
|
|
{
|
|
|
|
mpButtonData->mbSmallSymbol = bSmall;
|
|
|
|
}
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void Button::EnableImageDisplay( BOOL bEnable )
|
|
|
|
{
|
|
|
|
if( bEnable )
|
|
|
|
mpButtonData->mnButtonState &= ~BUTTON_DRAW_NOIMAGE;
|
|
|
|
else
|
|
|
|
mpButtonData->mnButtonState |= BUTTON_DRAW_NOIMAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
BOOL Button::IsImageDisplayEnabled()
|
|
|
|
{
|
|
|
|
return (mpButtonData->mnButtonState & BUTTON_DRAW_NOIMAGE) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void Button::EnableTextDisplay( BOOL bEnable )
|
|
|
|
{
|
|
|
|
if( bEnable )
|
|
|
|
mpButtonData->mnButtonState &= ~BUTTON_DRAW_NOTEXT;
|
|
|
|
else
|
|
|
|
mpButtonData->mnButtonState |= BUTTON_DRAW_NOTEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
BOOL Button::IsTextDisplayEnabled()
|
|
|
|
{
|
|
|
|
return (mpButtonData->mnButtonState & BUTTON_DRAW_NOTEXT) == 0;
|
|
|
|
}
|
2002-07-04 17:17:19 +00:00
|
|
|
|
2004-11-26 15:12:52 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void Button::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
Control::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
// The flag SETTINGS_IN_UPDATE_SETTINGS is set when the settings changed due to a
|
|
|
|
// Application::SettingsChanged event. In this scenario we want to keep the style settings
|
|
|
|
// of our radio buttons and our check boxes.
|
|
|
|
if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) &&
|
|
|
|
( rDCEvt.GetFlags() & SETTINGS_IN_UPDATE_SETTINGS ) )
|
|
|
|
|
|
|
|
{
|
|
|
|
const AllSettings* pOldSettings = rDCEvt.GetOldSettings();
|
|
|
|
if ( pOldSettings )
|
|
|
|
{
|
|
|
|
BOOL bResetStyleSettings = FALSE;
|
|
|
|
AllSettings aAllSettings = GetSettings();
|
|
|
|
StyleSettings aStyleSetting = aAllSettings.GetStyleSettings();
|
|
|
|
|
|
|
|
USHORT nCheckBoxStyle = aStyleSetting.GetCheckBoxStyle();
|
|
|
|
if ( nCheckBoxStyle != pOldSettings->GetStyleSettings().GetCheckBoxStyle() )
|
|
|
|
{
|
|
|
|
aStyleSetting.SetCheckBoxStyle( pOldSettings->GetStyleSettings().GetCheckBoxStyle() );
|
|
|
|
bResetStyleSettings = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
USHORT nRadioButtonStyle = aStyleSetting.GetRadioButtonStyle();
|
|
|
|
if ( nRadioButtonStyle != pOldSettings->GetStyleSettings().GetRadioButtonStyle() )
|
|
|
|
{
|
|
|
|
aStyleSetting.SetRadioButtonStyle( pOldSettings->GetStyleSettings().GetRadioButtonStyle() );
|
|
|
|
bResetStyleSettings = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bResetStyleSettings )
|
|
|
|
{
|
|
|
|
aAllSettings.SetStyleSettings( pOldSettings->GetStyleSettings() );
|
|
|
|
SetSettings( aAllSettings );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
2006-06-19 18:15:23 +00:00
|
|
|
void PushButton::ImplInitPushButtonData()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-01-13 16:58:41 +00:00
|
|
|
mpWindowImpl->mbPushButton = TRUE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
meSymbol = SYMBOL_NOSYMBOL;
|
|
|
|
meState = STATE_NOCHECK;
|
|
|
|
meSaveValue = STATE_NOCHECK;
|
|
|
|
mnDDStyle = 0;
|
|
|
|
mbPressed = FALSE;
|
|
|
|
mbInUserDraw = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
|
|
|
nStyle = ImplInitStyle( pParent->GetWindow( WINDOW_LASTCHILD ), nStyle );
|
|
|
|
Button::ImplInit( pParent, nStyle, NULL );
|
|
|
|
|
|
|
|
if ( nStyle & WB_NOLIGHTBORDER )
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_NOLIGHTBORDER;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
ImplInitSettings( TRUE, TRUE, TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
WinBits PushButton::ImplInitStyle( const Window* pPrevWindow, WinBits nStyle )
|
|
|
|
{
|
|
|
|
if ( !(nStyle & WB_NOTABSTOP) )
|
|
|
|
nStyle |= WB_TABSTOP;
|
2004-07-05 14:41:27 +00:00
|
|
|
|
|
|
|
// if no alignment is given, default to "vertically centered". This is because since
|
|
|
|
// #i26046#, we respect the vertical alignment flags (previously we didn't completely),
|
|
|
|
// but we of course want to look as before when no vertical alignment is specified
|
|
|
|
if ( ( nStyle & ( WB_TOP | WB_VCENTER | WB_BOTTOM ) ) == 0 )
|
|
|
|
nStyle |= WB_VCENTER;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !(nStyle & WB_NOGROUP) &&
|
|
|
|
(!pPrevWindow ||
|
|
|
|
((pPrevWindow->GetType() != WINDOW_PUSHBUTTON) &&
|
|
|
|
(pPrevWindow->GetType() != WINDOW_OKBUTTON) &&
|
|
|
|
(pPrevWindow->GetType() != WINDOW_CANCELBUTTON) &&
|
|
|
|
(pPrevWindow->GetType() != WINDOW_HELPBUTTON)) ) )
|
|
|
|
nStyle |= WB_GROUP;
|
|
|
|
return nStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::ImplInitSettings( BOOL bFont,
|
|
|
|
BOOL bForeground, BOOL bBackground )
|
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
|
|
|
|
if ( bFont )
|
|
|
|
{
|
|
|
|
Font aFont = rStyleSettings.GetPushButtonFont();
|
|
|
|
if ( IsControlFont() )
|
|
|
|
aFont.Merge( GetControlFont() );
|
|
|
|
SetZoomedPointFont( aFont );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bForeground || bFont )
|
|
|
|
{
|
|
|
|
Color aColor;
|
|
|
|
if ( IsControlForeground() )
|
|
|
|
aColor = GetControlForeground();
|
|
|
|
else
|
|
|
|
aColor = rStyleSettings.GetButtonTextColor();
|
|
|
|
SetTextColor( aColor );
|
|
|
|
SetTextFillColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bBackground )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
2005-01-21 12:32:58 +00:00
|
|
|
SetBackground();
|
|
|
|
// #i38498#: do not check for GetParent()->IsChildTransparentModeEnabled()
|
|
|
|
// otherwise the formcontrol button will be overdrawn due to PARENTCLIPMODE_NOCLIP
|
|
|
|
// for radio and checkbox this is ok as they shoud appear transparent in documents
|
|
|
|
if ( IsNativeControlSupported( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL ) )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
|
|
|
EnableChildTransparentMode( TRUE );
|
|
|
|
SetParentClipMode( PARENTCLIPMODE_NOCLIP );
|
|
|
|
SetPaintTransparent( TRUE );
|
2007-07-05 07:38:41 +00:00
|
|
|
mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects;
|
2004-05-10 14:45:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableChildTransparentMode( FALSE );
|
|
|
|
SetParentClipMode( 0 );
|
|
|
|
SetPaintTransparent( FALSE );
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::ImplDrawPushButtonFrame( Window* pDev,
|
|
|
|
Rectangle& rRect, USHORT nStyle )
|
|
|
|
{
|
|
|
|
if ( !(pDev->GetStyle() & (WB_RECTSTYLE | WB_SMALLSTYLE)) )
|
|
|
|
{
|
|
|
|
StyleSettings aStyleSettings = pDev->GetSettings().GetStyleSettings();
|
|
|
|
if ( pDev->IsControlBackground() )
|
|
|
|
aStyleSettings.Set3DColors( pDev->GetControlBackground() );
|
|
|
|
|
|
|
|
USHORT nPushButtonSysStyle = aStyleSettings.GetPushButtonStyle() & STYLE_PUSHBUTTON_STYLE;
|
|
|
|
if ( nPushButtonSysStyle == STYLE_PUSHBUTTON_MAC )
|
|
|
|
{
|
|
|
|
pDev->SetLineColor();
|
|
|
|
pDev->SetFillColor( aStyleSettings.GetFaceColor() );
|
|
|
|
pDev->DrawRect( rRect );
|
|
|
|
|
|
|
|
if ( (aStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
|
|
|
|
(pDev->GetOutDevType() == OUTDEV_PRINTER) )
|
|
|
|
nStyle |= BUTTON_DRAW_MONO;
|
|
|
|
|
|
|
|
if ( nStyle & BUTTON_DRAW_DEFAULT )
|
|
|
|
{
|
|
|
|
if ( nStyle & BUTTON_DRAW_MONO )
|
|
|
|
pDev->SetLineColor( Color( COL_BLACK ) );
|
|
|
|
else
|
|
|
|
pDev->SetLineColor( aStyleSettings.GetDarkShadowColor() );
|
|
|
|
|
|
|
|
pDev->DrawLine( Point( rRect.Left()+3, rRect.Top() ),
|
|
|
|
Point( rRect.Right()-3, rRect.Top() ) );
|
|
|
|
pDev->DrawLine( Point( rRect.Left()+3, rRect.Bottom() ),
|
|
|
|
Point( rRect.Right()-3, rRect.Bottom() ) );
|
|
|
|
pDev->DrawLine( Point( rRect.Left(), rRect.Top()+3 ),
|
|
|
|
Point( rRect.Left(), rRect.Bottom()-3 ) );
|
|
|
|
pDev->DrawLine( Point( rRect.Right(), rRect.Top()+3 ),
|
|
|
|
Point( rRect.Right(), rRect.Bottom()-3 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Left()+2, rRect.Top()+1 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Left()+1, rRect.Top()+2 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Right()-2, rRect.Top()+1 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Right()-1, rRect.Top()+2 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Left()+2, rRect.Bottom()-1 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Left()+1, rRect.Bottom()-2 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Right()-2, rRect.Bottom()-1 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Right()-1, rRect.Bottom()-2 ) );
|
|
|
|
|
|
|
|
if ( nStyle & BUTTON_DRAW_MONO )
|
|
|
|
pDev->SetLineColor( Color( COL_BLACK ) );
|
|
|
|
else
|
|
|
|
pDev->SetLineColor( aStyleSettings.GetShadowColor() );
|
|
|
|
pDev->DrawLine( Point( rRect.Left()+3, rRect.Bottom()-1 ),
|
|
|
|
Point( rRect.Right()-3, rRect.Bottom()-1 ) );
|
|
|
|
pDev->DrawLine( Point( rRect.Right()-1, rRect.Top()+3 ),
|
|
|
|
Point( rRect.Right()-1, rRect.Bottom()-3 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Right()-3, rRect.Bottom()-2 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Right()-2, rRect.Bottom()-2 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Right()-2, rRect.Bottom()-3 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
rRect.Left() += 2;
|
|
|
|
rRect.Top() += 2;
|
|
|
|
rRect.Right() -= 2;
|
|
|
|
rRect.Bottom() -= 2;
|
|
|
|
|
|
|
|
if ( nStyle & BUTTON_DRAW_MONO )
|
|
|
|
pDev->SetLineColor( Color( COL_BLACK ) );
|
|
|
|
else
|
|
|
|
pDev->SetLineColor( aStyleSettings.GetDarkShadowColor() );
|
|
|
|
|
|
|
|
pDev->DrawLine( Point( rRect.Left()+2, rRect.Top() ),
|
|
|
|
Point( rRect.Right()-2, rRect.Top() ) );
|
|
|
|
pDev->DrawLine( Point( rRect.Left()+2, rRect.Bottom() ),
|
|
|
|
Point( rRect.Right()-2, rRect.Bottom() ) );
|
|
|
|
pDev->DrawLine( Point( rRect.Left(), rRect.Top()+2 ),
|
|
|
|
Point( rRect.Left(), rRect.Bottom()-2 ) );
|
|
|
|
pDev->DrawLine( Point( rRect.Right(), rRect.Top()+2 ),
|
|
|
|
Point( rRect.Right(), rRect.Bottom()-2 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Left()+1, rRect.Top()+1 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Right()-1, rRect.Top()+1 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Left()+1, rRect.Bottom()-1 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Right()-1, rRect.Bottom()-1 ) );
|
|
|
|
|
|
|
|
pDev->SetLineColor();
|
|
|
|
if ( nStyle & BUTTON_DRAW_CHECKED )
|
|
|
|
pDev->SetFillColor( aStyleSettings.GetCheckedColor() );
|
|
|
|
else
|
|
|
|
pDev->SetFillColor( aStyleSettings.GetFaceColor() );
|
|
|
|
pDev->DrawRect( Rectangle( rRect.Left()+2, rRect.Top()+2, rRect.Right()-2, rRect.Bottom()-2 ) );
|
|
|
|
|
|
|
|
if ( !(nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED)) )
|
|
|
|
{
|
|
|
|
if ( nStyle & BUTTON_DRAW_MONO )
|
|
|
|
pDev->SetLineColor( Color( COL_BLACK ) );
|
|
|
|
else
|
|
|
|
pDev->SetLineColor( aStyleSettings.GetShadowColor() );
|
|
|
|
pDev->DrawLine( Point( rRect.Left()+2, rRect.Bottom()-1 ),
|
|
|
|
Point( rRect.Right()-2, rRect.Bottom()-1 ) );
|
|
|
|
pDev->DrawLine( Point( rRect.Right()-1, rRect.Top()+2 ),
|
|
|
|
Point( rRect.Right()-1, rRect.Bottom()-2 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Right()-2, rRect.Bottom()-2 ) );
|
|
|
|
pDev->SetLineColor( aStyleSettings.GetLightColor() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pDev->SetLineColor( aStyleSettings.GetShadowColor() );
|
|
|
|
|
|
|
|
if ( !(nStyle & BUTTON_DRAW_MONO) )
|
|
|
|
{
|
|
|
|
pDev->DrawLine( Point( rRect.Left()+2, rRect.Top()+1 ),
|
|
|
|
Point( rRect.Right()-2, rRect.Top()+1 ) );
|
|
|
|
pDev->DrawLine( Point( rRect.Left()+1, rRect.Top()+2 ),
|
|
|
|
Point( rRect.Left()+1, rRect.Bottom()-2 ) );
|
|
|
|
pDev->DrawPixel( Point( rRect.Top()+2, rRect.Right()+2 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
rRect.Left() += 2;
|
|
|
|
rRect.Top() += 2;
|
|
|
|
rRect.Right() -= 2;
|
|
|
|
rRect.Bottom() -= 2;
|
|
|
|
|
|
|
|
if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
|
|
|
|
{
|
|
|
|
rRect.Left()++;
|
|
|
|
rRect.Top()++;
|
|
|
|
rRect.Right()++;
|
|
|
|
rRect.Bottom()++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DecorationView aDecoView( pDev );
|
|
|
|
if ( pDev->IsControlBackground() )
|
|
|
|
{
|
|
|
|
AllSettings aSettings = pDev->GetSettings();
|
|
|
|
AllSettings aOldSettings = aSettings;
|
|
|
|
StyleSettings aStyleSettings = aSettings.GetStyleSettings();
|
|
|
|
aStyleSettings.Set3DColors( pDev->GetControlBackground() );
|
|
|
|
aSettings.SetStyleSettings( aStyleSettings );
|
2007-01-25 10:23:47 +00:00
|
|
|
pDev->OutputDevice::SetSettings( aSettings );
|
2000-09-18 16:07:07 +00:00
|
|
|
rRect = aDecoView.DrawButton( rRect, nStyle );
|
2007-01-25 10:23:47 +00:00
|
|
|
pDev->OutputDevice::SetSettings( aOldSettings );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rRect = aDecoView.DrawButton( rRect, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL PushButton::ImplHitTestPushButton( Window* pDev,
|
2006-06-19 18:15:23 +00:00
|
|
|
const Point& rPos )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Point aTempPoint;
|
|
|
|
Rectangle aTestRect( aTempPoint, pDev->GetOutputSizePixel() );
|
|
|
|
|
|
|
|
if ( !(pDev->GetStyle() & (WB_RECTSTYLE | WB_SMALLSTYLE)) )
|
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = pDev->GetSettings().GetStyleSettings();
|
|
|
|
|
|
|
|
USHORT nPushButtonSysStyle = rStyleSettings.GetPushButtonStyle() & STYLE_PUSHBUTTON_STYLE;
|
|
|
|
if ( nPushButtonSysStyle == STYLE_PUSHBUTTON_MAC )
|
|
|
|
{
|
|
|
|
aTestRect.Left() += 2;
|
|
|
|
aTestRect.Top() += 2;
|
|
|
|
aTestRect.Right() -= 2;
|
|
|
|
aTestRect.Bottom() -= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aTestRect.IsInside( rPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
USHORT PushButton::ImplGetTextStyle( ULONG nDrawFlags ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
|
|
|
|
USHORT nTextStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_MULTILINE | TEXT_DRAW_ENDELLIPSIS;
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO ) ||
|
|
|
|
( nDrawFlags & WINDOW_DRAW_MONO ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
nTextStyle |= TEXT_DRAW_MONO;
|
2004-07-05 14:41:27 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( GetStyle() & WB_WORDBREAK )
|
|
|
|
nTextStyle |= TEXT_DRAW_WORDBREAK;
|
|
|
|
if ( GetStyle() & WB_NOLABEL )
|
|
|
|
nTextStyle &= ~TEXT_DRAW_MNEMONIC;
|
2004-07-05 14:41:27 +00:00
|
|
|
|
|
|
|
if ( GetStyle() & WB_LEFT )
|
|
|
|
nTextStyle |= TEXT_DRAW_LEFT;
|
|
|
|
else if ( GetStyle() & WB_RIGHT )
|
|
|
|
nTextStyle |= TEXT_DRAW_RIGHT;
|
|
|
|
else
|
|
|
|
nTextStyle |= TEXT_DRAW_CENTER;
|
|
|
|
|
|
|
|
if ( GetStyle() & WB_TOP )
|
|
|
|
nTextStyle |= TEXT_DRAW_TOP;
|
|
|
|
else if ( GetStyle() & WB_BOTTOM )
|
|
|
|
nTextStyle |= TEXT_DRAW_BOTTOM;
|
|
|
|
else
|
|
|
|
nTextStyle |= TEXT_DRAW_VCENTER;
|
|
|
|
|
|
|
|
if ( ! ( (nDrawFlags & WINDOW_DRAW_NODISABLE) || IsEnabled() ) )
|
|
|
|
nTextStyle |= TEXT_DRAW_DISABLE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
return nTextStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static void ImplDrawBtnDropDownArrow( OutputDevice* pDev,
|
|
|
|
long nX, long nY,
|
|
|
|
Color& rColor, BOOL bBlack )
|
2006-01-26 17:07:58 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
Color aOldLineColor = pDev->GetLineColor();
|
|
|
|
Color aOldFillColor = pDev->GetFillColor();
|
|
|
|
|
|
|
|
pDev->SetLineColor();
|
|
|
|
if ( bBlack )
|
|
|
|
pDev->SetFillColor( Color( COL_BLACK ) );
|
2006-01-26 17:07:58 +00:00
|
|
|
else
|
2000-09-18 16:07:07 +00:00
|
|
|
pDev->SetFillColor( rColor );
|
|
|
|
pDev->DrawRect( Rectangle( nX+0, nY+0, nX+6, nY+0 ) );
|
|
|
|
pDev->DrawRect( Rectangle( nX+1, nY+1, nX+5, nY+1 ) );
|
|
|
|
pDev->DrawRect( Rectangle( nX+2, nY+2, nX+4, nY+2 ) );
|
|
|
|
pDev->DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
|
|
|
|
if ( bBlack )
|
2006-01-26 17:07:58 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
pDev->SetFillColor( rColor );
|
|
|
|
pDev->DrawRect( Rectangle( nX+2, nY+1, nX+4, nY+1 ) );
|
|
|
|
pDev->DrawRect( Rectangle( nX+3, nY+2, nX+3, nY+2 ) );
|
2006-01-26 17:07:58 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
pDev->SetLineColor( aOldLineColor );
|
|
|
|
pDev->SetFillColor( aOldFillColor );
|
2006-01-26 17:07:58 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, ULONG nDrawFlags,
|
2006-06-19 18:15:23 +00:00
|
|
|
const Rectangle& rRect,
|
2002-04-29 16:46:18 +00:00
|
|
|
bool bLayout )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
Rectangle aInRect = rRect;
|
2004-07-05 14:41:27 +00:00
|
|
|
Color aColor;
|
2000-09-18 16:07:07 +00:00
|
|
|
XubString aText = PushButton::GetText(); // PushButton:: wegen MoreButton
|
2004-07-05 14:41:27 +00:00
|
|
|
USHORT nTextStyle = ImplGetTextStyle( nDrawFlags );
|
2000-09-18 16:07:07 +00:00
|
|
|
USHORT nStyle;
|
2001-03-23 13:34:56 +00:00
|
|
|
|
|
|
|
if( aInRect.nRight < aInRect.nLeft || aInRect.nBottom < aInRect.nTop )
|
|
|
|
aInRect.SetEmpty();
|
|
|
|
|
2001-04-10 11:42:24 +00:00
|
|
|
pDev->Push( PUSH_CLIPREGION );
|
|
|
|
pDev->IntersectClipRegion( aInRect );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( nDrawFlags & WINDOW_DRAW_MONO )
|
|
|
|
aColor = Color( COL_BLACK );
|
|
|
|
else if ( IsControlForeground() )
|
|
|
|
aColor = GetControlForeground();
|
2006-01-26 17:07:58 +00:00
|
|
|
else if( nDrawFlags & WINDOW_DRAW_ROLLOVER )
|
|
|
|
aColor = rStyleSettings.GetButtonRolloverTextColor();
|
2004-07-05 14:41:27 +00:00
|
|
|
else
|
|
|
|
aColor = rStyleSettings.GetButtonTextColor();
|
|
|
|
|
|
|
|
pDev->SetTextColor( aColor );
|
|
|
|
|
|
|
|
if ( IsEnabled() || (nDrawFlags & WINDOW_DRAW_NODISABLE) )
|
|
|
|
nStyle = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2004-07-05 14:41:27 +00:00
|
|
|
nStyle = SYMBOL_DRAW_DISABLE;
|
|
|
|
|
|
|
|
Size aSize = rRect.GetSize();
|
|
|
|
Point aPos = rRect.TopLeft();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( mnDDStyle == PUSHBUTTON_DROPDOWN_MENUBUTTON )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-03-23 13:34:56 +00:00
|
|
|
// calc Symbol- and Textrect
|
2004-09-09 15:19:40 +00:00
|
|
|
long nSymbolSize = pDev->GetTextHeight() / 2 + 1;
|
2000-09-18 16:07:07 +00:00
|
|
|
aInRect.Right() -= 5;
|
2004-07-05 14:41:27 +00:00
|
|
|
aInRect.Left() = aInRect.Right() - nSymbolSize;
|
|
|
|
aSize.Width() -= ( 5 + nSymbolSize );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplDrawAlignedImage( pDev, aPos, aSize, bLayout,
|
|
|
|
1, nDrawFlags, nTextStyle );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ImplCalcSymbolRect( aInRect );
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
if( ! bLayout )
|
|
|
|
{
|
|
|
|
DecorationView aDecoView( pDev );
|
|
|
|
aDecoView.DrawSymbol( aInRect, SYMBOL_SPIN_DOWN, aColor, nStyle );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-04-12 11:18:06 +00:00
|
|
|
Rectangle aSymbolRect;
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, 1, nDrawFlags,
|
2005-04-12 11:18:06 +00:00
|
|
|
nTextStyle, IsSymbol() ? &aSymbolRect : NULL );
|
2001-03-23 13:34:56 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( IsSymbol() && ! bLayout )
|
2001-03-23 13:34:56 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
DecorationView aDecoView( pDev );
|
2005-04-12 11:18:06 +00:00
|
|
|
aDecoView.DrawSymbol( aSymbolRect, meSymbol, aColor, nStyle );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( mnDDStyle == PUSHBUTTON_DROPDOWN_TOOLBOX && !bLayout )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
BOOL bBlack = FALSE;
|
|
|
|
Color aArrowColor( COL_BLACK );
|
2004-07-05 14:41:27 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !(nDrawFlags & WINDOW_DRAW_MONO) )
|
|
|
|
{
|
|
|
|
if ( !IsEnabled() )
|
|
|
|
aArrowColor = rStyleSettings.GetShadowColor();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aArrowColor = Color( COL_LIGHTGREEN );
|
|
|
|
bBlack = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImplDrawBtnDropDownArrow( pDev, aInRect.Right()-6, aInRect.Top()+1,
|
|
|
|
aArrowColor, bBlack );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UserDrawEvent aUDEvt( this, aInRect, 0 );
|
|
|
|
UserDraw( aUDEvt );
|
2001-03-23 13:34:56 +00:00
|
|
|
|
2001-04-10 11:42:24 +00:00
|
|
|
pDev->Pop(); // restore clipregion
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::UserDraw( const UserDrawEvent& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
void PushButton::ImplDrawPushButton( bool bLayout )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-04-29 16:46:18 +00:00
|
|
|
if( !bLayout )
|
|
|
|
HideFocus();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
USHORT nButtonStyle = ImplGetButtonState();
|
2000-09-18 16:07:07 +00:00
|
|
|
Point aPoint;
|
|
|
|
Size aOutSz( GetOutputSizePixel() );
|
|
|
|
Rectangle aRect( aPoint, aOutSz );
|
|
|
|
Rectangle aInRect = aRect;
|
|
|
|
Rectangle aTextRect;
|
2004-05-10 14:45:59 +00:00
|
|
|
BOOL bNativeOK = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-03-23 13:34:56 +00:00
|
|
|
// adjust style if button should be rendered 'pressed'
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( mbPressed )
|
|
|
|
nButtonStyle |= BUTTON_DRAW_PRESSED;
|
|
|
|
|
2004-05-10 14:45:59 +00:00
|
|
|
// TODO: move this to Window class or make it a member !!!
|
|
|
|
ControlType aCtrlType = 0;
|
|
|
|
switch( GetParent()->GetType() )
|
|
|
|
{
|
|
|
|
case WINDOW_LISTBOX:
|
|
|
|
case WINDOW_MULTILISTBOX:
|
|
|
|
case WINDOW_TREELISTBOX:
|
|
|
|
aCtrlType = CTRL_LISTBOX;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINDOW_COMBOBOX:
|
|
|
|
case WINDOW_PATTERNBOX:
|
|
|
|
case WINDOW_NUMERICBOX:
|
|
|
|
case WINDOW_METRICBOX:
|
|
|
|
case WINDOW_CURRENCYBOX:
|
|
|
|
case WINDOW_DATEBOX:
|
|
|
|
case WINDOW_TIMEBOX:
|
|
|
|
case WINDOW_LONGCURRENCYBOX:
|
|
|
|
aCtrlType = CTRL_COMBOBOX;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL bDropDown = ( IsSymbol() && (GetSymbol()==SYMBOL_SPIN_DOWN) && !GetText().Len() );
|
|
|
|
|
|
|
|
if( bDropDown && (aCtrlType == CTRL_COMBOBOX || aCtrlType == CTRL_LISTBOX ) )
|
|
|
|
{
|
|
|
|
if( GetParent()->IsNativeControlSupported( aCtrlType, PART_ENTIRE_CONTROL) )
|
|
|
|
{
|
2005-04-12 11:18:06 +00:00
|
|
|
// skip painting if the button was already drawn by the theme
|
|
|
|
if( aCtrlType == CTRL_COMBOBOX )
|
|
|
|
{
|
|
|
|
Edit* pEdit = static_cast<Edit*>(GetParent());
|
|
|
|
if( pEdit->ImplUseNativeBorder( pEdit->GetStyle() ) )
|
|
|
|
bNativeOK = TRUE;
|
|
|
|
}
|
|
|
|
else if( GetParent()->IsNativeControlSupported( aCtrlType, HAS_BACKGROUND_TEXTURE) )
|
|
|
|
{
|
2004-05-10 14:45:59 +00:00
|
|
|
bNativeOK = TRUE;
|
2005-04-12 11:18:06 +00:00
|
|
|
}
|
|
|
|
if( !bNativeOK && GetParent()->IsNativeControlSupported( aCtrlType, PART_BUTTON_DOWN ) )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
|
|
|
// let the theme draw it, note we then need support
|
|
|
|
// for CTRL_LISTBOX/PART_BUTTON_DOWN and CTRL_COMBOBOX/PART_BUTTON_DOWN
|
|
|
|
|
|
|
|
ImplControlValue aControlValue;
|
|
|
|
Region aCtrlRegion( aInRect );
|
|
|
|
ControlState nState = 0;
|
|
|
|
|
|
|
|
if ( mbPressed ) nState |= CTRL_STATE_PRESSED;
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED ) nState |= CTRL_STATE_PRESSED;
|
2004-05-10 14:45:59 +00:00
|
|
|
if ( HasFocus() ) nState |= CTRL_STATE_FOCUSED;
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= CTRL_STATE_DEFAULT;
|
2004-05-10 14:45:59 +00:00
|
|
|
if ( Window::IsEnabled() ) nState |= CTRL_STATE_ENABLED;
|
|
|
|
|
|
|
|
if ( IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() ) )
|
|
|
|
nState |= CTRL_STATE_ROLLOVER;
|
|
|
|
|
|
|
|
bNativeOK = DrawNativeControl( aCtrlType, PART_BUTTON_DOWN, aCtrlRegion, nState,
|
|
|
|
aControlValue, rtl::OUString() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-05-10 14:45:59 +00:00
|
|
|
if( bNativeOK )
|
|
|
|
return;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-05-10 14:45:59 +00:00
|
|
|
if ( (bNativeOK=IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL)) == TRUE )
|
2001-03-23 13:34:56 +00:00
|
|
|
{
|
2008-03-05 16:07:33 +00:00
|
|
|
PushButtonValue aPBVal;
|
2004-05-10 14:45:59 +00:00
|
|
|
ImplControlValue aControlValue;
|
2008-03-05 16:07:33 +00:00
|
|
|
aControlValue.setOptionalVal( &aPBVal );
|
2004-05-10 14:45:59 +00:00
|
|
|
Region aCtrlRegion( aInRect );
|
|
|
|
ControlState nState = 0;
|
|
|
|
|
2005-07-06 08:19:53 +00:00
|
|
|
if ( mbPressed || IsChecked() ) nState |= CTRL_STATE_PRESSED;
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED ) nState |= CTRL_STATE_PRESSED;
|
2004-05-10 14:45:59 +00:00
|
|
|
if ( HasFocus() ) nState |= CTRL_STATE_FOCUSED;
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= CTRL_STATE_DEFAULT;
|
2004-05-10 14:45:59 +00:00
|
|
|
if ( Window::IsEnabled() ) nState |= CTRL_STATE_ENABLED;
|
|
|
|
|
|
|
|
if ( IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() ) )
|
|
|
|
nState |= CTRL_STATE_ROLLOVER;
|
|
|
|
|
2008-03-05 16:07:33 +00:00
|
|
|
if( GetStyle() & WB_BEVELBUTTON )
|
|
|
|
aPBVal.mbBevelButton = true;
|
|
|
|
|
2004-05-10 14:45:59 +00:00
|
|
|
// draw frame into invisible window to have aInRect modified correctly
|
|
|
|
// but do not shift the inner rect for pressed buttons (ie remove BUTTON_DRAW_PRESSED)
|
|
|
|
// this assumes the theme has enough visual cues to signalize the button was pressed
|
|
|
|
//Window aWin( this );
|
|
|
|
//ImplDrawPushButtonFrame( &aWin, aInRect, nButtonStyle & ~BUTTON_DRAW_PRESSED );
|
|
|
|
|
|
|
|
// looks better this way as symbols were displaced slightly using the above approach
|
|
|
|
aInRect.Top()+=4;
|
|
|
|
aInRect.Bottom()-=4;
|
|
|
|
aInRect.Left()+=4;
|
|
|
|
aInRect.Right()-=4;
|
|
|
|
|
2008-05-30 07:06:39 +00:00
|
|
|
// prepare single line hint (needed on mac to decide between normal push button and
|
|
|
|
// rectangular bevel button look)
|
|
|
|
Size aFontSize( Application::GetSettings().GetStyleSettings().GetPushButtonFont().GetSize() );
|
|
|
|
aFontSize = LogicToPixel( aFontSize, MapMode( MAP_POINT ) );
|
|
|
|
Size aInRectSize( LogicToPixel( Size( aInRect.GetWidth(), aInRect.GetHeight() ) ) );
|
|
|
|
aPBVal.mbSingleLine = (aInRectSize.Height() < 2 * aFontSize.Height() );
|
|
|
|
|
|
|
|
bNativeOK = DrawNativeControl( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
|
|
|
|
aControlValue, rtl::OUString()/*PushButton::GetText()*/ );
|
|
|
|
|
2004-05-10 14:45:59 +00:00
|
|
|
// draw content using the same aInRect as non-native VCL would do
|
2006-01-26 17:07:58 +00:00
|
|
|
ImplDrawPushButtonContent( this,
|
|
|
|
(nState&CTRL_STATE_ROLLOVER) ? WINDOW_DRAW_ROLLOVER : 0,
|
2006-06-19 18:15:23 +00:00
|
|
|
aInRect, bLayout );
|
2004-05-10 14:45:59 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( HasFocus() )
|
|
|
|
ShowFocus( ImplGetFocusRect() );
|
2004-05-10 14:45:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bNativeOK == FALSE )
|
|
|
|
{
|
|
|
|
// draw PushButtonFrame, aInRect has content size afterwards
|
|
|
|
if( ! bLayout )
|
|
|
|
ImplDrawPushButtonFrame( this, aInRect, nButtonStyle );
|
|
|
|
|
|
|
|
// draw content
|
2006-06-19 18:15:23 +00:00
|
|
|
ImplDrawPushButtonContent( this, 0, aInRect, bLayout );
|
2004-05-10 14:45:59 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if( ! bLayout && HasFocus() )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ShowFocus( ImplGetFocusRect() );
|
2001-03-23 13:34:56 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::ImplSetDefButton( BOOL bSet )
|
|
|
|
{
|
2004-05-10 14:45:59 +00:00
|
|
|
Size aSize( GetSizePixel() );
|
|
|
|
Point aPos( GetPosPixel() );
|
|
|
|
int dLeft(0), dRight(0), dTop(0), dBottom(0);
|
|
|
|
BOOL bSetPos = FALSE;
|
|
|
|
|
|
|
|
if ( (IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL)) == TRUE )
|
|
|
|
{
|
|
|
|
Region aBoundingRgn, aContentRgn;
|
|
|
|
Rectangle aCtrlRect( 0, 0, 80, 20 ); // use a constant size to avoid accumulating
|
|
|
|
// will not work if the theme has dynamic adornment sizes
|
|
|
|
ImplControlValue aControlValue;
|
|
|
|
Region aCtrlRegion( aCtrlRect );
|
|
|
|
ControlState nState = CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED;
|
|
|
|
|
|
|
|
// get native size of a 'default' button
|
|
|
|
// and adjust the VCL button if more space for adornment is required
|
|
|
|
if( GetNativeControlRegion( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion,
|
|
|
|
nState, aControlValue, rtl::OUString(),
|
|
|
|
aBoundingRgn, aContentRgn ) )
|
|
|
|
{
|
|
|
|
Rectangle aCont(aContentRgn.GetBoundRect());
|
|
|
|
Rectangle aBound(aBoundingRgn.GetBoundRect());
|
|
|
|
|
|
|
|
dLeft = aCont.Left() - aBound.Left();
|
|
|
|
dTop = aCont.Top() - aBound.Top();
|
|
|
|
dRight = aBound.Right() - aCont.Right();
|
|
|
|
dBottom = aBound.Bottom() - aCont.Bottom();
|
|
|
|
bSetPos = dLeft || dTop || dRight || dBottom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( bSet )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if( !(ImplGetButtonState() & BUTTON_DRAW_DEFAULT) && bSetPos )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
|
|
|
// adjust pos/size when toggling from non-default to default
|
|
|
|
aPos.Move(-dLeft, -dTop);
|
|
|
|
aSize.Width() += dLeft + dRight;
|
|
|
|
aSize.Height() += dTop + dBottom;
|
|
|
|
}
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_DEFAULT;
|
2004-05-10 14:45:59 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if( (ImplGetButtonState() & BUTTON_DRAW_DEFAULT) && bSetPos )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
|
|
|
// adjust pos/size when toggling from default to non-default
|
|
|
|
aPos.Move(dLeft, dTop);
|
|
|
|
aSize.Width() -= dLeft + dRight;
|
|
|
|
aSize.Height() -= dTop + dBottom;
|
|
|
|
}
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_DEFAULT;
|
2004-05-10 14:45:59 +00:00
|
|
|
}
|
|
|
|
if( bSetPos )
|
|
|
|
SetPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height(), WINDOW_POSSIZE_ALL );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL PushButton::ImplIsDefButton() const
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
return (ImplGetButtonState() & BUTTON_DRAW_DEFAULT) != 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
PushButton::PushButton( WindowType nType ) :
|
|
|
|
Button( nType )
|
|
|
|
{
|
2006-06-19 18:15:23 +00:00
|
|
|
ImplInitPushButtonData();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
PushButton::PushButton( Window* pParent, WinBits nStyle ) :
|
|
|
|
Button( WINDOW_PUSHBUTTON )
|
|
|
|
{
|
2006-06-19 18:15:23 +00:00
|
|
|
ImplInitPushButtonData();
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
PushButton::PushButton( Window* pParent, const ResId& rResId ) :
|
|
|
|
Button( WINDOW_PUSHBUTTON )
|
|
|
|
{
|
2006-06-19 18:15:23 +00:00
|
|
|
ImplInitPushButtonData();
|
2000-09-18 16:07:07 +00:00
|
|
|
rResId.SetRT( RSC_PUSHBUTTON );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
PushButton::~PushButton()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::MouseButtonDown( const MouseEvent& rMEvt )
|
|
|
|
{
|
|
|
|
if ( rMEvt.IsLeft() &&
|
2006-06-19 18:15:23 +00:00
|
|
|
ImplHitTestPushButton( this, rMEvt.GetPosPixel() ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
USHORT nTrackFlags = 0;
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ( GetStyle() & WB_REPEAT ) &&
|
|
|
|
! ( GetStyle() & WB_TOGGLE ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
nTrackFlags |= STARTTRACK_BUTTONREPEAT;
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplDrawPushButton();
|
|
|
|
StartTracking( nTrackFlags );
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( nTrackFlags & STARTTRACK_BUTTONREPEAT )
|
2000-09-18 16:07:07 +00:00
|
|
|
Click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::Tracking( const TrackingEvent& rTEvt )
|
|
|
|
{
|
|
|
|
if ( rTEvt.IsTrackingEnded() )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
|
|
|
|
GrabFocus();
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( GetStyle() & WB_TOGGLE )
|
|
|
|
{
|
|
|
|
// Don't toggle, when aborted
|
|
|
|
if ( !rTEvt.IsTrackingCanceled() )
|
|
|
|
{
|
|
|
|
if ( IsChecked() )
|
|
|
|
{
|
|
|
|
Check( FALSE );
|
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Check( TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplDrawPushButton();
|
|
|
|
|
|
|
|
// Bei Abbruch kein Click-Handler rufen
|
|
|
|
if ( !rTEvt.IsTrackingCanceled() )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ! ( ( GetStyle() & WB_REPEAT ) &&
|
|
|
|
! ( GetStyle() & WB_TOGGLE ) ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
Click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-19 18:15:23 +00:00
|
|
|
if ( ImplHitTestPushButton( this, rTEvt.GetMouseEvent().GetPosPixel() ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( rTEvt.IsTrackingRepeat() && (GetStyle() & WB_REPEAT) &&
|
|
|
|
! ( GetStyle() & WB_TOGGLE ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
Click();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplDrawPushButton();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplDrawPushButton();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::KeyInput( const KeyEvent& rKEvt )
|
|
|
|
{
|
|
|
|
KeyCode aKeyCode = rKEvt.GetKeyCode();
|
|
|
|
|
|
|
|
if ( !aKeyCode.GetModifier() &&
|
|
|
|
((aKeyCode.GetCode() == KEY_RETURN) || (aKeyCode.GetCode() == KEY_SPACE)) )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplDrawPushButton();
|
|
|
|
}
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ( GetStyle() & WB_REPEAT ) &&
|
|
|
|
! ( GetStyle() & WB_TOGGLE ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
Click();
|
|
|
|
}
|
2004-07-05 14:41:27 +00:00
|
|
|
else if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_ESCAPE) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplDrawPushButton();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Button::KeyInput( rKEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::KeyUp( const KeyEvent& rKEvt )
|
|
|
|
{
|
|
|
|
KeyCode aKeyCode = rKEvt.GetKeyCode();
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) &&
|
2000-09-18 16:07:07 +00:00
|
|
|
((aKeyCode.GetCode() == KEY_RETURN) || (aKeyCode.GetCode() == KEY_SPACE)) )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( GetStyle() & WB_TOGGLE )
|
|
|
|
{
|
|
|
|
if ( IsChecked() )
|
|
|
|
{
|
|
|
|
Check( FALSE );
|
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Check( TRUE );
|
|
|
|
|
|
|
|
Toggle();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplDrawPushButton();
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( !( ( GetStyle() & WB_REPEAT ) &&
|
|
|
|
! ( GetStyle() & WB_TOGGLE ) ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
Click();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Button::KeyUp( rKEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
void PushButton::FillLayoutData() const
|
|
|
|
{
|
|
|
|
mpLayoutData = new vcl::ControlLayoutData();
|
|
|
|
const_cast<PushButton*>(this)->ImplDrawPushButton( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2006-06-19 18:15:23 +00:00
|
|
|
void PushButton::Paint( const Rectangle& )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplDrawPushButton();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::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 );
|
|
|
|
Rectangle aTextRect;
|
|
|
|
Font aFont = GetDrawPixelFont( pDev );
|
|
|
|
|
|
|
|
pDev->Push();
|
|
|
|
pDev->SetMapMode();
|
|
|
|
pDev->SetFont( aFont );
|
|
|
|
if ( nFlags & WINDOW_DRAW_MONO )
|
2003-09-04 06:42:10 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
pDev->SetTextColor( Color( COL_BLACK ) );
|
2003-09-04 06:42:10 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2003-09-04 06:42:10 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
pDev->SetTextColor( GetTextColor() );
|
2003-09-04 06:42:10 +00:00
|
|
|
|
|
|
|
// DecoView uses the FaceColor...
|
|
|
|
AllSettings aSettings = pDev->GetSettings();
|
|
|
|
StyleSettings aStyleSettings = aSettings.GetStyleSettings();
|
|
|
|
if ( IsControlBackground() )
|
|
|
|
aStyleSettings.SetFaceColor( GetControlBackground() );
|
|
|
|
else
|
|
|
|
aStyleSettings.SetFaceColor( GetSettings().GetStyleSettings().GetFaceColor() );
|
|
|
|
aSettings.SetStyleSettings( aStyleSettings );
|
|
|
|
pDev->SetSettings( aSettings );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
pDev->SetTextFillColor();
|
|
|
|
|
|
|
|
DecorationView aDecoView( pDev );
|
|
|
|
USHORT nButtonStyle = 0;
|
|
|
|
if ( nFlags & WINDOW_DRAW_MONO )
|
|
|
|
nButtonStyle |= BUTTON_DRAW_MONO;
|
|
|
|
if ( IsChecked() )
|
|
|
|
nButtonStyle |= BUTTON_DRAW_CHECKED;
|
|
|
|
aRect = aDecoView.DrawButton( aRect, nButtonStyle );
|
|
|
|
|
2006-06-19 18:15:23 +00:00
|
|
|
ImplDrawPushButtonContent( pDev, nFlags, aRect, false );
|
2000-09-18 16:07:07 +00:00
|
|
|
pDev->Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::Resize()
|
|
|
|
{
|
2002-05-08 15:05:42 +00:00
|
|
|
Control::Resize();
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::GetFocus()
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ShowFocus( ImplGetFocusRect() );
|
2000-09-18 16:07:07 +00:00
|
|
|
SetInputContext( InputContext( GetFont() ) );
|
|
|
|
Button::GetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::LoseFocus()
|
|
|
|
{
|
|
|
|
EndSelection();
|
|
|
|
HideFocus();
|
|
|
|
Button::LoseFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
Button::StateChanged( nType );
|
|
|
|
|
|
|
|
if ( (nType == STATE_CHANGE_ENABLE) ||
|
|
|
|
(nType == STATE_CHANGE_TEXT) ||
|
|
|
|
(nType == STATE_CHANGE_IMAGE) ||
|
|
|
|
(nType == STATE_CHANGE_DATA) ||
|
|
|
|
(nType == STATE_CHANGE_STATE) ||
|
|
|
|
(nType == STATE_CHANGE_UPDATEMODE) )
|
|
|
|
{
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_STYLE )
|
|
|
|
{
|
|
|
|
SetStyle( ImplInitStyle( GetWindow( WINDOW_PREV ), GetStyle() ) );
|
|
|
|
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
|
|
|
{
|
|
|
|
if ( (GetPrevStyle() & PUSHBUTTON_VIEW_STYLE) !=
|
|
|
|
(GetStyle() & PUSHBUTTON_VIEW_STYLE) )
|
|
|
|
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 PushButton::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
Button::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
|
|
|
|
(rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
|
|
|
|
((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE)) )
|
|
|
|
{
|
|
|
|
ImplInitSettings( TRUE, TRUE, TRUE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2004-02-20 07:50:15 +00:00
|
|
|
long PushButton::PreNotify( NotifyEvent& rNEvt )
|
|
|
|
{
|
2004-05-10 14:45:59 +00:00
|
|
|
long nDone = 0;
|
|
|
|
const MouseEvent* pMouseEvt = NULL;
|
|
|
|
|
2006-06-19 18:15:23 +00:00
|
|
|
if( (rNEvt.GetType() == EVENT_MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != NULL )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
|
|
|
if( pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow() )
|
|
|
|
{
|
|
|
|
// trigger redraw as mouse over state has changed
|
|
|
|
|
|
|
|
// TODO: move this to Window class or make it a member !!!
|
|
|
|
ControlType aCtrlType = 0;
|
|
|
|
switch( GetParent()->GetType() )
|
|
|
|
{
|
|
|
|
case WINDOW_LISTBOX:
|
|
|
|
case WINDOW_MULTILISTBOX:
|
|
|
|
case WINDOW_TREELISTBOX:
|
|
|
|
aCtrlType = CTRL_LISTBOX;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINDOW_COMBOBOX:
|
|
|
|
case WINDOW_PATTERNBOX:
|
|
|
|
case WINDOW_NUMERICBOX:
|
|
|
|
case WINDOW_METRICBOX:
|
|
|
|
case WINDOW_CURRENCYBOX:
|
|
|
|
case WINDOW_DATEBOX:
|
|
|
|
case WINDOW_TIMEBOX:
|
|
|
|
case WINDOW_LONGCURRENCYBOX:
|
|
|
|
aCtrlType = CTRL_COMBOBOX;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL bDropDown = ( IsSymbol() && (GetSymbol()==SYMBOL_SPIN_DOWN) && !GetText().Len() );
|
|
|
|
|
|
|
|
if( bDropDown && GetParent()->IsNativeControlSupported( aCtrlType, PART_ENTIRE_CONTROL) &&
|
|
|
|
!GetParent()->IsNativeControlSupported( aCtrlType, PART_BUTTON_DOWN) )
|
|
|
|
{
|
|
|
|
Window *pBorder = GetParent()->GetWindow( WINDOW_BORDER );
|
|
|
|
if(aCtrlType == CTRL_COMBOBOX)
|
|
|
|
{
|
|
|
|
// only paint the button part to avoid flickering of the combobox text
|
|
|
|
Point aPt;
|
|
|
|
Rectangle aClipRect( aPt, GetOutputSizePixel() );
|
|
|
|
aClipRect.SetPos(pBorder->ScreenToOutputPixel(OutputToScreenPixel(aClipRect.TopLeft())));
|
|
|
|
pBorder->Invalidate( aClipRect );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pBorder->Invalidate( INVALIDATE_NOERASE );
|
|
|
|
pBorder->Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL) )
|
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nDone ? nDone : Button::PreNotify(rNEvt);
|
2004-02-20 07:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void PushButton::Toggle()
|
|
|
|
{
|
2004-10-22 11:12:18 +00:00
|
|
|
ImplCallEventListenersAndHandler( VCLEVENT_PUSHBUTTON_TOGGLE, maToggleHdl, this );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::SetSymbol( SymbolType eSymbol )
|
|
|
|
{
|
|
|
|
if ( meSymbol != eSymbol )
|
|
|
|
{
|
|
|
|
meSymbol = eSymbol;
|
|
|
|
StateChanged( STATE_CHANGE_DATA );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-25 12:10:56 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void PushButton::SetSymbolAlign( SymbolAlign eAlign )
|
|
|
|
{
|
|
|
|
ImplSetSymbolAlign( eAlign );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
SymbolAlign PushButton::GetSymbolAlign() const
|
|
|
|
{
|
|
|
|
return ImplGetSymbolAlign();
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::SetDropDown( USHORT nStyle )
|
|
|
|
{
|
|
|
|
if ( mnDDStyle != nStyle )
|
|
|
|
{
|
|
|
|
mnDDStyle = nStyle;
|
|
|
|
StateChanged( STATE_CHANGE_DATA );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::SetState( TriState eState )
|
|
|
|
{
|
|
|
|
if ( meState != eState )
|
|
|
|
{
|
|
|
|
meState = eState;
|
|
|
|
if ( meState == STATE_NOCHECK )
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~(BUTTON_DRAW_CHECKED | BUTTON_DRAW_DONTKNOW);
|
2000-09-18 16:07:07 +00:00
|
|
|
else if ( meState == STATE_CHECK )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_DONTKNOW;
|
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_CHECKED;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else // STATE_DONTKNOW
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_CHECKED;
|
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_DONTKNOW;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StateChanged( STATE_CHANGE_STATE );
|
2001-06-15 11:56:11 +00:00
|
|
|
Toggle();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::SetPressed( BOOL bPressed )
|
|
|
|
{
|
|
|
|
if ( mbPressed != bPressed )
|
|
|
|
{
|
|
|
|
mbPressed = bPressed;
|
|
|
|
StateChanged( STATE_CHANGE_DATA );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void PushButton::EndSelection()
|
|
|
|
{
|
|
|
|
EndTracking( ENDTRACK_CANCEL );
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !mbPressed )
|
|
|
|
ImplDrawPushButton();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Size PushButton::CalcMinimumSize( long nMaxWidth ) const
|
|
|
|
{
|
|
|
|
Size aSize;
|
|
|
|
|
|
|
|
if ( IsSymbol() )
|
|
|
|
aSize = Size( 12, 12 );
|
2004-07-05 14:41:27 +00:00
|
|
|
else if ( IsImage() && ! (ImplGetButtonState() & BUTTON_DRAW_NOIMAGE) )
|
|
|
|
aSize = GetModeImage().GetSizePixel();
|
2008-01-14 12:04:30 +00:00
|
|
|
if ( PushButton::GetText().Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ULONG nDrawFlags = 0;
|
2008-01-14 12:04:30 +00:00
|
|
|
Size textSize = GetTextRect( Rectangle( Point(), Size( nMaxWidth ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
|
|
|
|
PushButton::GetText(), ImplGetTextStyle( nDrawFlags ) ).GetSize();
|
|
|
|
aSize.Width() += int( textSize.Width () * 1.15 );
|
|
|
|
aSize.Height() = std::max( aSize.Height(), long( textSize.Height() * 1.15 ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2007-07-03 13:05:08 +00:00
|
|
|
// cf. ImplDrawPushButton ...
|
|
|
|
aSize.Width() += 8;
|
|
|
|
aSize.Height() += 8;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
return CalcWindowSize( aSize );
|
|
|
|
}
|
|
|
|
|
2008-01-14 12:04:30 +00:00
|
|
|
Size PushButton::GetOptimalSize(WindowSizeType eType) const
|
|
|
|
{
|
|
|
|
switch (eType) {
|
|
|
|
case WINDOWSIZE_MINIMUM: {
|
|
|
|
return CalcMinimumSize();
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return Button::GetOptimalSize( eType );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
void OKButton::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
|
|
|
PushButton::ImplInit( pParent, nStyle );
|
|
|
|
|
|
|
|
SetText( Button::GetStandardText( BUTTON_OK ) );
|
|
|
|
SetHelpText( Button::GetStandardHelpText( BUTTON_OK ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
OKButton::OKButton( Window* pParent, WinBits nStyle ) :
|
|
|
|
PushButton( WINDOW_OKBUTTON )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
OKButton::OKButton( Window* pParent, const ResId& rResId ) :
|
|
|
|
PushButton( WINDOW_OKBUTTON )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_OKBUTTON );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void OKButton::Click()
|
|
|
|
{
|
|
|
|
// Ist kein Link gesetzt, dann schliesse Parent
|
2001-11-27 08:54:45 +00:00
|
|
|
if ( !GetClickHdl() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Window* pParent = GetParent();
|
|
|
|
if ( pParent->IsSystemWindow() )
|
|
|
|
{
|
|
|
|
if ( pParent->IsDialog() )
|
|
|
|
{
|
2001-08-07 11:32:22 +00:00
|
|
|
if ( ((Dialog*)pParent)->IsInExecute() )
|
|
|
|
((Dialog*)pParent)->EndDialog( TRUE );
|
2000-09-18 16:07:07 +00:00
|
|
|
// gegen rekursive Aufrufe schuetzen
|
2001-08-07 11:32:22 +00:00
|
|
|
else if ( !((Dialog*)pParent)->IsInClose() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-08-07 11:32:22 +00:00
|
|
|
if ( pParent->GetStyle() & WB_CLOSEABLE )
|
2000-09-18 16:07:07 +00:00
|
|
|
((Dialog*)pParent)->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( pParent->GetStyle() & WB_CLOSEABLE )
|
|
|
|
((SystemWindow*)pParent)->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-11-27 08:54:45 +00:00
|
|
|
else
|
2001-11-08 15:05:45 +00:00
|
|
|
{
|
|
|
|
PushButton::Click();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
void CancelButton::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
|
|
|
PushButton::ImplInit( pParent, nStyle );
|
|
|
|
|
|
|
|
SetText( Button::GetStandardText( BUTTON_CANCEL ) );
|
|
|
|
SetHelpText( Button::GetStandardHelpText( BUTTON_CANCEL ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
CancelButton::CancelButton( Window* pParent, WinBits nStyle ) :
|
|
|
|
PushButton( WINDOW_CANCELBUTTON )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
CancelButton::CancelButton( Window* pParent, const ResId& rResId ) :
|
|
|
|
PushButton( WINDOW_CANCELBUTTON )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_CANCELBUTTON );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CancelButton::Click()
|
|
|
|
{
|
|
|
|
// Ist kein Link gesetzt, dann schliesse Parent
|
2001-11-27 08:54:45 +00:00
|
|
|
if ( !GetClickHdl() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Window* pParent = GetParent();
|
|
|
|
if ( pParent->IsSystemWindow() )
|
|
|
|
{
|
|
|
|
if ( pParent->IsDialog() )
|
|
|
|
{
|
2001-08-07 11:32:22 +00:00
|
|
|
if ( ((Dialog*)pParent)->IsInExecute() )
|
|
|
|
((Dialog*)pParent)->EndDialog( FALSE );
|
2000-09-18 16:07:07 +00:00
|
|
|
// gegen rekursive Aufrufe schuetzen
|
2001-08-07 11:32:22 +00:00
|
|
|
else if ( !((Dialog*)pParent)->IsInClose() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-08-07 11:32:22 +00:00
|
|
|
if ( pParent->GetStyle() & WB_CLOSEABLE )
|
2000-09-18 16:07:07 +00:00
|
|
|
((Dialog*)pParent)->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( pParent->GetStyle() & WB_CLOSEABLE )
|
|
|
|
((SystemWindow*)pParent)->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-11-27 08:54:45 +00:00
|
|
|
else
|
2001-11-08 15:05:45 +00:00
|
|
|
{
|
|
|
|
PushButton::Click();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
void HelpButton::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
|
|
|
PushButton::ImplInit( pParent, nStyle | WB_NOPOINTERFOCUS );
|
|
|
|
|
|
|
|
SetText( Button::GetStandardText( BUTTON_HELP ) );
|
|
|
|
SetHelpText( Button::GetStandardHelpText( BUTTON_HELP ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
HelpButton::HelpButton( Window* pParent, WinBits nStyle ) :
|
|
|
|
PushButton( WINDOW_HELPBUTTON )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
HelpButton::HelpButton( Window* pParent, const ResId& rResId ) :
|
|
|
|
PushButton( WINDOW_HELPBUTTON )
|
|
|
|
{
|
|
|
|
rResId.SetRT( RSC_HELPBUTTON );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void HelpButton::Click()
|
|
|
|
{
|
|
|
|
// Ist kein Link gesetzt, loese Hilfe aus
|
2001-11-27 08:54:45 +00:00
|
|
|
if ( !GetClickHdl() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Window* pFocusWin = Application::GetFocusWindow();
|
|
|
|
if ( !pFocusWin )
|
|
|
|
pFocusWin = this;
|
|
|
|
|
|
|
|
HelpEvent aEvt( pFocusWin->GetPointerPosPixel(), HELPMODE_CONTEXT );
|
|
|
|
pFocusWin->RequestHelp( aEvt );
|
|
|
|
}
|
2001-11-02 09:36:06 +00:00
|
|
|
PushButton::Click();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2006-06-19 18:15:23 +00:00
|
|
|
void RadioButton::ImplInitRadioButtonData()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
mbChecked = FALSE;
|
|
|
|
mbSaveValue = FALSE;
|
|
|
|
mbRadioCheck = TRUE;
|
|
|
|
mbStateChanged = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
|
|
|
nStyle = ImplInitStyle( pParent->GetWindow( WINDOW_LASTCHILD ), nStyle );
|
|
|
|
Button::ImplInit( pParent, nStyle, NULL );
|
|
|
|
|
|
|
|
ImplInitSettings( TRUE, TRUE, TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
WinBits RadioButton::ImplInitStyle( const Window* pPrevWindow, WinBits nStyle )
|
|
|
|
{
|
|
|
|
if ( !(nStyle & WB_NOGROUP) &&
|
|
|
|
(!pPrevWindow || (pPrevWindow->GetType() != WINDOW_RADIOBUTTON)) )
|
|
|
|
nStyle |= WB_GROUP;
|
|
|
|
if ( !(nStyle & WB_NOTABSTOP) )
|
|
|
|
{
|
|
|
|
if ( IsChecked() )
|
|
|
|
nStyle |= WB_TABSTOP;
|
|
|
|
else
|
|
|
|
nStyle &= ~WB_TABSTOP;
|
|
|
|
}
|
|
|
|
return nStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::ImplInitSettings( BOOL bFont,
|
|
|
|
BOOL bForeground, BOOL bBackground )
|
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
|
|
|
|
if ( bFont )
|
|
|
|
{
|
|
|
|
Font aFont = rStyleSettings.GetRadioCheckFont();
|
|
|
|
if ( IsControlFont() )
|
|
|
|
aFont.Merge( GetControlFont() );
|
|
|
|
SetZoomedPointFont( aFont );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bForeground || bFont )
|
|
|
|
{
|
|
|
|
Color aColor;
|
|
|
|
if ( IsControlForeground() )
|
|
|
|
aColor = GetControlForeground();
|
|
|
|
else
|
|
|
|
aColor = rStyleSettings.GetRadioCheckTextColor();
|
|
|
|
SetTextColor( aColor );
|
|
|
|
SetTextFillColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bBackground )
|
|
|
|
{
|
|
|
|
Window* pParent = GetParent();
|
2005-01-31 08:17:00 +00:00
|
|
|
if ( !IsControlBackground() &&
|
|
|
|
(pParent->IsChildTransparentModeEnabled() || IsNativeControlSupported( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL ) ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
EnableChildTransparentMode( TRUE );
|
|
|
|
SetParentClipMode( PARENTCLIPMODE_NOCLIP );
|
|
|
|
SetPaintTransparent( TRUE );
|
|
|
|
SetBackground();
|
2007-07-05 07:38:41 +00:00
|
|
|
if( IsNativeControlSupported( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL ) )
|
|
|
|
mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableChildTransparentMode( FALSE );
|
|
|
|
SetParentClipMode( 0 );
|
|
|
|
SetPaintTransparent( FALSE );
|
|
|
|
|
|
|
|
if ( IsControlBackground() )
|
|
|
|
SetBackground( GetControlBackground() );
|
|
|
|
else
|
|
|
|
SetBackground( pParent->GetBackground() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-17 16:55:28 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//--- 12.03.2003 18:46:14 ---------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::DrawRadioButtonState( )
|
|
|
|
{
|
|
|
|
ImplDrawRadioButtonState( );
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-03-05 16:07:33 +00:00
|
|
|
void RadioButton::ImplInvalidateOrDrawRadioButtonState()
|
|
|
|
{
|
|
|
|
if( ImplGetSVData()->maNWFData.mbCheckBoxNeedsErase )
|
|
|
|
{
|
|
|
|
if ( IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL) )
|
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
Update();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImplDrawRadioButtonState();
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void RadioButton::ImplDrawRadioButtonState()
|
|
|
|
{
|
2006-06-19 18:15:23 +00:00
|
|
|
USHORT nButtonStyle = 0;
|
2004-05-10 14:45:59 +00:00
|
|
|
BOOL bNativeOK = FALSE;
|
|
|
|
|
|
|
|
// no native drawing for image radio buttons
|
|
|
|
if ( !maImage && (bNativeOK=IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL)) == TRUE )
|
|
|
|
{
|
|
|
|
ImplControlValue aControlValue( mbChecked ? BUTTONVALUE_ON : BUTTONVALUE_OFF, rtl::OUString(), 0 );
|
|
|
|
Rectangle aCtrlRect( maStateRect.TopLeft(), maStateRect.GetSize() );
|
|
|
|
Region aCtrlRegion( aCtrlRect );
|
|
|
|
ControlState nState = 0;
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED ) nState |= CTRL_STATE_PRESSED;
|
2004-05-10 14:45:59 +00:00
|
|
|
if ( HasFocus() ) nState |= CTRL_STATE_FOCUSED;
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= CTRL_STATE_DEFAULT;
|
2004-05-10 14:45:59 +00:00
|
|
|
if ( IsEnabled() ) nState |= CTRL_STATE_ENABLED;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-05-10 14:45:59 +00:00
|
|
|
if ( IsMouseOver() && maMouseRect.IsInside( GetPointerPosPixel() ) )
|
|
|
|
nState |= CTRL_STATE_ROLLOVER;
|
|
|
|
|
|
|
|
bNativeOK = DrawNativeControl( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
|
|
|
|
aControlValue,rtl::OUString() );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bNativeOK == FALSE )
|
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
// kein Image-RadioButton
|
|
|
|
if ( !maImage )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
USHORT nStyle = ImplGetButtonState();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !IsEnabled() )
|
|
|
|
nStyle |= BUTTON_DRAW_DISABLED;
|
|
|
|
if ( mbChecked )
|
|
|
|
nStyle |= BUTTON_DRAW_CHECKED;
|
|
|
|
Image aImage = GetRadioImage( GetSettings(), nStyle );
|
|
|
|
if ( IsZoom() )
|
|
|
|
DrawImage( maStateRect.TopLeft(), maStateRect.GetSize(), aImage );
|
|
|
|
else
|
|
|
|
DrawImage( maStateRect.TopLeft(), aImage );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HideFocus();
|
|
|
|
|
|
|
|
DecorationView aDecoView( this );
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
Rectangle aImageRect = maStateRect;
|
|
|
|
Size aImageSize = maImage.GetSizePixel();
|
|
|
|
BOOL bEnabled = IsEnabled();
|
|
|
|
|
|
|
|
aImageSize.Width() = CalcZoom( aImageSize.Width() );
|
|
|
|
aImageSize.Height() = CalcZoom( aImageSize.Height() );
|
|
|
|
|
|
|
|
// Border und Selektionsstatus ausgeben
|
2006-06-19 18:15:23 +00:00
|
|
|
nButtonStyle = FRAME_DRAW_DOUBLEIN;
|
|
|
|
aImageRect = aDecoView.DrawFrame( aImageRect, nButtonStyle );
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) || !bEnabled )
|
2000-09-18 16:07:07 +00:00
|
|
|
SetFillColor( rStyleSettings.GetFaceColor() );
|
|
|
|
else
|
|
|
|
SetFillColor( rStyleSettings.GetFieldColor() );
|
|
|
|
SetLineColor();
|
|
|
|
DrawRect( aImageRect );
|
|
|
|
|
|
|
|
// Image ausgeben
|
2006-06-19 18:15:23 +00:00
|
|
|
nButtonStyle = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !bEnabled )
|
2006-06-19 18:15:23 +00:00
|
|
|
nButtonStyle |= IMAGE_DRAW_DISABLE;
|
2002-04-18 07:11:17 +00:00
|
|
|
|
|
|
|
// check for HC mode
|
|
|
|
Image *pImage = &maImage;
|
|
|
|
Color aBackCol;
|
|
|
|
if( !!maImageHC && ImplGetCurrentBackgroundColor( aBackCol ) )
|
|
|
|
{
|
|
|
|
if( aBackCol.IsDark() )
|
|
|
|
pImage = &maImageHC;
|
2002-08-14 09:15:16 +00:00
|
|
|
// #99902 no col transform required
|
|
|
|
//if( aBackCol.IsBright() )
|
|
|
|
// nStyle |= IMAGE_DRAW_COLORTRANSFORM;
|
2002-04-18 07:11:17 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Point aImagePos( aImageRect.TopLeft() );
|
|
|
|
aImagePos.X() += (aImageRect.GetWidth()-aImageSize.Width())/2;
|
|
|
|
aImagePos.Y() += (aImageRect.GetHeight()-aImageSize.Height())/2;
|
|
|
|
if ( IsZoom() )
|
2006-06-19 18:15:23 +00:00
|
|
|
DrawImage( aImagePos, aImageSize, *pImage, nButtonStyle );
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2006-06-19 18:15:23 +00:00
|
|
|
DrawImage( aImagePos, *pImage, nButtonStyle );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aImageRect.Left()++;
|
|
|
|
aImageRect.Top()++;
|
|
|
|
aImageRect.Right()--;
|
|
|
|
aImageRect.Bottom()--;
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplSetFocusRect( aImageRect );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( mbChecked )
|
|
|
|
{
|
|
|
|
SetLineColor( rStyleSettings.GetHighlightColor() );
|
|
|
|
SetFillColor();
|
|
|
|
if ( (aImageSize.Width() >= 20) || (aImageSize.Height() >= 20) )
|
|
|
|
{
|
|
|
|
aImageRect.Left()++;
|
|
|
|
aImageRect.Top()++;
|
|
|
|
aImageRect.Right()--;
|
|
|
|
aImageRect.Bottom()--;
|
|
|
|
}
|
|
|
|
DrawRect( aImageRect );
|
|
|
|
aImageRect.Left()++;
|
|
|
|
aImageRect.Top()++;
|
|
|
|
aImageRect.Right()--;
|
|
|
|
aImageRect.Bottom()--;
|
|
|
|
DrawRect( aImageRect );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( HasFocus() )
|
2004-07-05 14:41:27 +00:00
|
|
|
ShowFocus( ImplGetFocusRect() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2004-05-10 14:45:59 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags,
|
|
|
|
const Point& rPos, const Size& rSize,
|
|
|
|
const Size& rImageSize, long nImageSep,
|
|
|
|
Rectangle& rStateRect,
|
|
|
|
Rectangle& rMouseRect,
|
2002-04-29 16:46:18 +00:00
|
|
|
bool bLayout )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
WinBits nWinStyle = GetStyle();
|
|
|
|
XubString aText( GetText() );
|
|
|
|
Rectangle aRect( rPos, rSize );
|
2002-04-29 16:46:18 +00:00
|
|
|
MetricVector* pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : NULL;
|
|
|
|
String* pDisplayText = bLayout ? &mpLayoutData->m_aDisplayText : NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-03-29 10:25:02 +00:00
|
|
|
pDev->Push( PUSH_CLIPREGION );
|
|
|
|
pDev->IntersectClipRegion( Rectangle( rPos, rSize ) );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// kein Image-RadioButton
|
|
|
|
if ( !maImage )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) ) ||
|
|
|
|
( HasImage() && ! (ImplGetButtonState() & BUTTON_DRAW_NOIMAGE) ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
USHORT nTextStyle = Button::ImplGetTextStyle( aText, nWinStyle, nDrawFlags );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
Size aSize( rSize );
|
|
|
|
Point aPos( rPos );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
aPos.X() += rImageSize.Width() + nImageSep;
|
|
|
|
aSize.Width() -= rImageSize.Width() + nImageSep;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2008-03-05 16:07:33 +00:00
|
|
|
// if the text rect height is smaller than the height of the image
|
|
|
|
// then for single lines the default should be centered text
|
|
|
|
if( (nWinStyle & (WB_TOP|WB_CENTER|WB_BOTTOM)) == 0 &&
|
|
|
|
(rImageSize.Height() > rSize.Height() || ! (nWinStyle & WB_WORDBREAK) ) )
|
|
|
|
{
|
|
|
|
nTextStyle &= ~(TEXT_DRAW_TOP|TEXT_DRAW_BOTTOM);
|
|
|
|
nTextStyle |= TEXT_DRAW_VCENTER;
|
|
|
|
aSize.Height() = rImageSize.Height();
|
|
|
|
}
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, 1,
|
|
|
|
nDrawFlags, nTextStyle, NULL );
|
|
|
|
|
|
|
|
rMouseRect = Rectangle( aPos, aSize );
|
2000-09-18 16:07:07 +00:00
|
|
|
rMouseRect.Left() = rPos.X();
|
2004-07-05 14:41:27 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
rStateRect.Left() = rPos.X();
|
|
|
|
rStateRect.Top() = rMouseRect.Top();
|
2004-07-05 14:41:27 +00:00
|
|
|
|
|
|
|
if ( aSize.Height() > rImageSize.Height() )
|
|
|
|
rStateRect.Top() += ( aSize.Height() - rImageSize.Height() ) / 2;
|
2008-03-05 16:07:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
rStateRect.Top() -= ( rImageSize.Height() - aSize.Height() ) / 2;
|
|
|
|
if( rStateRect.Top() < 0 )
|
|
|
|
rStateRect.Top() = 0;
|
|
|
|
}
|
2004-07-05 14:41:27 +00:00
|
|
|
|
|
|
|
rStateRect.Right() = rStateRect.Left() + rImageSize.Width()-1;
|
|
|
|
rStateRect.Bottom() = rStateRect.Top() + rImageSize.Height()-1;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( rStateRect.Bottom() > rMouseRect.Bottom() )
|
|
|
|
rMouseRect.Bottom() = rStateRect.Bottom();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( nWinStyle & WB_CENTER )
|
|
|
|
rStateRect.Left() = rPos.X()+((rSize.Width()-rImageSize.Width())/2);
|
|
|
|
else if ( nWinStyle & WB_RIGHT )
|
|
|
|
rStateRect.Left() = rPos.X()+rSize.Width()-rImageSize.Width(); //-1;
|
|
|
|
else
|
|
|
|
rStateRect.Left() = rPos.X(); //+1;
|
|
|
|
if ( nWinStyle & WB_VCENTER )
|
|
|
|
rStateRect.Top() = rPos.Y()+((rSize.Height()-rImageSize.Height())/2);
|
|
|
|
else if ( nWinStyle & WB_BOTTOM )
|
|
|
|
rStateRect.Top() = rPos.Y()+rSize.Height()-rImageSize.Height(); //-1;
|
|
|
|
else
|
|
|
|
rStateRect.Top() = rPos.Y(); //+1;
|
|
|
|
rStateRect.Right() = rStateRect.Left()+rImageSize.Width()-1;
|
|
|
|
rStateRect.Bottom() = rStateRect.Top()+rImageSize.Height()-1;
|
|
|
|
rMouseRect = rStateRect;
|
2004-07-05 14:41:27 +00:00
|
|
|
|
|
|
|
ImplSetFocusRect( rStateRect );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
/* und oben -1, da CalcSize() auch Focus-Rechteck nicht mit einrechnet,
|
|
|
|
da im Writer ansonsten die Images noch weiter oben haengen
|
|
|
|
rFocusRect = rStateRect;
|
|
|
|
rFocusRect.Left()--;
|
|
|
|
rFocusRect.Top()--;
|
|
|
|
rFocusRect.Right()++;
|
|
|
|
rFocusRect.Bottom()++;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BOOL bTopImage = (nWinStyle & WB_TOP) != 0;
|
|
|
|
Size aImageSize = maImage.GetSizePixel();
|
|
|
|
Rectangle aImageRect( rPos, rSize );
|
|
|
|
long nTextHeight = pDev->GetTextHeight();
|
|
|
|
long nTextWidth = pDev->GetCtrlTextWidth( aText );
|
|
|
|
|
|
|
|
// Positionen und Groessen berechnen
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Size aTmpSize( (aImageSize.Width()+8), (aImageSize.Height()+8) );
|
|
|
|
if ( bTopImage )
|
|
|
|
{
|
|
|
|
aImageRect.Left() = (rSize.Width()-aTmpSize.Width())/2;
|
|
|
|
aImageRect.Top() = (rSize.Height()-(aTmpSize.Height()+nTextHeight+6))/2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aImageRect.Top() = (rSize.Height()-aTmpSize.Height())/2;
|
|
|
|
|
|
|
|
aImageRect.Right() = aImageRect.Left()+aTmpSize.Width();
|
|
|
|
aImageRect.Bottom() = aImageRect.Top()+aTmpSize.Height();
|
|
|
|
|
2002-07-04 17:17:19 +00:00
|
|
|
// Text ausgeben
|
2000-09-18 16:07:07 +00:00
|
|
|
Point aTxtPos = rPos;
|
|
|
|
if ( bTopImage )
|
|
|
|
{
|
|
|
|
aTxtPos.X() += (rSize.Width()-nTextWidth)/2;
|
|
|
|
aTxtPos.Y() += aImageRect.Bottom()+6;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aTxtPos.X() += aImageRect.Right()+8;
|
|
|
|
aTxtPos.Y() += (rSize.Height()-nTextHeight)/2;
|
|
|
|
}
|
2002-04-29 16:46:18 +00:00
|
|
|
pDev->DrawCtrlText( aTxtPos, aText, 0, STRING_LEN, TEXT_DRAW_MNEMONIC, pVector, pDisplayText );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rMouseRect = aImageRect;
|
|
|
|
rStateRect = aImageRect;
|
|
|
|
}
|
2006-03-29 10:25:02 +00:00
|
|
|
|
|
|
|
pDev->Pop();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
void RadioButton::ImplDrawRadioButton( bool bLayout )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-04-29 16:46:18 +00:00
|
|
|
if( !bLayout )
|
|
|
|
HideFocus();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
Size aImageSize;
|
|
|
|
if ( !maImage )
|
2005-03-18 16:51:14 +00:00
|
|
|
aImageSize = ImplGetRadioImageSize();
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
aImageSize = maImage.GetSizePixel();
|
|
|
|
aImageSize.Width() = CalcZoom( aImageSize.Width() );
|
|
|
|
aImageSize.Height() = CalcZoom( aImageSize.Height() );
|
|
|
|
|
2004-05-10 14:45:59 +00:00
|
|
|
// Draw control text
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplDraw( this, 0, Point(), GetOutputSizePixel(),
|
2004-07-05 14:41:27 +00:00
|
|
|
aImageSize, IMPL_SEP_BUTTON_IMAGE, maStateRect, maMouseRect, bLayout );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-05-10 14:45:59 +00:00
|
|
|
if( !bLayout || (IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL)==TRUE) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( !maImage && HasFocus() )
|
|
|
|
ShowFocus( ImplGetFocusRect() );
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
ImplDrawRadioButtonState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-01-28 13:16:22 +00:00
|
|
|
void RadioButton::GetRadioButtonGroup( std::vector< RadioButton* >& io_rGroup, bool bIncludeThis ) const
|
|
|
|
{
|
|
|
|
// empty the list
|
|
|
|
io_rGroup.clear();
|
|
|
|
|
|
|
|
// go back to first in group;
|
|
|
|
Window* pFirst = const_cast<RadioButton*>(this);
|
|
|
|
while( ( pFirst->GetStyle() & WB_GROUP ) == 0 )
|
|
|
|
{
|
|
|
|
Window* pWindow = pFirst->GetWindow( WINDOW_PREV );
|
|
|
|
if( pWindow )
|
|
|
|
pFirst = pWindow;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// insert radiobuttons up to next group
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if( pFirst->GetType() == WINDOW_RADIOBUTTON )
|
|
|
|
{
|
|
|
|
if( pFirst != this || bIncludeThis )
|
|
|
|
io_rGroup.push_back( static_cast<RadioButton*>(pFirst) );
|
|
|
|
}
|
|
|
|
pFirst = pFirst->GetWindow( WINDOW_NEXT );
|
|
|
|
} while( pFirst && ( ( pFirst->GetStyle() & WB_GROUP ) == 0 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void RadioButton::ImplUncheckAllOther()
|
|
|
|
{
|
2005-01-13 16:58:41 +00:00
|
|
|
mpWindowImpl->mnStyle |= WB_TABSTOP;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Gruppe mit RadioButtons durchgehen und die gecheckten Buttons
|
|
|
|
Window* pWindow;
|
|
|
|
WinBits nStyle;
|
|
|
|
if ( !(GetStyle() & WB_GROUP) )
|
|
|
|
{
|
|
|
|
pWindow = GetWindow( WINDOW_PREV );
|
|
|
|
while ( pWindow )
|
|
|
|
{
|
|
|
|
nStyle = pWindow->GetStyle();
|
|
|
|
|
|
|
|
if ( pWindow->GetType() == WINDOW_RADIOBUTTON )
|
|
|
|
{
|
|
|
|
if ( ((RadioButton*)pWindow)->IsChecked() )
|
|
|
|
{
|
|
|
|
ImplDelData aDelData;
|
|
|
|
pWindow->ImplAddDel( &aDelData );
|
|
|
|
((RadioButton*)pWindow)->SetState( FALSE );
|
|
|
|
if ( aDelData.IsDelete() )
|
|
|
|
return;
|
|
|
|
pWindow->ImplRemoveDel( &aDelData );
|
|
|
|
}
|
|
|
|
// Um falsch gesetzt WB_TABSTOPS immer zu entfernen, nicht
|
|
|
|
// innerhalb der if-Abfrage
|
2005-01-13 16:58:41 +00:00
|
|
|
pWindow->mpWindowImpl->mnStyle &= ~WB_TABSTOP;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( nStyle & WB_GROUP )
|
|
|
|
break;
|
|
|
|
|
|
|
|
pWindow = pWindow->GetWindow( WINDOW_PREV );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pWindow = GetWindow( WINDOW_NEXT );
|
|
|
|
while ( pWindow )
|
|
|
|
{
|
|
|
|
nStyle = pWindow->GetStyle();
|
|
|
|
|
|
|
|
if ( nStyle & WB_GROUP )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ( pWindow->GetType() == WINDOW_RADIOBUTTON )
|
|
|
|
{
|
|
|
|
if ( ((RadioButton*)pWindow)->IsChecked() )
|
|
|
|
{
|
|
|
|
ImplDelData aDelData;
|
|
|
|
pWindow->ImplAddDel( &aDelData );
|
|
|
|
((RadioButton*)pWindow)->SetState( FALSE );
|
|
|
|
if ( aDelData.IsDelete() )
|
|
|
|
return;
|
|
|
|
pWindow->ImplRemoveDel( &aDelData );
|
|
|
|
}
|
|
|
|
// Um falsch gesetzt WB_TABSTOPS immer zu entfernen, nicht
|
|
|
|
// innerhalb der if-Abfrage
|
2005-01-13 16:58:41 +00:00
|
|
|
pWindow->mpWindowImpl->mnStyle &= ~WB_TABSTOP;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pWindow = pWindow->GetWindow( WINDOW_NEXT );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::ImplCallClick( BOOL bGrabFocus, USHORT nFocusFlags )
|
|
|
|
{
|
|
|
|
mbStateChanged = !mbChecked;
|
|
|
|
mbChecked = TRUE;
|
2005-01-13 16:58:41 +00:00
|
|
|
mpWindowImpl->mnStyle |= WB_TABSTOP;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawRadioButtonState();
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplDelData aDelData;
|
|
|
|
ImplAddDel( &aDelData );
|
|
|
|
if ( mbRadioCheck )
|
|
|
|
ImplUncheckAllOther();
|
|
|
|
if ( aDelData.IsDelete() )
|
|
|
|
return;
|
|
|
|
if ( bGrabFocus )
|
|
|
|
ImplGrabFocus( nFocusFlags );
|
|
|
|
if ( aDelData.IsDelete() )
|
|
|
|
return;
|
|
|
|
if ( mbStateChanged )
|
|
|
|
Toggle();
|
|
|
|
if ( aDelData.IsDelete() )
|
|
|
|
return;
|
|
|
|
Click();
|
|
|
|
if ( aDelData.IsDelete() )
|
|
|
|
return;
|
|
|
|
ImplRemoveDel( &aDelData );
|
|
|
|
mbStateChanged = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
RadioButton::RadioButton( Window* pParent, WinBits nStyle ) :
|
|
|
|
Button( WINDOW_RADIOBUTTON )
|
|
|
|
{
|
2006-06-19 18:15:23 +00:00
|
|
|
ImplInitRadioButtonData();
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
RadioButton::RadioButton( Window* pParent, const ResId& rResId ) :
|
|
|
|
Button( WINDOW_RADIOBUTTON )
|
|
|
|
{
|
2006-06-19 18:15:23 +00:00
|
|
|
ImplInitRadioButtonData();
|
2000-09-18 16:07:07 +00:00
|
|
|
rResId.SetRT( RSC_RADIOBUTTON );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::ImplLoadRes( const ResId& rResId )
|
|
|
|
{
|
|
|
|
Button::ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
//anderer Wert als Default ?
|
|
|
|
USHORT nChecked = ReadShortRes();
|
|
|
|
if ( nChecked )
|
|
|
|
SetState( TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
RadioButton::~RadioButton()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::MouseButtonDown( const MouseEvent& rMEvt )
|
|
|
|
{
|
|
|
|
if ( rMEvt.IsLeft() && maMouseRect.IsInside( rMEvt.GetPosPixel() ) )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawRadioButtonState();
|
2000-09-18 16:07:07 +00:00
|
|
|
StartTracking();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Button::MouseButtonDown( rMEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::Tracking( const TrackingEvent& rTEvt )
|
|
|
|
{
|
|
|
|
if ( rTEvt.IsTrackingEnded() )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
|
|
|
|
GrabFocus();
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Bei Abbruch kein Click-Handler rufen
|
|
|
|
if ( !rTEvt.IsTrackingCanceled() )
|
|
|
|
ImplCallClick();
|
|
|
|
else
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawRadioButtonState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( maMouseRect.IsInside( rTEvt.GetMouseEvent().GetPosPixel() ) )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawRadioButtonState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawRadioButtonState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::KeyInput( const KeyEvent& rKEvt )
|
|
|
|
{
|
|
|
|
KeyCode aKeyCode = rKEvt.GetKeyCode();
|
|
|
|
|
|
|
|
if ( !aKeyCode.GetModifier() && (aKeyCode.GetCode() == KEY_SPACE) )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawRadioButtonState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2004-07-05 14:41:27 +00:00
|
|
|
else if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_ESCAPE) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawRadioButtonState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Button::KeyInput( rKEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::KeyUp( const KeyEvent& rKEvt )
|
|
|
|
{
|
|
|
|
KeyCode aKeyCode = rKEvt.GetKeyCode();
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_SPACE) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplCallClick();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Button::KeyUp( rKEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
void RadioButton::FillLayoutData() const
|
|
|
|
{
|
|
|
|
mpLayoutData = new vcl::ControlLayoutData();
|
|
|
|
const_cast<RadioButton*>(this)->ImplDrawRadioButton( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2006-06-19 18:15:23 +00:00
|
|
|
void RadioButton::Paint( const Rectangle& )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplDrawRadioButton();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
|
|
|
|
ULONG nFlags )
|
|
|
|
{
|
|
|
|
if ( !maImage )
|
|
|
|
{
|
|
|
|
MapMode aResMapMode( MAP_100TH_MM );
|
|
|
|
Point aPos = pDev->LogicToPixel( rPos );
|
|
|
|
Size aSize = pDev->LogicToPixel( rSize );
|
|
|
|
Size aImageSize = pDev->LogicToPixel( Size( 300, 300 ), aResMapMode );
|
|
|
|
Size aBrd1Size = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
|
|
|
|
Size aBrd2Size = pDev->LogicToPixel( Size( 60, 60 ), aResMapMode );
|
|
|
|
Font aFont = GetDrawPixelFont( pDev );
|
|
|
|
Rectangle aStateRect;
|
|
|
|
Rectangle aMouseRect;
|
|
|
|
Rectangle aFocusRect;
|
|
|
|
|
|
|
|
aImageSize.Width() = CalcZoom( aImageSize.Width() );
|
|
|
|
aImageSize.Height() = CalcZoom( aImageSize.Height() );
|
|
|
|
aBrd1Size.Width() = CalcZoom( aBrd1Size.Width() );
|
|
|
|
aBrd1Size.Height() = CalcZoom( aBrd1Size.Height() );
|
|
|
|
aBrd2Size.Width() = CalcZoom( aBrd2Size.Width() );
|
|
|
|
aBrd2Size.Height() = CalcZoom( aBrd2Size.Height() );
|
|
|
|
|
|
|
|
if ( !aBrd1Size.Width() )
|
|
|
|
aBrd1Size.Width() = 1;
|
|
|
|
if ( !aBrd1Size.Height() )
|
|
|
|
aBrd1Size.Height() = 1;
|
|
|
|
if ( !aBrd2Size.Width() )
|
|
|
|
aBrd2Size.Width() = 1;
|
|
|
|
if ( !aBrd2Size.Height() )
|
|
|
|
aBrd2Size.Height() = 1;
|
|
|
|
|
|
|
|
pDev->Push();
|
|
|
|
pDev->SetMapMode();
|
|
|
|
pDev->SetFont( aFont );
|
|
|
|
if ( nFlags & WINDOW_DRAW_MONO )
|
|
|
|
pDev->SetTextColor( Color( COL_BLACK ) );
|
|
|
|
else
|
|
|
|
pDev->SetTextColor( GetTextColor() );
|
|
|
|
pDev->SetTextFillColor();
|
|
|
|
|
|
|
|
ImplDraw( pDev, nFlags, aPos, aSize,
|
|
|
|
aImageSize, GetDrawPixel( pDev, IMPL_SEP_BUTTON_IMAGE ),
|
2004-07-05 14:41:27 +00:00
|
|
|
aStateRect, aMouseRect );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
Point aCenterPos = aStateRect.Center();
|
|
|
|
long nRadX = aImageSize.Width()/2;
|
|
|
|
long nRadY = aImageSize.Height()/2;
|
|
|
|
|
|
|
|
pDev->SetLineColor();
|
|
|
|
pDev->SetFillColor( Color( COL_BLACK ) );
|
|
|
|
pDev->DrawPolygon( Polygon( aCenterPos, nRadX, nRadY ) );
|
|
|
|
nRadX -= aBrd1Size.Width();
|
|
|
|
nRadY -= aBrd1Size.Height();
|
|
|
|
pDev->SetFillColor( Color( COL_WHITE ) );
|
|
|
|
pDev->DrawPolygon( Polygon( aCenterPos, nRadX, nRadY ) );
|
|
|
|
if ( mbChecked )
|
|
|
|
{
|
|
|
|
nRadX -= aBrd1Size.Width();
|
|
|
|
nRadY -= aBrd1Size.Height();
|
|
|
|
if ( !nRadX )
|
|
|
|
nRadX = 1;
|
|
|
|
if ( !nRadY )
|
|
|
|
nRadY = 1;
|
|
|
|
pDev->SetFillColor( Color( COL_BLACK ) );
|
|
|
|
pDev->DrawPolygon( Polygon( aCenterPos, nRadX, nRadY ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
pDev->Pop();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ERROR( "RadioButton::Draw() - not implemented for RadioButton with Image" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::Resize()
|
|
|
|
{
|
2002-05-08 15:05:42 +00:00
|
|
|
Control::Resize();
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::GetFocus()
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ShowFocus( ImplGetFocusRect() );
|
2000-09-18 16:07:07 +00:00
|
|
|
SetInputContext( InputContext( GetFont() ) );
|
|
|
|
Button::GetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::LoseFocus()
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawRadioButtonState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HideFocus();
|
|
|
|
Button::LoseFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
Button::StateChanged( nType );
|
|
|
|
|
|
|
|
if ( nType == STATE_CHANGE_STATE )
|
|
|
|
{
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
2005-04-12 11:18:06 +00:00
|
|
|
Invalidate( maStateRect );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if ( (nType == STATE_CHANGE_ENABLE) ||
|
|
|
|
(nType == STATE_CHANGE_TEXT) ||
|
|
|
|
(nType == STATE_CHANGE_IMAGE) ||
|
|
|
|
(nType == STATE_CHANGE_DATA) ||
|
|
|
|
(nType == STATE_CHANGE_UPDATEMODE) )
|
|
|
|
{
|
|
|
|
if ( IsUpdateMode() )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_STYLE )
|
|
|
|
{
|
|
|
|
SetStyle( ImplInitStyle( GetWindow( WINDOW_PREV ), GetStyle() ) );
|
|
|
|
|
|
|
|
if ( (GetPrevStyle() & RADIOBUTTON_VIEW_STYLE) !=
|
|
|
|
(GetStyle() & RADIOBUTTON_VIEW_STYLE) )
|
|
|
|
{
|
|
|
|
if ( IsUpdateMode() )
|
|
|
|
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 RadioButton::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
Button::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
|
|
|
|
(rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
|
|
|
|
((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE)) )
|
|
|
|
{
|
|
|
|
ImplInitSettings( TRUE, TRUE, TRUE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2004-02-20 07:50:15 +00:00
|
|
|
long RadioButton::PreNotify( NotifyEvent& rNEvt )
|
|
|
|
{
|
2004-05-10 14:45:59 +00:00
|
|
|
long nDone = 0;
|
|
|
|
const MouseEvent* pMouseEvt = NULL;
|
|
|
|
|
2006-06-19 18:15:23 +00:00
|
|
|
if( (rNEvt.GetType() == EVENT_MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != NULL )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
|
|
|
if( !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
|
|
|
|
{
|
|
|
|
// trigger redraw if mouse over state has changed
|
|
|
|
if( IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL) )
|
|
|
|
{
|
|
|
|
if( ( maMouseRect.IsInside( GetPointerPosPixel()) &&
|
|
|
|
!maMouseRect.IsInside( GetLastPointerPosPixel()) ) ||
|
|
|
|
( maMouseRect.IsInside( GetLastPointerPosPixel()) &&
|
|
|
|
!maMouseRect.IsInside( GetPointerPosPixel()) ) ||
|
|
|
|
pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow() )
|
|
|
|
{
|
|
|
|
Invalidate( maStateRect );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nDone ? nDone : Button::PreNotify(rNEvt);
|
2004-02-20 07:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void RadioButton::Toggle()
|
|
|
|
{
|
2004-10-22 11:12:18 +00:00
|
|
|
ImplCallEventListenersAndHandler( VCLEVENT_RADIOBUTTON_TOGGLE, maToggleHdl, this );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
BOOL RadioButton::SetModeRadioImage( const Image& rImage, BmpColorMode eMode )
|
|
|
|
{
|
|
|
|
if( eMode == BMP_COLOR_NORMAL )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( rImage != maImage )
|
|
|
|
{
|
|
|
|
maImage = rImage;
|
|
|
|
StateChanged( STATE_CHANGE_DATA );
|
|
|
|
}
|
|
|
|
}
|
2002-04-18 07:11:17 +00:00
|
|
|
else if( eMode == BMP_COLOR_HIGHCONTRAST )
|
|
|
|
{
|
|
|
|
if( maImageHC != rImage )
|
|
|
|
{
|
|
|
|
maImageHC = rImage;
|
|
|
|
StateChanged( STATE_CHANGE_DATA );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
2004-07-05 14:41:27 +00:00
|
|
|
|
2002-04-18 07:11:17 +00:00
|
|
|
return TRUE;
|
2002-03-05 08:20:36 +00:00
|
|
|
}
|
|
|
|
|
2002-04-18 07:11:17 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
const Image& RadioButton::GetModeRadioImage( BmpColorMode eMode ) const
|
2002-03-05 08:20:36 +00:00
|
|
|
{
|
2002-04-18 07:11:17 +00:00
|
|
|
if( eMode == BMP_COLOR_HIGHCONTRAST )
|
|
|
|
return maImageHC;
|
|
|
|
else
|
|
|
|
return maImage;
|
2002-03-05 08:20:36 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::SetState( BOOL bCheck )
|
|
|
|
{
|
|
|
|
// TabStop-Flag richtig mitfuehren
|
|
|
|
if ( bCheck )
|
2005-01-13 16:58:41 +00:00
|
|
|
mpWindowImpl->mnStyle |= WB_TABSTOP;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2005-01-13 16:58:41 +00:00
|
|
|
mpWindowImpl->mnStyle &= ~WB_TABSTOP;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( mbChecked != bCheck )
|
|
|
|
{
|
|
|
|
mbChecked = bCheck;
|
|
|
|
StateChanged( STATE_CHANGE_STATE );
|
2001-06-15 11:56:11 +00:00
|
|
|
Toggle();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RadioButton::Check( BOOL bCheck )
|
|
|
|
{
|
|
|
|
// TabStop-Flag richtig mitfuehren
|
|
|
|
if ( bCheck )
|
2005-01-13 16:58:41 +00:00
|
|
|
mpWindowImpl->mnStyle |= WB_TABSTOP;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2005-01-13 16:58:41 +00:00
|
|
|
mpWindowImpl->mnStyle &= ~WB_TABSTOP;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( mbChecked != bCheck )
|
|
|
|
{
|
|
|
|
mbChecked = bCheck;
|
|
|
|
ImplDelData aDelData;
|
|
|
|
ImplAddDel( &aDelData );
|
|
|
|
StateChanged( STATE_CHANGE_STATE );
|
|
|
|
if ( aDelData.IsDelete() )
|
|
|
|
return;
|
|
|
|
if ( bCheck && mbRadioCheck )
|
|
|
|
ImplUncheckAllOther();
|
2001-06-15 11:56:11 +00:00
|
|
|
if ( aDelData.IsDelete() )
|
|
|
|
return;
|
|
|
|
Toggle();
|
|
|
|
ImplRemoveDel( &aDelData );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2005-03-18 16:51:14 +00:00
|
|
|
Size RadioButton::ImplGetRadioImageSize() const
|
|
|
|
{
|
|
|
|
Size aSize;
|
|
|
|
// why are IsNativeControlSupported and GetNativeControlRegion not const ?
|
|
|
|
RadioButton* pThis = const_cast<RadioButton*>(this);
|
|
|
|
bool bDefaultSize = true;
|
|
|
|
if( pThis->IsNativeControlSupported( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL ) )
|
|
|
|
{
|
|
|
|
ImplControlValue aControlValue;
|
2005-04-12 11:18:06 +00:00
|
|
|
// #i45896# workaround gcc3.3 temporary problem
|
|
|
|
Region aCtrlRegion = Region( Rectangle( Point( 0, 0 ), GetSizePixel() ) );
|
2005-03-18 16:51:14 +00:00
|
|
|
ControlState nState = CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED;
|
|
|
|
Region aBoundingRgn, aContentRgn;
|
|
|
|
|
|
|
|
// get native size of a radio button
|
|
|
|
if( pThis->GetNativeControlRegion( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion,
|
|
|
|
nState, aControlValue, rtl::OUString(),
|
|
|
|
aBoundingRgn, aContentRgn ) )
|
|
|
|
{
|
|
|
|
Rectangle aCont(aContentRgn.GetBoundRect());
|
|
|
|
aSize = aCont.GetSize();
|
|
|
|
bDefaultSize = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( bDefaultSize )
|
|
|
|
aSize = GetRadioImage( GetSettings(), 0 ).GetSizePixel();
|
|
|
|
return aSize;
|
|
|
|
}
|
|
|
|
|
2007-06-06 13:21:07 +00:00
|
|
|
static void LoadThemedImageList (const StyleSettings &rStyleSettings,
|
|
|
|
ImageList *pList, const ResId &rResId,
|
|
|
|
USHORT nImages)
|
|
|
|
{
|
2007-12-12 12:19:37 +00:00
|
|
|
Color aColorAry1[6];
|
|
|
|
Color aColorAry2[6];
|
|
|
|
aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 );
|
|
|
|
aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 );
|
|
|
|
aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF );
|
|
|
|
aColorAry1[3] = Color( 0x80, 0x80, 0x80 );
|
|
|
|
aColorAry1[4] = Color( 0x00, 0x00, 0x00 );
|
|
|
|
aColorAry1[5] = Color( 0x00, 0xFF, 0x00 );
|
|
|
|
aColorAry2[0] = rStyleSettings.GetFaceColor();
|
|
|
|
aColorAry2[1] = rStyleSettings.GetWindowColor();
|
|
|
|
aColorAry2[2] = rStyleSettings.GetLightColor();
|
|
|
|
aColorAry2[3] = rStyleSettings.GetShadowColor();
|
|
|
|
aColorAry2[4] = rStyleSettings.GetDarkShadowColor();
|
|
|
|
aColorAry2[5] = rStyleSettings.GetWindowTextColor();
|
2007-06-06 13:21:07 +00:00
|
|
|
|
|
|
|
Color aMaskColor(0x00, 0x00, 0xFF );
|
2007-12-12 12:19:37 +00:00
|
|
|
DBG_ASSERT( sizeof(aColorAry1) == sizeof(aColorAry2), "aColorAry1 must match aColorAry2" );
|
2007-06-06 13:21:07 +00:00
|
|
|
// FIXME: do we want the mask for the checkbox ?
|
|
|
|
pList->InsertFromHorizontalBitmap (rResId, nImages, &aMaskColor,
|
2007-12-12 12:19:37 +00:00
|
|
|
aColorAry1, aColorAry2, sizeof(aColorAry1) / sizeof(Color));
|
2007-06-06 13:21:07 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Image RadioButton::GetRadioImage( const AllSettings& rSettings, USHORT nFlags )
|
|
|
|
{
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
|
|
const StyleSettings& rStyleSettings = rSettings.GetStyleSettings();
|
|
|
|
USHORT nStyle = rStyleSettings.GetRadioButtonStyle() & STYLE_RADIOBUTTON_STYLE;
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
|
|
|
|
nStyle = STYLE_RADIOBUTTON_MONO;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !pSVData->maCtrlData.mpRadioImgList ||
|
|
|
|
(pSVData->maCtrlData.mnRadioStyle != nStyle) ||
|
|
|
|
(pSVData->maCtrlData.mnLastRadioFColor != rStyleSettings.GetFaceColor().GetColor()) ||
|
|
|
|
(pSVData->maCtrlData.mnLastRadioWColor != rStyleSettings.GetWindowColor().GetColor()) ||
|
|
|
|
(pSVData->maCtrlData.mnLastRadioLColor != rStyleSettings.GetLightColor().GetColor()) )
|
|
|
|
{
|
|
|
|
if ( pSVData->maCtrlData.mpRadioImgList )
|
|
|
|
delete pSVData->maCtrlData.mpRadioImgList;
|
|
|
|
|
|
|
|
pSVData->maCtrlData.mnLastRadioFColor = rStyleSettings.GetFaceColor().GetColor();
|
|
|
|
pSVData->maCtrlData.mnLastRadioWColor = rStyleSettings.GetWindowColor().GetColor();
|
|
|
|
pSVData->maCtrlData.mnLastRadioLColor = rStyleSettings.GetLightColor().GetColor();
|
|
|
|
|
2007-06-06 13:21:07 +00:00
|
|
|
Color pColorAry1[6];
|
|
|
|
Color pColorAry2[6];
|
2000-09-18 16:07:07 +00:00
|
|
|
pColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 );
|
|
|
|
pColorAry1[1] = Color( 0xFF, 0xFF, 0x00 );
|
|
|
|
pColorAry1[2] = Color( 0xFF, 0xFF, 0xFF );
|
|
|
|
pColorAry1[3] = Color( 0x80, 0x80, 0x80 );
|
|
|
|
pColorAry1[4] = Color( 0x00, 0x00, 0x00 );
|
|
|
|
pColorAry1[5] = Color( 0x00, 0xFF, 0x00 );
|
|
|
|
pColorAry2[0] = rStyleSettings.GetFaceColor();
|
|
|
|
pColorAry2[1] = rStyleSettings.GetWindowColor();
|
|
|
|
pColorAry2[2] = rStyleSettings.GetLightColor();
|
|
|
|
pColorAry2[3] = rStyleSettings.GetShadowColor();
|
|
|
|
pColorAry2[4] = rStyleSettings.GetDarkShadowColor();
|
|
|
|
pColorAry2[5] = rStyleSettings.GetWindowTextColor();
|
|
|
|
|
2005-09-28 13:39:27 +00:00
|
|
|
ResMgr* pResMgr = ImplGetResMgr();
|
2007-06-06 13:21:07 +00:00
|
|
|
pSVData->maCtrlData.mpRadioImgList = new ImageList();
|
2005-09-28 13:39:27 +00:00
|
|
|
if( pResMgr )
|
2007-06-06 13:21:07 +00:00
|
|
|
LoadThemedImageList( rStyleSettings,
|
|
|
|
pSVData->maCtrlData.mpRadioImgList,
|
|
|
|
ResId( SV_RESID_BITMAP_RADIO+nStyle, *pResMgr ), 6 );
|
|
|
|
pSVData->maCtrlData.mnRadioStyle = nStyle;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
USHORT nId;
|
|
|
|
if ( nFlags & BUTTON_DRAW_DISABLED )
|
|
|
|
{
|
|
|
|
if ( nFlags & BUTTON_DRAW_CHECKED )
|
|
|
|
nId = 6;
|
|
|
|
else
|
|
|
|
nId = 5;
|
|
|
|
}
|
|
|
|
else if ( nFlags & BUTTON_DRAW_PRESSED )
|
|
|
|
{
|
|
|
|
if ( nFlags & BUTTON_DRAW_CHECKED )
|
|
|
|
nId = 4;
|
|
|
|
else
|
|
|
|
nId = 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( nFlags & BUTTON_DRAW_CHECKED )
|
|
|
|
nId = 2;
|
|
|
|
else
|
|
|
|
nId = 1;
|
|
|
|
}
|
|
|
|
return pSVData->maCtrlData.mpRadioImgList->GetImage( nId );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-04-04 10:01:13 +00:00
|
|
|
void RadioButton::ImplSetMinimumNWFSize()
|
|
|
|
{
|
|
|
|
Push( PUSH_MAPMODE );
|
|
|
|
SetMapMode( MAP_PIXEL );
|
|
|
|
|
|
|
|
ImplControlValue aControlValue;
|
|
|
|
Size aCurSize( GetSizePixel() );
|
|
|
|
Region aCtrlRegion = Region( Rectangle( Point( 0, 0 ), aCurSize ) );
|
|
|
|
Region aBoundingRgn, aContentRgn;
|
|
|
|
|
|
|
|
// get native size of a radiobutton
|
|
|
|
if( GetNativeControlRegion( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion,
|
|
|
|
CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED, aControlValue, rtl::OUString(),
|
|
|
|
aBoundingRgn, aContentRgn ) )
|
|
|
|
{
|
|
|
|
Rectangle aCont(aContentRgn.GetBoundRect());
|
|
|
|
Size aSize = aCont.GetSize();
|
|
|
|
|
|
|
|
if( aSize.Height() > aCurSize.Height() )
|
|
|
|
{
|
|
|
|
aCurSize.Height() = aSize.Height();
|
|
|
|
SetSizePixel( aCurSize );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Size RadioButton::CalcMinimumSize( long nMaxWidth ) const
|
|
|
|
{
|
|
|
|
Size aSize;
|
|
|
|
if ( !maImage )
|
2005-03-18 16:51:14 +00:00
|
|
|
aSize = ImplGetRadioImageSize();
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
aSize = maImage.GetSizePixel();
|
|
|
|
|
2001-04-27 13:24:48 +00:00
|
|
|
nMaxWidth -= aSize.Width();
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
XubString aText = GetText();
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-04-27 13:24:48 +00:00
|
|
|
// subtract what will be added later
|
|
|
|
nMaxWidth-=2;
|
|
|
|
nMaxWidth -= IMPL_SEP_BUTTON_IMAGE;
|
|
|
|
|
|
|
|
Size aTextSize = GetTextRect( Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
|
2000-09-18 16:07:07 +00:00
|
|
|
aText, FixedText::ImplGetTextStyle( GetStyle() ) ).GetSize();
|
2001-04-27 13:24:48 +00:00
|
|
|
aSize.Width()+=2; // for focus rect
|
2000-09-18 16:07:07 +00:00
|
|
|
aSize.Width() += IMPL_SEP_BUTTON_IMAGE;
|
|
|
|
aSize.Width() += aTextSize.Width();
|
|
|
|
if ( aSize.Height() < aTextSize.Height() )
|
|
|
|
aSize.Height() = aTextSize.Height();
|
|
|
|
}
|
|
|
|
else if ( !maImage )
|
|
|
|
{
|
|
|
|
/* da ansonsten im Writer die Control zu weit oben haengen
|
|
|
|
aSize.Width() += 2;
|
|
|
|
aSize.Height() += 2;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
return CalcWindowSize( aSize );
|
|
|
|
}
|
|
|
|
|
2008-01-14 12:04:30 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Size RadioButton::GetOptimalSize(WindowSizeType eType) const
|
|
|
|
{
|
|
|
|
switch (eType) {
|
|
|
|
case WINDOWSIZE_MINIMUM:
|
|
|
|
return CalcMinimumSize();
|
|
|
|
default:
|
|
|
|
return Button::GetOptimalSize( eType );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
2006-06-19 18:15:23 +00:00
|
|
|
void CheckBox::ImplInitCheckBoxData()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
meState = STATE_NOCHECK;
|
|
|
|
meSaveValue = STATE_NOCHECK;
|
|
|
|
mbTriState = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::ImplInit( Window* pParent, WinBits nStyle )
|
|
|
|
{
|
|
|
|
nStyle = ImplInitStyle( pParent->GetWindow( WINDOW_LASTCHILD ), nStyle );
|
|
|
|
Button::ImplInit( pParent, nStyle, NULL );
|
|
|
|
|
|
|
|
ImplInitSettings( TRUE, TRUE, TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
WinBits CheckBox::ImplInitStyle( const Window* pPrevWindow, WinBits nStyle )
|
|
|
|
{
|
|
|
|
if ( !(nStyle & WB_NOTABSTOP) )
|
|
|
|
nStyle |= WB_TABSTOP;
|
|
|
|
if ( !(nStyle & WB_NOGROUP) &&
|
|
|
|
(!pPrevWindow || (pPrevWindow->GetType() != WINDOW_CHECKBOX)) )
|
|
|
|
nStyle |= WB_GROUP;
|
|
|
|
return nStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::ImplInitSettings( BOOL bFont,
|
|
|
|
BOOL bForeground, BOOL bBackground )
|
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
|
|
|
|
if ( bFont )
|
|
|
|
{
|
|
|
|
Font aFont = rStyleSettings.GetRadioCheckFont();
|
|
|
|
if ( IsControlFont() )
|
|
|
|
aFont.Merge( GetControlFont() );
|
|
|
|
SetZoomedPointFont( aFont );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bForeground || bFont )
|
|
|
|
{
|
|
|
|
Color aColor;
|
|
|
|
if ( IsControlForeground() )
|
|
|
|
aColor = GetControlForeground();
|
|
|
|
else
|
|
|
|
aColor = rStyleSettings.GetRadioCheckTextColor();
|
|
|
|
SetTextColor( aColor );
|
|
|
|
SetTextFillColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bBackground )
|
|
|
|
{
|
|
|
|
Window* pParent = GetParent();
|
2005-01-31 08:17:00 +00:00
|
|
|
if ( !IsControlBackground() &&
|
|
|
|
(pParent->IsChildTransparentModeEnabled() || IsNativeControlSupported( CTRL_CHECKBOX, PART_ENTIRE_CONTROL ) ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
EnableChildTransparentMode( TRUE );
|
|
|
|
SetParentClipMode( PARENTCLIPMODE_NOCLIP );
|
|
|
|
SetPaintTransparent( TRUE );
|
|
|
|
SetBackground();
|
2007-07-05 07:38:41 +00:00
|
|
|
if( IsNativeControlSupported( CTRL_CHECKBOX, PART_ENTIRE_CONTROL ) )
|
|
|
|
ImplGetWindowImpl()->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableChildTransparentMode( FALSE );
|
|
|
|
SetParentClipMode( 0 );
|
|
|
|
SetPaintTransparent( FALSE );
|
|
|
|
|
|
|
|
if ( IsControlBackground() )
|
|
|
|
SetBackground( GetControlBackground() );
|
|
|
|
else
|
|
|
|
SetBackground( pParent->GetBackground() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::ImplLoadRes( const ResId& rResId )
|
|
|
|
{
|
|
|
|
Button::ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( rResId.GetRT() != RSC_TRISTATEBOX )
|
|
|
|
{
|
|
|
|
USHORT nChecked = ReadShortRes();
|
|
|
|
//anderer Wert als Default ?
|
|
|
|
if( nChecked )
|
|
|
|
Check( TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-03-05 16:07:33 +00:00
|
|
|
void CheckBox::ImplInvalidateOrDrawCheckBoxState()
|
|
|
|
{
|
|
|
|
if( ImplGetSVData()->maNWFData.mbCheckBoxNeedsErase )
|
|
|
|
{
|
|
|
|
if ( IsNativeControlSupported(CTRL_CHECKBOX, PART_ENTIRE_CONTROL) )
|
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
Update();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImplDrawCheckBoxState();
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void CheckBox::ImplDrawCheckBoxState()
|
|
|
|
{
|
2004-05-10 14:45:59 +00:00
|
|
|
bool bNativeOK = TRUE;
|
|
|
|
|
|
|
|
if ( (bNativeOK=IsNativeControlSupported(CTRL_CHECKBOX, PART_ENTIRE_CONTROL)) == TRUE )
|
|
|
|
{
|
|
|
|
ImplControlValue aControlValue( meState == STATE_CHECK ? BUTTONVALUE_ON : BUTTONVALUE_OFF, rtl::OUString(), 0 );
|
|
|
|
Region aCtrlRegion( maStateRect );
|
|
|
|
ControlState nState = 0;
|
|
|
|
|
|
|
|
if ( HasFocus() ) nState |= CTRL_STATE_FOCUSED;
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= CTRL_STATE_DEFAULT;
|
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED ) nState |= CTRL_STATE_PRESSED;
|
2004-05-10 14:45:59 +00:00
|
|
|
if ( IsEnabled() ) nState |= CTRL_STATE_ENABLED;
|
|
|
|
|
|
|
|
if ( meState == STATE_CHECK )
|
|
|
|
aControlValue.setTristateVal( BUTTONVALUE_ON );
|
|
|
|
else if ( meState == STATE_DONTKNOW )
|
|
|
|
aControlValue.setTristateVal( BUTTONVALUE_MIXED );
|
|
|
|
|
|
|
|
if ( IsMouseOver() && maMouseRect.IsInside( GetPointerPosPixel() ) )
|
|
|
|
nState |= CTRL_STATE_ROLLOVER;
|
|
|
|
|
|
|
|
bNativeOK = DrawNativeControl( CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
|
|
|
|
aControlValue, rtl::OUString() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bNativeOK == FALSE )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
USHORT nStyle = ImplGetButtonState();
|
2004-05-10 14:45:59 +00:00
|
|
|
if ( !IsEnabled() )
|
|
|
|
nStyle |= BUTTON_DRAW_DISABLED;
|
|
|
|
if ( meState == STATE_DONTKNOW )
|
|
|
|
nStyle |= BUTTON_DRAW_DONTKNOW;
|
|
|
|
else if ( meState == STATE_CHECK )
|
|
|
|
nStyle |= BUTTON_DRAW_CHECKED;
|
|
|
|
Image aImage = GetCheckImage( GetSettings(), nStyle );
|
|
|
|
if ( IsZoom() )
|
|
|
|
DrawImage( maStateRect.TopLeft(), maStateRect.GetSize(), aImage );
|
|
|
|
else
|
|
|
|
DrawImage( maStateRect.TopLeft(), aImage );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags,
|
|
|
|
const Point& rPos, const Size& rSize,
|
|
|
|
const Size& rImageSize, long nImageSep,
|
2004-07-05 14:41:27 +00:00
|
|
|
Rectangle& rStateRect, Rectangle& rMouseRect,
|
2002-04-29 16:46:18 +00:00
|
|
|
bool bLayout )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
WinBits nWinStyle = GetStyle();
|
|
|
|
XubString aText( GetText() );
|
|
|
|
|
2007-04-26 09:36:08 +00:00
|
|
|
pDev->Push( PUSH_CLIPREGION | PUSH_LINECOLOR );
|
2006-03-29 10:25:02 +00:00
|
|
|
pDev->IntersectClipRegion( Rectangle( rPos, rSize ) );
|
|
|
|
|
2007-04-26 09:36:08 +00:00
|
|
|
long nLineY = rPos.Y() + (rSize.Height()-1)/2;
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) ) ||
|
|
|
|
( HasImage() && ! (ImplGetButtonState() & BUTTON_DRAW_NOIMAGE) ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
USHORT nTextStyle = Button::ImplGetTextStyle( aText, nWinStyle, nDrawFlags );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
Size aSize( rSize );
|
|
|
|
Point aPos( rPos );
|
|
|
|
aPos.X() += rImageSize.Width() + nImageSep;
|
|
|
|
aSize.Width() -= rImageSize.Width() + nImageSep;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2008-03-05 16:07:33 +00:00
|
|
|
// if the text rect height is smaller than the height of the image
|
|
|
|
// then for single lines the default should be centered text
|
|
|
|
if( (nWinStyle & (WB_TOP|WB_CENTER|WB_BOTTOM)) == 0 &&
|
|
|
|
(rImageSize.Height() > rSize.Height() || ! (nWinStyle & WB_WORDBREAK) ) )
|
|
|
|
{
|
|
|
|
nTextStyle &= ~(TEXT_DRAW_TOP|TEXT_DRAW_BOTTOM);
|
|
|
|
nTextStyle |= TEXT_DRAW_VCENTER;
|
|
|
|
aSize.Height() = rImageSize.Height();
|
|
|
|
}
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, 1,
|
|
|
|
nDrawFlags, nTextStyle, NULL );
|
2007-04-26 09:36:08 +00:00
|
|
|
nLineY = aPos.Y() + aSize.Height()/2;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
rMouseRect = Rectangle( aPos, aSize );
|
|
|
|
rMouseRect.Left() = rPos.X();
|
2004-05-10 14:45:59 +00:00
|
|
|
rStateRect.Left() = rPos.X();
|
|
|
|
rStateRect.Top() = rMouseRect.Top();
|
2002-07-08 15:11:07 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( aSize.Height() > rImageSize.Height() )
|
|
|
|
rStateRect.Top() += ( aSize.Height() - rImageSize.Height() ) / 2;
|
2008-03-05 16:07:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
rStateRect.Top() -= ( rImageSize.Height() - aSize.Height() ) / 2;
|
|
|
|
if( rStateRect.Top() < 0 )
|
|
|
|
rStateRect.Top() = 0;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
rStateRect.Right() = rStateRect.Left()+rImageSize.Width()-1;
|
|
|
|
rStateRect.Bottom() = rStateRect.Top()+rImageSize.Height()-1;
|
|
|
|
if ( rStateRect.Bottom() > rMouseRect.Bottom() )
|
|
|
|
rMouseRect.Bottom() = rStateRect.Bottom();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( nWinStyle & WB_CENTER )
|
|
|
|
rStateRect.Left() = rPos.X()+((rSize.Width()-rImageSize.Width())/2);
|
|
|
|
else if ( nWinStyle & WB_RIGHT )
|
2004-05-10 14:45:59 +00:00
|
|
|
rStateRect.Left() = rPos.X()+rSize.Width()-rImageSize.Width();
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2004-05-10 14:45:59 +00:00
|
|
|
rStateRect.Left() = rPos.X();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nWinStyle & WB_VCENTER )
|
|
|
|
rStateRect.Top() = rPos.Y()+((rSize.Height()-rImageSize.Height())/2);
|
|
|
|
else if ( nWinStyle & WB_BOTTOM )
|
2004-05-10 14:45:59 +00:00
|
|
|
rStateRect.Top() = rPos.Y()+rSize.Height()-rImageSize.Height();
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2004-05-10 14:45:59 +00:00
|
|
|
rStateRect.Top() = rPos.Y();
|
2000-09-18 16:07:07 +00:00
|
|
|
rStateRect.Right() = rStateRect.Left()+rImageSize.Width()-1;
|
|
|
|
rStateRect.Bottom() = rStateRect.Top()+rImageSize.Height()-1;
|
2004-05-10 14:45:59 +00:00
|
|
|
// provide space for focusrect
|
|
|
|
// note: this assumes that the control's size was adjusted
|
|
|
|
// accordingly in Get/LoseFocus, so the onscreen position won't change
|
|
|
|
if( HasFocus() )
|
|
|
|
rStateRect.Move( 1, 1 );
|
2000-09-18 16:07:07 +00:00
|
|
|
rMouseRect = rStateRect;
|
2002-07-08 15:11:07 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplSetFocusRect( rStateRect );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2006-03-29 10:25:02 +00:00
|
|
|
|
2007-04-26 09:36:08 +00:00
|
|
|
const int nLineSpace = 4;
|
|
|
|
if( (GetStyle() & WB_CBLINESTYLE) != 0 &&
|
|
|
|
rMouseRect.Right()-1-nLineSpace < rPos.X()+rSize.Width() )
|
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
|
|
|
|
SetLineColor( Color( COL_BLACK ) );
|
|
|
|
else
|
|
|
|
SetLineColor( rStyleSettings.GetShadowColor() );
|
|
|
|
long nLineX = rMouseRect.Right()+nLineSpace;
|
|
|
|
DrawLine( Point( nLineX, nLineY ), Point( rPos.X() + rSize.Width()-1, nLineY ) );
|
|
|
|
if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
|
|
|
|
{
|
|
|
|
SetLineColor( rStyleSettings.GetLightColor() );
|
|
|
|
DrawLine( Point( nLineX, nLineY+1 ), Point( rPos.X() + rSize.Width()-1, nLineY+1 ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-29 10:25:02 +00:00
|
|
|
pDev->Pop();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
void CheckBox::ImplDrawCheckBox( bool bLayout )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-03-18 16:51:14 +00:00
|
|
|
Size aImageSize = ImplGetCheckImageSize();
|
2000-09-18 16:07:07 +00:00
|
|
|
aImageSize.Width() = CalcZoom( aImageSize.Width() );
|
|
|
|
aImageSize.Height() = CalcZoom( aImageSize.Height() );
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
if( !bLayout )
|
|
|
|
HideFocus();
|
2004-07-05 14:41:27 +00:00
|
|
|
|
|
|
|
ImplDraw( this, 0, Point(), GetOutputSizePixel(), aImageSize,
|
|
|
|
IMPL_SEP_BUTTON_IMAGE, maStateRect, maMouseRect, bLayout );
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
if( !bLayout )
|
|
|
|
{
|
2002-07-08 15:11:07 +00:00
|
|
|
ImplDrawCheckBoxState();
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( HasFocus() )
|
|
|
|
ShowFocus( ImplGetFocusRect() );
|
2002-04-29 16:46:18 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::ImplCheck()
|
|
|
|
{
|
|
|
|
TriState eNewState;
|
|
|
|
if ( meState == STATE_NOCHECK )
|
|
|
|
eNewState = STATE_CHECK;
|
|
|
|
else if ( !mbTriState )
|
|
|
|
eNewState = STATE_NOCHECK;
|
|
|
|
else if ( meState == STATE_CHECK )
|
|
|
|
eNewState = STATE_DONTKNOW;
|
|
|
|
else
|
|
|
|
eNewState = STATE_NOCHECK;
|
|
|
|
meState = eNewState;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawCheckBoxState();
|
2003-12-01 08:53:28 +00:00
|
|
|
|
|
|
|
ImplDelData aDelData;
|
|
|
|
ImplAddDel( &aDelData );
|
2000-09-18 16:07:07 +00:00
|
|
|
Toggle();
|
2003-12-01 08:53:28 +00:00
|
|
|
if ( aDelData.IsDelete() )
|
|
|
|
return;
|
|
|
|
ImplRemoveDel( &aDelData );
|
2000-09-18 16:07:07 +00:00
|
|
|
Click();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
CheckBox::CheckBox( Window* pParent, WinBits nStyle ) :
|
|
|
|
Button( WINDOW_CHECKBOX )
|
|
|
|
{
|
2006-06-19 18:15:23 +00:00
|
|
|
ImplInitCheckBoxData();
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
CheckBox::CheckBox( Window* pParent, const ResId& rResId ) :
|
|
|
|
Button( WINDOW_CHECKBOX )
|
|
|
|
{
|
2006-06-19 18:15:23 +00:00
|
|
|
ImplInitCheckBoxData();
|
2000-09-18 16:07:07 +00:00
|
|
|
rResId.SetRT( RSC_CHECKBOX );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::MouseButtonDown( const MouseEvent& rMEvt )
|
|
|
|
{
|
|
|
|
if ( rMEvt.IsLeft() && maMouseRect.IsInside( rMEvt.GetPosPixel() ) )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawCheckBoxState();
|
2000-09-18 16:07:07 +00:00
|
|
|
StartTracking();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Button::MouseButtonDown( rMEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::Tracking( const TrackingEvent& rTEvt )
|
|
|
|
{
|
|
|
|
if ( rTEvt.IsTrackingEnded() )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
|
|
|
|
GrabFocus();
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Bei Abbruch kein Click-Handler rufen
|
|
|
|
if ( !rTEvt.IsTrackingCanceled() )
|
|
|
|
ImplCheck();
|
|
|
|
else
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawCheckBoxState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( maMouseRect.IsInside( rTEvt.GetMouseEvent().GetPosPixel() ) )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawCheckBoxState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawCheckBoxState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::KeyInput( const KeyEvent& rKEvt )
|
|
|
|
{
|
|
|
|
KeyCode aKeyCode = rKEvt.GetKeyCode();
|
|
|
|
|
|
|
|
if ( !aKeyCode.GetModifier() && (aKeyCode.GetCode() == KEY_SPACE) )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawCheckBoxState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2004-07-05 14:41:27 +00:00
|
|
|
else if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_ESCAPE) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawCheckBoxState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Button::KeyInput( rKEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::KeyUp( const KeyEvent& rKEvt )
|
|
|
|
{
|
|
|
|
KeyCode aKeyCode = rKEvt.GetKeyCode();
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_SPACE) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplCheck();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Button::KeyUp( rKEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-04-29 16:46:18 +00:00
|
|
|
void CheckBox::FillLayoutData() const
|
|
|
|
{
|
|
|
|
mpLayoutData = new vcl::ControlLayoutData();
|
|
|
|
const_cast<CheckBox*>(this)->ImplDrawCheckBox( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2006-06-19 18:15:23 +00:00
|
|
|
void CheckBox::Paint( const Rectangle& )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplDrawCheckBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
|
|
|
|
ULONG nFlags )
|
|
|
|
{
|
|
|
|
MapMode aResMapMode( MAP_100TH_MM );
|
|
|
|
Point aPos = pDev->LogicToPixel( rPos );
|
|
|
|
Size aSize = pDev->LogicToPixel( rSize );
|
|
|
|
Size aImageSize = pDev->LogicToPixel( Size( 300, 300 ), aResMapMode );
|
|
|
|
Size aBrd1Size = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
|
|
|
|
Size aBrd2Size = pDev->LogicToPixel( Size( 30, 30 ), aResMapMode );
|
|
|
|
long nCheckWidth = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode ).Width();
|
|
|
|
Font aFont = GetDrawPixelFont( pDev );
|
|
|
|
Rectangle aStateRect;
|
|
|
|
Rectangle aMouseRect;
|
|
|
|
|
|
|
|
aImageSize.Width() = CalcZoom( aImageSize.Width() );
|
|
|
|
aImageSize.Height() = CalcZoom( aImageSize.Height() );
|
|
|
|
aBrd1Size.Width() = CalcZoom( aBrd1Size.Width() );
|
|
|
|
aBrd1Size.Height() = CalcZoom( aBrd1Size.Height() );
|
|
|
|
aBrd2Size.Width() = CalcZoom( aBrd2Size.Width() );
|
|
|
|
aBrd2Size.Height() = CalcZoom( aBrd2Size.Height() );
|
|
|
|
|
|
|
|
if ( !aBrd1Size.Width() )
|
|
|
|
aBrd1Size.Width() = 1;
|
|
|
|
if ( !aBrd1Size.Height() )
|
|
|
|
aBrd1Size.Height() = 1;
|
|
|
|
if ( !aBrd2Size.Width() )
|
|
|
|
aBrd2Size.Width() = 1;
|
|
|
|
if ( !aBrd2Size.Height() )
|
|
|
|
aBrd2Size.Height() = 1;
|
|
|
|
if ( !nCheckWidth )
|
|
|
|
nCheckWidth = 1;
|
|
|
|
|
|
|
|
pDev->Push();
|
|
|
|
pDev->SetMapMode();
|
|
|
|
pDev->SetFont( aFont );
|
|
|
|
if ( nFlags & WINDOW_DRAW_MONO )
|
|
|
|
pDev->SetTextColor( Color( COL_BLACK ) );
|
|
|
|
else
|
|
|
|
pDev->SetTextColor( GetTextColor() );
|
|
|
|
pDev->SetTextFillColor();
|
|
|
|
|
|
|
|
ImplDraw( pDev, nFlags, aPos, aSize,
|
|
|
|
aImageSize, GetDrawPixel( pDev, IMPL_SEP_BUTTON_IMAGE ),
|
2004-07-05 14:41:27 +00:00
|
|
|
aStateRect, aMouseRect, false );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
pDev->SetLineColor();
|
|
|
|
pDev->SetFillColor( Color( COL_BLACK ) );
|
|
|
|
pDev->DrawRect( aStateRect );
|
|
|
|
aStateRect.Left() += aBrd1Size.Width();
|
|
|
|
aStateRect.Top() += aBrd1Size.Height();
|
|
|
|
aStateRect.Right() -= aBrd1Size.Width();
|
|
|
|
aStateRect.Bottom() -= aBrd1Size.Height();
|
|
|
|
if ( meState == STATE_DONTKNOW )
|
|
|
|
pDev->SetFillColor( Color( COL_LIGHTGRAY ) );
|
|
|
|
else
|
|
|
|
pDev->SetFillColor( Color( COL_WHITE ) );
|
|
|
|
pDev->DrawRect( aStateRect );
|
|
|
|
|
|
|
|
if ( meState == STATE_CHECK )
|
|
|
|
{
|
|
|
|
aStateRect.Left() += aBrd2Size.Width();
|
|
|
|
aStateRect.Top() += aBrd2Size.Height();
|
|
|
|
aStateRect.Right() -= aBrd2Size.Width();
|
|
|
|
aStateRect.Bottom() -= aBrd2Size.Height();
|
|
|
|
Point aPos11( aStateRect.TopLeft() );
|
|
|
|
Point aPos12( aStateRect.BottomRight() );
|
|
|
|
Point aPos21( aStateRect.TopRight() );
|
|
|
|
Point aPos22( aStateRect.BottomLeft() );
|
|
|
|
Point aTempPos11( aPos11 );
|
|
|
|
Point aTempPos12( aPos12 );
|
|
|
|
Point aTempPos21( aPos21 );
|
|
|
|
Point aTempPos22( aPos22 );
|
|
|
|
pDev->SetLineColor( Color( COL_BLACK ) );
|
|
|
|
long nDX = 0;
|
|
|
|
for ( long i = 0; i < nCheckWidth; i++ )
|
|
|
|
{
|
|
|
|
if ( !(i % 2) )
|
|
|
|
{
|
|
|
|
aTempPos11.X() = aPos11.X()+nDX;
|
|
|
|
aTempPos12.X() = aPos12.X()+nDX;
|
|
|
|
aTempPos21.X() = aPos21.X()+nDX;
|
|
|
|
aTempPos22.X() = aPos22.X()+nDX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nDX++;
|
|
|
|
aTempPos11.X() = aPos11.X()-nDX;
|
|
|
|
aTempPos12.X() = aPos12.X()-nDX;
|
|
|
|
aTempPos21.X() = aPos21.X()-nDX;
|
|
|
|
aTempPos22.X() = aPos22.X()-nDX;
|
|
|
|
}
|
|
|
|
pDev->DrawLine( aTempPos11, aTempPos12 );
|
|
|
|
pDev->DrawLine( aTempPos21, aTempPos22 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pDev->Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::Resize()
|
|
|
|
{
|
2002-05-08 15:05:42 +00:00
|
|
|
Control::Resize();
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::GetFocus()
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( !GetText().Len() || (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
|
|
|
// increase button size to have space for focus rect
|
|
|
|
// checkboxes without text will draw focusrect around the check
|
|
|
|
// See CheckBox::ImplDraw()
|
|
|
|
Point aPos( GetPosPixel() );
|
|
|
|
Size aSize( GetSizePixel() );
|
|
|
|
aPos.Move(-1,-1);
|
|
|
|
aSize.Height() += 2;
|
|
|
|
aSize.Width() += 2;
|
|
|
|
SetPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height(), WINDOW_POSSIZE_ALL );
|
|
|
|
ImplDrawCheckBox();
|
|
|
|
}
|
|
|
|
else
|
2004-07-05 14:41:27 +00:00
|
|
|
ShowFocus( ImplGetFocusRect() );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SetInputContext( InputContext( GetFont() ) );
|
|
|
|
Button::GetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::LoseFocus()
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
|
2008-03-05 16:07:33 +00:00
|
|
|
ImplInvalidateOrDrawCheckBoxState();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HideFocus();
|
|
|
|
Button::LoseFocus();
|
2004-05-10 14:45:59 +00:00
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( !GetText().Len() || (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
|
|
|
// decrease button size again (see GetFocus())
|
|
|
|
// checkboxes without text will draw focusrect around the check
|
|
|
|
Point aPos( GetPosPixel() );
|
|
|
|
Size aSize( GetSizePixel() );
|
|
|
|
aPos.Move(1,1);
|
|
|
|
aSize.Height() -= 2;
|
|
|
|
aSize.Width() -= 2;
|
|
|
|
SetPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height(), WINDOW_POSSIZE_ALL );
|
|
|
|
ImplDrawCheckBox();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
Button::StateChanged( nType );
|
|
|
|
|
|
|
|
if ( nType == STATE_CHANGE_STATE )
|
|
|
|
{
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
2005-04-12 11:18:06 +00:00
|
|
|
Invalidate( maStateRect );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if ( (nType == STATE_CHANGE_ENABLE) ||
|
|
|
|
(nType == STATE_CHANGE_TEXT) ||
|
|
|
|
(nType == STATE_CHANGE_IMAGE) ||
|
|
|
|
(nType == STATE_CHANGE_DATA) ||
|
|
|
|
(nType == STATE_CHANGE_UPDATEMODE) )
|
|
|
|
{
|
|
|
|
if ( IsUpdateMode() )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else if ( nType == STATE_CHANGE_STYLE )
|
|
|
|
{
|
|
|
|
SetStyle( ImplInitStyle( GetWindow( WINDOW_PREV ), GetStyle() ) );
|
|
|
|
|
|
|
|
if ( (GetPrevStyle() & CHECKBOX_VIEW_STYLE) !=
|
|
|
|
(GetStyle() & CHECKBOX_VIEW_STYLE) )
|
|
|
|
{
|
|
|
|
if ( IsUpdateMode() )
|
|
|
|
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 CheckBox::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
Button::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
|
|
|
|
(rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
|
|
|
|
((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE)) )
|
|
|
|
{
|
|
|
|
ImplInitSettings( TRUE, TRUE, TRUE );
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2004-02-20 07:50:15 +00:00
|
|
|
long CheckBox::PreNotify( NotifyEvent& rNEvt )
|
|
|
|
{
|
2004-05-10 14:45:59 +00:00
|
|
|
long nDone = 0;
|
|
|
|
const MouseEvent* pMouseEvt = NULL;
|
|
|
|
|
2006-06-19 18:15:23 +00:00
|
|
|
if( (rNEvt.GetType() == EVENT_MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != NULL )
|
2004-05-10 14:45:59 +00:00
|
|
|
{
|
|
|
|
if( !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
|
|
|
|
{
|
|
|
|
// trigger redraw if mouse over state has changed
|
|
|
|
if( IsNativeControlSupported(CTRL_CHECKBOX, PART_ENTIRE_CONTROL) )
|
|
|
|
{
|
|
|
|
if( ( maMouseRect.IsInside( GetPointerPosPixel()) &&
|
|
|
|
!maMouseRect.IsInside( GetLastPointerPosPixel()) ) ||
|
|
|
|
( maMouseRect.IsInside( GetLastPointerPosPixel()) &&
|
|
|
|
!maMouseRect.IsInside( GetPointerPosPixel()) ) ||
|
|
|
|
pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow() )
|
|
|
|
{
|
|
|
|
Invalidate( maStateRect );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nDone ? nDone : Button::PreNotify(rNEvt);
|
2004-02-20 07:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void CheckBox::Toggle()
|
|
|
|
{
|
2004-10-22 11:12:18 +00:00
|
|
|
ImplCallEventListenersAndHandler( VCLEVENT_CHECKBOX_TOGGLE, maToggleHdl, this );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::SetState( TriState eState )
|
|
|
|
{
|
|
|
|
if ( !mbTriState && (eState == STATE_DONTKNOW) )
|
|
|
|
eState = STATE_NOCHECK;
|
|
|
|
|
|
|
|
if ( meState != eState )
|
|
|
|
{
|
|
|
|
meState = eState;
|
|
|
|
StateChanged( STATE_CHANGE_STATE );
|
2001-06-15 11:56:11 +00:00
|
|
|
Toggle();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CheckBox::EnableTriState( BOOL bTriState )
|
|
|
|
{
|
|
|
|
if ( mbTriState != bTriState )
|
|
|
|
{
|
|
|
|
mbTriState = bTriState;
|
|
|
|
|
|
|
|
if ( !bTriState && (meState == STATE_DONTKNOW) )
|
|
|
|
SetState( STATE_NOCHECK );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2005-03-18 16:51:14 +00:00
|
|
|
Size CheckBox::ImplGetCheckImageSize() const
|
|
|
|
{
|
|
|
|
Size aSize;
|
|
|
|
// why are IsNativeControlSupported and GetNativeControlRegion not const ?
|
|
|
|
CheckBox* pThis = const_cast<CheckBox*>(this);
|
|
|
|
bool bDefaultSize = true;
|
|
|
|
if( pThis->IsNativeControlSupported( CTRL_CHECKBOX, PART_ENTIRE_CONTROL ) )
|
|
|
|
{
|
|
|
|
ImplControlValue aControlValue;
|
2005-04-12 11:18:06 +00:00
|
|
|
// #i45896# workaround gcc3.3 temporary problem
|
|
|
|
Region aCtrlRegion = Region( Rectangle( Point( 0, 0 ), GetSizePixel() ) );
|
2005-03-18 16:51:14 +00:00
|
|
|
ControlState nState = CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED;
|
|
|
|
Region aBoundingRgn, aContentRgn;
|
|
|
|
|
|
|
|
// get native size of a check box
|
|
|
|
if( pThis->GetNativeControlRegion( CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
|
|
|
|
nState, aControlValue, rtl::OUString(),
|
|
|
|
aBoundingRgn, aContentRgn ) )
|
|
|
|
{
|
|
|
|
Rectangle aCont(aContentRgn.GetBoundRect());
|
|
|
|
aSize = aCont.GetSize();
|
|
|
|
bDefaultSize = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( bDefaultSize )
|
|
|
|
aSize = GetCheckImage( GetSettings(), 0 ).GetSizePixel();
|
|
|
|
return aSize;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Image CheckBox::GetCheckImage( const AllSettings& rSettings, USHORT nFlags )
|
|
|
|
{
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
|
|
const StyleSettings& rStyleSettings = rSettings.GetStyleSettings();
|
|
|
|
USHORT nStyle = rStyleSettings.GetCheckBoxStyle() & STYLE_CHECKBOX_STYLE;
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
|
|
|
|
nStyle = STYLE_CHECKBOX_MONO;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !pSVData->maCtrlData.mpCheckImgList ||
|
|
|
|
(pSVData->maCtrlData.mnCheckStyle != nStyle) ||
|
|
|
|
(pSVData->maCtrlData.mnLastCheckFColor != rStyleSettings.GetFaceColor().GetColor()) ||
|
|
|
|
(pSVData->maCtrlData.mnLastCheckWColor != rStyleSettings.GetWindowColor().GetColor()) ||
|
|
|
|
(pSVData->maCtrlData.mnLastCheckLColor != rStyleSettings.GetLightColor().GetColor()) )
|
|
|
|
{
|
|
|
|
if ( pSVData->maCtrlData.mpCheckImgList )
|
|
|
|
delete pSVData->maCtrlData.mpCheckImgList;
|
|
|
|
|
|
|
|
pSVData->maCtrlData.mnLastCheckFColor = rStyleSettings.GetFaceColor().GetColor();
|
|
|
|
pSVData->maCtrlData.mnLastCheckWColor = rStyleSettings.GetWindowColor().GetColor();
|
|
|
|
pSVData->maCtrlData.mnLastCheckLColor = rStyleSettings.GetLightColor().GetColor();
|
|
|
|
|
2005-09-28 13:39:27 +00:00
|
|
|
ResMgr* pResMgr = ImplGetResMgr();
|
2007-06-06 13:21:07 +00:00
|
|
|
pSVData->maCtrlData.mpCheckImgList = new ImageList();
|
2005-09-28 13:39:27 +00:00
|
|
|
if( pResMgr )
|
2007-06-06 13:21:07 +00:00
|
|
|
LoadThemedImageList( rStyleSettings,
|
|
|
|
pSVData->maCtrlData.mpCheckImgList,
|
|
|
|
ResId( SV_RESID_BITMAP_CHECK+nStyle, *pResMgr ), 9 );
|
2000-09-18 16:07:07 +00:00
|
|
|
pSVData->maCtrlData.mnCheckStyle = nStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
USHORT nId;
|
|
|
|
if ( nFlags & BUTTON_DRAW_DISABLED )
|
|
|
|
{
|
|
|
|
if ( nFlags & BUTTON_DRAW_DONTKNOW )
|
|
|
|
nId = 9;
|
|
|
|
else if ( nFlags & BUTTON_DRAW_CHECKED )
|
|
|
|
nId = 6;
|
|
|
|
else
|
|
|
|
nId = 5;
|
|
|
|
}
|
|
|
|
else if ( nFlags & BUTTON_DRAW_PRESSED )
|
|
|
|
{
|
|
|
|
if ( nFlags & BUTTON_DRAW_DONTKNOW )
|
|
|
|
nId = 8;
|
|
|
|
else if ( nFlags & BUTTON_DRAW_CHECKED )
|
|
|
|
nId = 4;
|
|
|
|
else
|
|
|
|
nId = 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( nFlags & BUTTON_DRAW_DONTKNOW )
|
|
|
|
nId = 7;
|
|
|
|
else if ( nFlags & BUTTON_DRAW_CHECKED )
|
|
|
|
nId = 2;
|
|
|
|
else
|
|
|
|
nId = 1;
|
|
|
|
}
|
|
|
|
return pSVData->maCtrlData.mpCheckImgList->GetImage( nId );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-04-04 10:01:13 +00:00
|
|
|
void CheckBox::ImplSetMinimumNWFSize()
|
|
|
|
{
|
|
|
|
Push( PUSH_MAPMODE );
|
|
|
|
SetMapMode( MAP_PIXEL );
|
|
|
|
|
|
|
|
ImplControlValue aControlValue;
|
|
|
|
Size aCurSize( GetSizePixel() );
|
|
|
|
Region aCtrlRegion = Region( Rectangle( Point( 0, 0 ), aCurSize ) );
|
|
|
|
Region aBoundingRgn, aContentRgn;
|
|
|
|
|
|
|
|
// get native size of a radiobutton
|
|
|
|
if( GetNativeControlRegion( CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
|
|
|
|
CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED, aControlValue, rtl::OUString(),
|
|
|
|
aBoundingRgn, aContentRgn ) )
|
|
|
|
{
|
|
|
|
Rectangle aCont(aContentRgn.GetBoundRect());
|
|
|
|
Size aSize = aCont.GetSize();
|
|
|
|
|
|
|
|
if( aSize.Height() > aCurSize.Height() )
|
|
|
|
{
|
|
|
|
aCurSize.Height() = aSize.Height();
|
|
|
|
SetSizePixel( aCurSize );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Size CheckBox::CalcMinimumSize( long nMaxWidth ) const
|
|
|
|
{
|
2005-03-18 16:51:14 +00:00
|
|
|
Size aSize = ImplGetCheckImageSize();
|
2001-04-27 13:24:48 +00:00
|
|
|
nMaxWidth -= aSize.Width();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
XubString aText = GetText();
|
2004-07-05 14:41:27 +00:00
|
|
|
if ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-04-27 13:24:48 +00:00
|
|
|
// subtract what will be added later
|
|
|
|
nMaxWidth-=2;
|
|
|
|
nMaxWidth -= IMPL_SEP_BUTTON_IMAGE;
|
|
|
|
|
|
|
|
Size aTextSize = GetTextRect( Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
|
2000-09-18 16:07:07 +00:00
|
|
|
aText, FixedText::ImplGetTextStyle( GetStyle() ) ).GetSize();
|
2001-04-27 13:24:48 +00:00
|
|
|
aSize.Width()+=2; // for focus rect
|
2000-09-18 16:07:07 +00:00
|
|
|
aSize.Width() += IMPL_SEP_BUTTON_IMAGE;
|
|
|
|
aSize.Width() += aTextSize.Width();
|
|
|
|
if ( aSize.Height() < aTextSize.Height() )
|
|
|
|
aSize.Height() = aTextSize.Height();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-07-08 15:11:07 +00:00
|
|
|
// is this still correct ? since the checkbox now
|
|
|
|
// shows a focus rect it should be 2 pixels wider and longer
|
2000-09-18 16:07:07 +00:00
|
|
|
/* da ansonsten im Writer die Control zu weit oben haengen
|
|
|
|
aSize.Width() += 2;
|
|
|
|
aSize.Height() += 2;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
return CalcWindowSize( aSize );
|
|
|
|
}
|
|
|
|
|
2008-01-14 12:04:30 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Size CheckBox::GetOptimalSize(WindowSizeType eType) const
|
|
|
|
{
|
|
|
|
switch (eType) {
|
|
|
|
case WINDOWSIZE_MINIMUM:
|
|
|
|
return CalcMinimumSize();
|
|
|
|
default:
|
|
|
|
return Button::GetOptimalSize( eType );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
ImageButton::ImageButton( WindowType nType ) :
|
|
|
|
PushButton( nType )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplInitStyle();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ImageButton::ImageButton( Window* pParent, WinBits nStyle ) :
|
|
|
|
PushButton( pParent, nStyle )
|
|
|
|
{
|
2004-07-05 14:41:27 +00:00
|
|
|
ImplInitStyle();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ImageButton::ImageButton( Window* pParent, const ResId& rResId ) :
|
|
|
|
PushButton( pParent, rResId.SetRT( RSC_IMAGEBUTTON ) )
|
|
|
|
{
|
2005-01-03 16:38:30 +00:00
|
|
|
ULONG nObjMask = ReadLongRes();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( RSC_IMAGEBUTTON_IMAGE & nObjMask )
|
|
|
|
{
|
2007-04-26 08:27:13 +00:00
|
|
|
SetModeImage( Image( ResId( (RSHEADER_TYPE*)GetClassRes(), *rResId.GetResMgr() ) ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( RSC_IMAGEBUTTON_SYMBOL & nObjMask )
|
2005-01-03 16:38:30 +00:00
|
|
|
SetSymbol( (SymbolType)ReadLongRes() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( RSC_IMAGEBUTTON_STATE & nObjMask )
|
2005-01-03 16:38:30 +00:00
|
|
|
SetState( (TriState)ReadLongRes() );
|
2004-07-05 14:41:27 +00:00
|
|
|
|
|
|
|
ImplInitStyle();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ImageButton::~ImageButton()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-07-05 14:41:27 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void ImageButton::ImplInitStyle()
|
|
|
|
{
|
|
|
|
WinBits nStyle = GetStyle();
|
|
|
|
|
|
|
|
if ( ! ( nStyle & ( WB_RIGHT | WB_LEFT ) ) )
|
|
|
|
nStyle |= WB_CENTER;
|
|
|
|
|
|
|
|
if ( ! ( nStyle & ( WB_TOP | WB_BOTTOM ) ) )
|
|
|
|
nStyle |= WB_VCENTER;
|
|
|
|
|
|
|
|
SetStyle( nStyle );
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
ImageRadioButton::ImageRadioButton( Window* pParent, WinBits nStyle ) :
|
|
|
|
RadioButton( pParent, nStyle )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ImageRadioButton::ImageRadioButton( Window* pParent, const ResId& rResId ) :
|
|
|
|
RadioButton( pParent, rResId.SetRT( RSC_IMAGERADIOBUTTON ) )
|
|
|
|
{
|
2005-01-03 16:38:30 +00:00
|
|
|
ULONG nObjMask = ReadLongRes();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( RSC_IMAGERADIOBUTTON_IMAGE & nObjMask )
|
|
|
|
{
|
2007-04-26 08:27:13 +00:00
|
|
|
SetModeRadioImage( Image( ResId( (RSHEADER_TYPE*)GetClassRes(), *rResId.GetResMgr() ) ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ImageRadioButton::~ImageRadioButton()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
TriStateBox::TriStateBox( Window* pParent, WinBits nStyle ) :
|
|
|
|
CheckBox( pParent, nStyle )
|
|
|
|
{
|
|
|
|
EnableTriState( TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
TriStateBox::TriStateBox( Window* pParent, const ResId& rResId ) :
|
|
|
|
CheckBox( pParent, rResId.SetRT( RSC_TRISTATEBOX ) )
|
|
|
|
{
|
|
|
|
EnableTriState( TRUE );
|
|
|
|
|
2005-01-03 16:38:30 +00:00
|
|
|
ULONG nTriState = ReadLongRes();
|
2000-09-18 16:07:07 +00:00
|
|
|
USHORT bDisableTriState = ReadShortRes();
|
|
|
|
//anderer Wert als Default ?
|
|
|
|
if ( (TriState)nTriState != STATE_NOCHECK )
|
|
|
|
SetState( (TriState)nTriState );
|
|
|
|
if ( bDisableTriState )
|
|
|
|
EnableTriState( FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
TriStateBox::~TriStateBox()
|
|
|
|
{
|
2001-06-15 11:56:11 +00:00
|
|
|
}
|