Files
libreoffice/svx/source/dialog/fontlb.cxx

177 lines
5.4 KiB
C++
Raw Normal View History

2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:07:07 +00:00
*
* $RCSfile: fontlb.cxx,v $
2000-09-18 16:07:07 +00:00
*
* $Revision: 1.6 $
2000-09-18 16:07:07 +00:00
*
* last change: $Author: ihi $ $Date: 2006-12-20 14:11:23 $
2000-09-18 16:07:07 +00:00
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
2000-09-18 16:07:07 +00:00
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
2000-09-18 16:07:07 +00:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
2000-09-18 16:07:07 +00:00
*
* This library 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 for more details.
2000-09-18 16:07:07 +00:00
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
2000-09-18 16:07:07 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
2002-07-23 09:52:55 +00:00
#ifndef SVX_FONTLB_HXX
2000-09-18 16:07:07 +00:00
#include "fontlb.hxx"
2002-07-23 09:52:55 +00:00
#endif
2000-09-18 16:07:07 +00:00
2002-07-23 09:52:55 +00:00
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
2000-09-18 16:07:07 +00:00
2002-07-23 09:52:55 +00:00
// ============================================================================
2000-09-18 16:07:07 +00:00
2002-07-23 09:52:55 +00:00
DBG_NAME( SvLBoxFontString );
2000-09-18 16:07:07 +00:00
2002-07-23 09:52:55 +00:00
SvLBoxFontString::SvLBoxFontString() :
SvLBoxString()
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
DBG_CTOR( SvLBoxFontString, 0 );
2000-09-18 16:07:07 +00:00
}
2002-07-23 09:52:55 +00:00
SvLBoxFontString::SvLBoxFontString(
SvLBoxEntry* pEntry, sal_uInt16 nFlags, const XubString& rString,
const Font& rFont, const Color* pColor ) :
SvLBoxString( pEntry, nFlags, rString ),
maFont( rFont ),
mbUseColor( pColor != NULL )
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
DBG_CTOR( SvLBoxFontString, 0 );
SetText( pEntry, rString );
if( pColor )
maFont.SetColor( *pColor );
2000-09-18 16:07:07 +00:00
}
SvLBoxFontString::~SvLBoxFontString()
{
2002-07-23 09:52:55 +00:00
DBG_DTOR( SvLBoxFontString, 0 );
2000-09-18 16:07:07 +00:00
}
SvLBoxItem* SvLBoxFontString::Create() const
{
2002-07-23 09:52:55 +00:00
DBG_CHKTHIS( SvLBoxFontString, 0 );
2000-09-18 16:07:07 +00:00
return new SvLBoxFontString;
}
2002-07-23 09:52:55 +00:00
void SvLBoxFontString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry )
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
DBG_CHKTHIS( SvLBoxFontString, 0 );
Font aOldFont( rDev.GetFont() );
Font aNewFont( maFont );
bool bSel = (nFlags & SVLISTENTRYFLAG_SELECTED) != 0;
// if( !mbUseColor ) // selection gets font color, if available
if( !mbUseColor || bSel ) // selection always gets highlight color
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
aNewFont.SetColor( bSel ? rSett.GetHighlightTextColor() : rSett.GetFieldTextColor() );
2000-09-18 16:07:07 +00:00
}
2002-07-23 09:52:55 +00:00
rDev.SetFont( aNewFont );
SvLBoxString::Paint( rPos, rDev, nFlags, pEntry );
rDev.SetFont( aOldFont );
2000-09-18 16:07:07 +00:00
}
2002-07-23 09:52:55 +00:00
void SvLBoxFontString::InitViewData( SvLBox* pView, SvLBoxEntry* pEntry, SvViewDataItem* pViewData )
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
DBG_CHKTHIS( SvLBoxFontString, 0 );
Font aOldFont( pView->GetFont() );
pView->SetFont( maFont );
SvLBoxString::InitViewData( pView, pEntry, pViewData);
pView->SetFont( aOldFont );
2000-09-18 16:07:07 +00:00
}
2002-07-23 09:52:55 +00:00
// ============================================================================
SvxFontListBox::SvxFontListBox( Window* pParent, const ResId& rResId ) :
SvTabListBox( pParent, rResId ),
maStdFont( GetFont() ),
mbUseFont( false )
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
maStdFont.SetTransparent( TRUE );
maEntryFont = maStdFont;
2000-09-18 16:07:07 +00:00
}
2002-07-23 09:52:55 +00:00
void SvxFontListBox::InsertFontEntry( const String& rString, const Font& rFont, const Color* pColor )
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
mbUseFont = true; // InitEntry() will use maEntryFont
maEntryFont = rFont; // font to use in InitEntry() over InsertEntry()
mpEntryColor = pColor; // color to use in InitEntry() over InsertEntry()
InsertEntry( rString );
mbUseFont = false;
2000-09-18 16:07:07 +00:00
}
2002-07-23 09:52:55 +00:00
void SvxFontListBox::SelectEntryPos( sal_uInt16 nPos, bool bSelect )
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
SvLBoxEntry* pEntry = GetEntry( nPos );
if( pEntry )
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
Select( pEntry, bSelect );
ShowEntry( pEntry );
2000-09-18 16:07:07 +00:00
}
}
2002-07-23 09:52:55 +00:00
void SvxFontListBox::SetNoSelection()
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
SelectAll( FALSE, TRUE );
2000-09-18 16:07:07 +00:00
}
2002-07-23 09:52:55 +00:00
sal_uInt32 SvxFontListBox::GetSelectEntryPos() const
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
SvLBoxEntry* pSvLBoxEntry = FirstSelected();
return pSvLBoxEntry ? GetModel()->GetAbsPos( pSvLBoxEntry ) : LIST_ENTRY_NOTFOUND;
2000-09-18 16:07:07 +00:00
}
2002-07-23 09:52:55 +00:00
XubString SvxFontListBox::GetSelectEntry() const
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
return GetEntryText( GetSelectEntryPos() );
2000-09-18 16:07:07 +00:00
}
2002-07-23 09:52:55 +00:00
void SvxFontListBox::InitEntry(
SvLBoxEntry* pEntry, const XubString& rEntryText,
const Image& rCollImg, const Image& rExpImg,
SvLBoxButtonKind eButtonKind )
2000-09-18 16:07:07 +00:00
{
2002-07-23 09:52:55 +00:00
if( mbUseFont )
2000-09-18 16:07:07 +00:00
{
if( nTreeFlags & TREEFLAG_CHKBTN )
pEntry->AddItem( new SvLBoxButton( pEntry, eButtonKind, 0,
pCheckButtonData ) );
2002-07-23 09:52:55 +00:00
pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, rCollImg, rExpImg, SVLISTENTRYFLAG_EXPANDED ) );
pEntry->AddItem( new SvLBoxFontString( pEntry, 0, rEntryText, maEntryFont, mpEntryColor ) );
2000-09-18 16:07:07 +00:00
}
else
SvTreeListBox::InitEntry( pEntry, rEntryText, rCollImg, rExpImg,
eButtonKind );
2000-09-18 16:07:07 +00:00
}
2002-07-23 09:52:55 +00:00
// ============================================================================